[关闭]
@weixin 2015-05-24T14:38:06.000000Z 字数 16633 阅读 1359

compiler study 5 - crowbar whole workflow

compile


I debugged the crowbar program, just have a rough idea how the crowbar works.

test case 1

preparation

  1. print("hoge\tpiyo\n\\n");

save it as a file, test.crb.

  1. lldb --source test/br_aliases crowbar test/test.crb
  1. command alias bfl breakpoint set -f %1 -l %2
  2. bfl main.c 21
  3. bfl create.c 121
  4. bfl create.c 152
  5. bfl create.c 207
  6. bfl execute.c 298
  7. bfl eval.c 746
  8. bfl eval.c 683
  9. bfl eval.c 656
  10. bfl eval.c 587

begin to debug :

compile process

debug 1
debug 2
debug 3
debug 4
why in this print case, crb_create_funciton_call_expression got triggered.
go back to crowbar.y, you would see this :

  1. primary_expression
  2. : IDENTIFIER LP argument_list RP
  3. {
  4. $$ = crb_create_function_call_expression($1, $3);
  5. }
  6. | IDENTIFIER LP RP
  7. {
  8. $$ = crb_create_function_call_expression($1, NULL);
  9. }

print("hello"); exactly match the pattern.
here is the call graph from doxygen call graph

intepret process

here is the interpret process from doxygen
static analysis
dynamic analysis

dispose interpreter

test cases 2

preparation

  1. print("3 + 5.." + (3 + 5) + "\n"); #this is a comment

test2.crb

debug

lex tokenize process

I used pvtrace and graphviz dynamically analyze the code, here is the pic :
call graph

  1. create identifier

    1. * thread #1: tid = 0x23a0a2, 0x000000010000960c crowbar`crb_create_identifier(str=0x0000000101002200) + 12 at string.c:58, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1
    2. frame #0: 0x000000010000960c crowbar`crb_create_identifier(str=0x0000000101002200) + 12 at string.c:58
    3. 55 {
    4. 56 char *new_str;
    5. 57
    6. -> 58 new_str = crb_malloc(strlen(str) + 1);
    7. 59
    8. 60 strcpy(new_str, str);
    9. 61
  2. the above code shows the str is print, why?

    1. (lldb) p str
    2. (char *) $1 = 0x0000000101002200 "print"

    see crowbar.l,

    1. <INITIAL>[A-Za-z_][A-Za-z_0-9]* {
    2. yylval.identifier = crb_create_identifier(yytext);
    3. return IDENTIFIER;
    4. }
  3. lexer woudl ignore the LP and RP, just go ahead and see ", then decide to open_string_literal

    1. * thread #1: tid = 0x23a0a2, 0x00000001000094c4 crowbar`crb_open_string_literal + 4 at string.c:15, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
    2. frame #0: 0x00000001000094c4 crowbar`crb_open_string_literal + 4 at string.c:15
    3. 12 void
    4. 13 crb_open_string_literal(void)
    5. 14 {
    6. -> 15 st_string_literal_buffer_size = 0;
    7. 16 }
    8. 17
    9. 18 void
  4. then lexer see another ", decide to close string

    1. * thread #1: tid = 0x23a0a2, 0x00000001000095ec crowbar`crb_close_string_literal + 76 at string.c:50, queue = 'com.apple.main-thread', stop reason = step over
    2. frame #0: 0x00000001000095ec crowbar`crb_close_string_literal + 76 at string.c:50
    3. 47 memcpy(new_str, st_string_literal_buffer, st_string_literal_buffer_size);
    4. 48 new_str[st_string_literal_buffer_size] = '\0';
    5. 49
    6. -> 50 return new_str;
    7. 51 }
    8. 52
    9. 53 char *
    10. (lldb) p new_str
    11. (char *) $4 = 0x0000000101000158 "3 + 5.."

compile process

the pattern is like this :

  1. * thread #1: tid = 0x1e945a, 0x00000001000043b2 crowbar`yyparse + 2818 at crowbar.y:148, queue = 'com.apple.main-thread', stop reason = step over
  2. frame #0: 0x00000001000043b2 crowbar`yyparse + 2818 at crowbar.y:148
  3. 145 : multiplicative_expression
  4. 146 | additive_expression ADD multiplicative_expression
  5. 147 {
  6. -> 148 $$ = crb_create_binary_expression(ADD_EXPRESSION, $1, $3);
  7. 149 }
  8. 150 | additive_expression SUB multiplicative_expression
  9. 151 {

then it would start create a binary expression

  1. ESSION, left=0x0000000100803360, right=0x0000000100803378) + 22 at create.c:152, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
  2. frame #0: 0x0000000100005a66 crowbar`crb_create_binary_expression(operator=ADD_EXPRESSION, left=0x0000000100803360, right=0x0000000100803378) + 22 at create.c:152
  3. 149 crb_create_binary_expression(ExpressionType operator,
  4. 150 Expression *left, Expression *right)
  5. 151 {
  6. -> 152 if ((left->type == INT_EXPRESSION
  7. 153 || left->type == DOUBLE_EXPRESSION)
  8. 154 && (right->type == INT_EXPRESSION
  9. 155 || right->type == DOUBLE_EXPRESSION)) {
  10. (lldb) bt
  11. * thread #1: tid = 0x1e945a, 0x0000000100005a66 crowbar`crb_create_binary_expression(operator=ADD_EXPRESSION, left=0x0000000100803360, right=0x0000000100803378) + 22 at create.c:152, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
  12. * frame #0: 0x0000000100005a66 crowbar`crb_create_binary_expression(operator=ADD_EXPRESSION, left=0x0000000100803360, right=0x0000000100803378) + 22 at create.c:152
  13. frame #1: 0x00000001000043b2 crowbar`yyparse + 2818 at crowbar.y:148
  14. frame #2: 0x000000010000550c crowbar`CRB_compile(interpreter=0x0000000100803240, fp=0x00007fff7d8cf070) + 44 at interface.c:47
  15. frame #3: 0x0000000100005358 crowbar`main(argc=2, argv=0x00007fff5fbff798) + 184 at main.c:22
  16. frame #4: 0x00007fff9b5655c9 libdyld.dylib`start + 1
  17. frame #5: 0x00007fff9b5655c9 libdyld.dylib`start + 1

it would first evalue (3+5), the tree looks like this :

  1. (lldb) p left->type
  2. (ExpressionType) $1 = INT_EXPRESSION
  3. (lldb) p right->type
  4. (ExpressionType) $2 = INT_EXPRESSION

then it would

  1. frame #0: 0x0000000100005a66 crowbar`crb_create_binary_expression(operator=ADD_EXPRESSION, left=0x0000000101000140, right=0x0000000101000160) + 22 at create.c:152
  2. 149 crb_create_binary_expression(ExpressionType operator,
  3. 150 Expression *left, Expression *right)
  4. 151 {
  5. -> 152 if ((left->type == INT_EXPRESSION
  6. 153 || left->type == DOUBLE_EXPRESSION)
  7. 154 && (right->type == INT_EXPRESSION
  8. 155 || right->type == DOUBLE_EXPRESSION)) {
  9. (lldb) p left->type
  10. (ExpressionType) $9 = STRING_EXPRESSION
  11. (lldb) p right->u.int_value
  12. (int) $10 = 8
  13. (lldb) p left->u.string_value
  14. (char *) $11 = 0x0000000101000158 "3 + 5.."

test case 3

  1. if (true) {
  2. print("true\n");
  3. }

dynamic code analysis call graph 2

  1. crb_create_boolean_expression, firstly see 'true', then at crowbar.y it create boolean expression

    1. 197 | TRUE_T
    2. 198 {
    3. -> 199 $$ = crb_create_boolean_expression(CRB_TRUE);
    4. 200 }
    5. 201 | FALSE_T
  2. crb_create_identifier, then see 'print', create identifier at crowbar.l

    1. 55 <INITIAL>[A-Za-z_][A-Za-z_0-9]* {
    2. -> 56 yylval.identifier = crb_create_identifier(yytext);
    3. 57 return IDENTIFIER;
    4. 58 }
  3. crb_open_string_literal, then see ", at crowbar.l

    1. <INITIAL>\" {
    2. 72 crb_open_string_literal();
    3. -> 73 BEGIN STRING_LITERAL_STATE;
    4. 74 }
  4. crb_close_string_literal, same as above

    1. <STRING_LITERAL_STATE>\" {
    2. 98 Expression *expression = crb_alloc_expression(STRING_EXPRESSION);
    3. -> 99 expression->u.string_value = crb_close_string_literal();
    4. 100 yylval.expression = expression;
    5. 101 BEGIN INITIAL;
    6. 102 return STRING_LITERAL;
  5. crb_create_argument_list, then see "true\n" as argument, at crowbar.y

    1. argument_list
    2. 74 : expression
    3. 75 {
    4. -> 76 $$ = crb_create_argument_list($1);
    5. 77 }
    6. 78 | argument_list COMMA expression
  6. crb_create_function_call_expression, after get argument_list, then see 'funciton call' at crowbar.y

    1. 177 primary_expression
    2. 178 : IDENTIFIER LP argument_list RP
    3. 179 {
    4. -> 180 $$ = crb_create_function_call_expression($1, $3);
    5. 181 }
    6. 182 | IDENTIFIER LP RP
  7. crb_create_statement_list, then print("true\n"); as a statement, because the statement pattern is expression SEMICOLON

    1. 83 statement_list
    2. 84 : statement
    3. 85 {
    4. -> 86 $$ = crb_create_statement_list($1);
    5. 87 }
  8. crb_create_block

    1. 308 block
    2. 309 : LC statement_list RC
    3. 310 {
    4. -> 311 $$ = crb_create_block($2);
    5. 312 }
    6. 313 | LC RC
  9. crb_create_if_statement

    1. 239 if_statement
    2. 240 : IF LP expression RP block
    3. 241 {
    4. -> 242 $$ = crb_create_if_statement($3, $5, NULL, NULL);
    5. 243 }
    6. 244 | IF LP expression RP block ELSE block
  10. crb_chain_statement_list

    1. frame #0: 0x00000001000040f5 crowbar`yyparse + 2117 at crowbar.y:50
    2. 47 CRB_Interpreter *inter = crb_get_current_interpreter();
    3. 48
    4. 49 inter->statement_list
    5. -> 50 = crb_chain_statement_list(inter->statement_list, $1);

test case 4

dynamic code analysis ![call graph 2]

  1. if (false) {
  2. print("bad\n");
  3. } else {
  4. print("good\n");
  5. }
  1. crb_create_boolean_expression

    1. frame #0: 0x000000010000451b crowbar`yyparse + 3179 at crowbar.y:203
    2. 200 }
    3. 201 | FALSE_T
    4. 202 {
    5. -> 203 $$ = crb_create_boolean_expression(CRB_FALSE);
    6. 204 }
    7. 205 | NULL_T
    8. 206 {
  2. crb_create_identifier, print

    1. frame #0: 0x00000001000019db crowbar`yylex + 1435 at crowbar.l:56
    2. 53 <INITIAL>"/" return DIV;
    3. 54 <INITIAL>"%" return MOD;
    4. 55 <INITIAL>[A-Za-z_][A-Za-z_0-9]* {
    5. -> 56 yylval.identifier = crb_create_identifier(yytext);
    6. 57 return IDENTIFIER;
    7. 58 }
    8. 59 <INITIAL>([1-9][0-9]*)|"0" {
  3. crb_close_string_literal

    1. * thread #1: tid = 0x43fb0, 0x00000001000095ec crowbar`crb_close_string_literal + 76 at string.c:50, queue = 'com.apple.main-thread', stop reason = step over
    2. frame #0: 0x00000001000095ec crowbar`crb_close_string_literal + 76 at string.c:50
    3. 47 memcpy(new_str, st_string_literal_buffer, st_string_literal_buffer_size);
    4. 48 new_str[st_string_literal_buffer_size] = '\0';
    5. 49
    6. -> 50 return new_str;
    7. 51 }
    8. 52
    9. 53 char *
    10. (lldb) p new_str
    11. (char *) $5 = 0x0000000101000170 "bad\n"
    1. frame #0: 0x0000000100001bb1 crowbar`yylex + 1905 at crowbar.l:99
    2. 96 <COMMENT>. ;
    3. 97 <STRING_LITERAL_STATE>\" {
    4. 98 Expression *expression = crb_alloc_expression(STRING_EXPRESSION);
    5. -> 99 expression->u.string_value = crb_close_string_literal();
    6. 100 yylval.expression = expression;
    7. 101 BEGIN INITIAL;
    8. 102 return STRING_LITERAL;
  4. crb_create_argument_list

    1. frame #0: 0x00000001000041a2 crowbar`yyparse + 2290 at crowbar.y:76
    2. 73 argument_list
    3. 74 : expression
    4. 75 {
    5. -> 76 $$ = crb_create_argument_list($1);
    6. 77 }
    7. 78 | argument_list COMMA expression
    8. 79 {
  5. crb_create_function_call

    1. frame #0: 0x00000001000044a0 crowbar`yyparse + 3056 at crowbar.y:180
    2. 177 primary_expression
    3. 178 : IDENTIFIER LP argument_list RP
    4. 179 {
    5. -> 180 $$ = crb_create_function_call_expression($1, $3);
    6. 181 }
    7. 182 | IDENTIFIER LP RP
    8. 183 {
  6. *crb_create_statement_list

  7. crb_create_block

    1. frame #0: 0x0000000100004790 crowbar`yyparse + 3808 at crowbar.y:311
    2. 308 block
    3. 309 : LC statement_list RC
    4. 310 {
    5. -> 311 $$ = crb_create_block($2);
    6. 312 }
    7. 313 | LC RC
  8. crb_create_identifier, print again

  9. crb_close_string_literal, "good\n"
  10. crb_create_argument_list, ("good\n")
  11. crb_create_funcion_call
  12. crb_create_statement_list

    1. (lldb) p statement->u.expression_s->u.function_call_expression
    2. (FunctionCallExpression) $27 = {
    3. identifier = 0x00000001010001e0 "print"
    4. argument = 0x0000000101000208
    5. }
  13. crb_create_block

    1. (lldb) p then_block->statement_list->statement->u.expression_s->type
    2. (ExpressionType) $35 = FUNCTION_CALL_EXPRESSION
  14. crb_create_if_statement

    1. (lldb) p then_block->statement_list->statement->u.expression_s->u.function_call_expression.argument->expression->u.string_value
    2. (char *) $46 = 0x0000000101000170 "bad\n"
  15. crb_chain_statement_list

    1. frame #0: 0x000000010000594e crowbar`crb_chain_statement_list(list=0x0000000000000000, statement=0x0000000101000270) + 30 at create.c:95
    2. 92 StatementList *pos;
    3. 93
    4. 94 if (list == NULL)
    5. -> 95 return crb_create_statement_list(statement);
    6. 96
    7. 97 for (pos = list; pos->next; pos = pos->next)
    8. 98 ;
    9. (lldb) p statement
    10. (Statement *) $47 = 0x0000000101000270
    11. (lldb) p statement->type
    12. (StatementType) $48 = IF_STATEMENT

test case 5

test code :

  1. i = 0;
  2. for (;;) {
  3. print(" i.." + i);
  4. if (i > 5) {
  5. break;
  6. }
  7. i = i + 1;
  8. }
  9. print("\n");

dynamic code analysis : call graph 3

  1. create identifier

    1. frame #0: 0x000000010000960c crowbar`crb_create_identifier(str=0x0000000101800000) + 12 at string.c:58
    2. 55 {
    3. 56 char *new_str;
    4. 57
    5. -> 58 new_str = crb_malloc(strlen(str) + 1);
    6. 59
    7. 60 strcpy(new_str, str);
    8. 61
    9. (lldb) p str
    10. (char *) $1 = 0x0000000101800000 "i"
  2. create assign expression

    1. frame #0: 0x0000000100005a15 crowbar`crb_create_assign_expression(variable=0x0000000101000138, operand=0x0000000101000140) + 21 at create.c:121
    2. 118 {
    3. 119 Expression *exp;
    4. 120
    5. -> 121 exp = crb_alloc_expression(ASSIGN_EXPRESSION);
    6. 122 exp->u.assign_expression.variable = variable;
    7. 123 exp->u.assign_expression.operand = operand;
    8. 124
    9. (lldb) p operand
    10. (Expression *) $3 = 0x0000000101000140
    11. (lldb) p operand->type
    12. (ExpressionType) $4 = INT_EXPRESSION
    13. (lldb) p operand->u.int_value
    14. (int) $5 = 0
  3. crb_chain_statement_list

    1. frame #0: 0x0000000100005940 crowbar`crb_chain_statement_list(list=0x0000000000000000, statement=0x0000000101000170) + 16 at create.c:94
    2. 91 {
    3. 92 StatementList *pos;
    4. 93
    5. -> 94 if (list == NULL)
    6. 95 return crb_create_statement_list(statement);
    7. 96
    8. 97 for (pos = list; pos->next; pos = pos->next)
    1. (lldb) p statement->u.expression_s->type
    2. (ExpressionType) $10 = ASSIGN_EXPRESSION
  4. crb_create_identifier

    1. frame #0: 0x000000010000960c crowbar`crb_create_identifier(str=0x0000000101800016) + 12 at string.c:58
    2. 55 {
    3. 56 char *new_str;
    4. 57
    5. -> 58 new_str = crb_malloc(strlen(str) + 1);
    6. 59
    7. 60 strcpy(new_str, str);
    8. 61
    9. (lldb) p str
    10. (char *) $17 = 0x0000000101800016 "print"
  5. crb_open_string_literal

  6. crb_close_string_literal
  7. crb_create_binary_expression, create binary expr for "i.." + i

    1. frame #0: 0x0000000100005a66 crowbar`crb_create_binary_expression(operator=ADD_EXPRESSION, left=0x00000001010001b0, right=0x00000001010001d8) + 22 at create.c:152
    2. 149 crb_create_binary_expression(ExpressionType operator,
    3. 150 Expression *left, Expression *right)
    4. 151 {
    5. -> 152 if ((left->type == INT_EXPRESSION
    6. 153 || left->type == DOUBLE_EXPRESSION)
    7. 154 && (right->type == INT_EXPRESSION
    8. 155 || right->type == DOUBLE_EXPRESSION)) {
    9. (lldb) p left->type
    10. (ExpressionType) $19 = STRING_EXPRESSION
    11. (lldb) p left->u.string_value
    12. (char *) $20 = 0x00000001010001c8 " i.."
    13. (lldb) p right->u.string_value
    14. (char *) $21 = 0x00000001010001d0 "i"
  8. crb_create_argument_list

    1. frame #0: 0x0000000100005863 crowbar`crb_create_argument_list(expression=0x00000001010001f0) + 19 at create.c:58
    2. 55 {
    3. 56 ArgumentList *al;
    4. 57
    5. -> 58 al = crb_malloc(sizeof(ArgumentList));
    6. 59 al->expression = expression;
    7. 60 al->next = NULL;
    8. 61
    9. (lldb) p expression->type
    10. (ExpressionType) $23 = ADD_EXPRESSION
  9. crb_create_function_call_expression

  10. crb_create_statement_list

    1. frame #0: 0x0000000100005903 crowbar`crb_create_statement_list(statement=0x0000000101000230) + 19 at create.c:82
    2. 79 {
    3. 80 StatementList *sl;
    4. 81
    5. -> 82 sl = crb_malloc(sizeof(StatementList));
    6. 83 sl->statement = statement;
    7. 84 sl->next = NULL;
    8. 85
    9. (lldb) p statement->type
    10. (StatementType) $26 = EXPRESSION_STATEMENT
    11. (lldb) p statement->u.expression_s->type
    12. (ExpressionType) $27 = FUNCTION_CALL_EXPRESSION
    13. (lldb) p statement->u.expression_s->u.string_value
    14. (char *) $28 = 0x00000001010001a8 "print"
  11. crb_create_identifier, "i"

    1. frame #0: 0x000000010000960c crowbar`crb_create_identifier(str=0x0000000101800031) + 12 at string.c:58
    2. 55 {
    3. 56 char *new_str;
    4. 57
    5. -> 58 new_str = crb_malloc(strlen(str) + 1);
    6. 59
    7. 60 strcpy(new_str, str);
    8. 61
    9. (lldb) p str
    10. (char *) $30 = 0x0000000101800031 "i"
  12. crb_create_binary_expression

    1. frame #0: 0x0000000100005a66 crowbar`crb_create_binary_expression(operator=GT_EXPRESSION, left=0x0000000101000270, right=0x0000000101000288) + 22 at create.c:152
    2. 149 crb_create_binary_expression(ExpressionType operator,
    3. 150 Expression *left, Expression *right)
    4. 151 {
    5. -> 152 if ((left->type == INT_EXPRESSION
    6. 153 || left->type == DOUBLE_EXPRESSION)
    7. 154 && (right->type == INT_EXPRESSION
    8. 155 || right->type == DOUBLE_EXPRESSION)) {
    9. (lldb) p left->type
    10. (ExpressionType) $32 = IDENTIFIER_EXPRESSION
    11. (lldb) p right->type
    12. (ExpressionType) $33 = INT_EXPRESSION
    13. (lldb) p left->u.string_value
    14. (char *) $34 = 0x0000000101000268 "i"
    15. (lldb) p left->u.int_value
    16. (int) $35 = 16777832
    17. (lldb) p right->u.int_value
    18. (int) $36 = 5
  13. crb_create_break_statement

    1. frame #0: 0x0000000100004763 crowbar`yyparse + 3763 at crowbar.y:299
    2. 296 break_statement
    3. 297 : BREAK SEMICOLON
    4. 298 {
    5. -> 299 $$ = crb_create_break_statement();
    6. 300 }
    7. 301 ;
    8. 302 continue_statement
  14. crb_create_statement_list

    1. frame #0: 0x00000001000041e3 crowbar`yyparse + 2355 at crowbar.y:86
    2. 83 statement_list
    3. 84 : statement
    4. 85 {
    5. -> 86 $$ = crb_create_statement_list($1);
    6. 87 }
    7. 88 | statement_list statement
  15. crb_create_block

    1. frame #0: 0x0000000100006113 crowbar`crb_create_block(statement_list=0x00000001010002e0) + 19 at create.c:355
    2. 352 {
    3. 353 Block *block;
    4. 354
    5. -> 355 block = crb_malloc(sizeof(Block));
    6. 356 block->statement_list = statement_list;
    7. 357
    8. 358 return block;
  16. crb_create_identifier

    1. frame #0: 0x000000010000962e crowbar`crb_create_identifier(str=0x000000010180004c) + 46 at string.c:60
    2. 57
    3. 58 new_str = crb_malloc(strlen(str) + 1);
    4. 59
    5. -> 60 strcpy(new_str, str);
    6. 61
    7. 62 return new_str;
    8. 63 }
    9. (lldb) p str
    10. (char *) $52 = 0x000000010180004c "i"
  17. crb_create_if_statement

    1. frame #0: 0x0000000100005f4d crowbar`crb_create_if_statement(condition=0x00000001010002a0, then_block=0x00000001010002f0, elsif_list=0x0000000000000000, else_block=0x0000000000000000) + 29 at create.c:289
    2. 286 {
    3. 287 Statement *st;
    4. 288
    5. -> 289 st = alloc_statement(IF_STATEMENT);
    6. 290 st->u.if_s.condition = condition;
    7. 291 st->u.if_s.then_block = then_block;
    8. 292 st->u.if_s.elsif_list = elsif_list;
    1. frame #0: 0x00000001000045d2 crowbar`yyparse + 3362 at crowbar.y:242
    2. 239 if_statement
    3. 240 : IF LP expression RP block
    4. 241 {
    5. -> 242 $$ = crb_create_if_statement($3, $5, NULL, NULL);
    6. 243 }
    7. 244 | IF LP expression RP block ELSE block
  18. create_chain_statement_list,

    1. frame #0: 0x0000000100005940 crowbar`crb_chain_statement_list(list=0x0000000101000258, statement=0x0000000101000300) + 16 at create.c:94
    2. 91 {
    3. 92 StatementList *pos;
    4. 93
    5. -> 94 if (list == NULL)
    6. 95 return crb_create_statement_list(statement);
    7. 96
    8. 97 for (pos = list; pos->next; pos = pos->next)
    9. (lldb) p statement->type
    1. (lldb) p statement->u.expression_s->type
    2. (ExpressionType) $61 = GT_EXPRESSION
  19. crb_chain_statement_list

    1. frame #0: 0x0000000100005940 crowbar`crb_chain_statement_list(list=0x0000000101000258, statement=0x00000001010003a0) + 16 at create.c:94
    2. 91 {
    3. 92 StatementList *pos;
    4. 93
    5. -> 94 if (list == NULL)
    6. 95 return crb_create_statement_list(statement);
    7. 96
    8. 97 for (pos = list; pos->next; pos = pos->next)
    9. (lldb) p statement->type
    10. (StatementType) $79 = EXPRESSION_STATEMENT
    11. (lldb) p statement->u.expression_s
    12. (Expression *) $80 = 0x0000000101000388
    13. (lldb) p statement->u.expression_s->type
    14. (ExpressionType) $81 = ASSIGN_EXPRESSION
    15. (lldb) p statement->u.expression_s->u.string_value
    16. (char *) $82 = 0x00000001010002f8 "i"
  20. crb_create_block

    1. frame #0: 0x0000000100006113 crowbar`crb_create_block(statement_list=0x0000000101000258) + 19 at create.c:355
    2. 352 {
    3. 353 Block *block;
    4. 354
    5. -> 355 block = crb_malloc(sizeof(Block));
    6. 356 block->statement_list = statement_list;
    7. 357
    8. 358 return block;
  21. crb_create_block

    1. frame #0: 0x000000010000612a crowbar`crb_create_block(statement_list=0x0000000101000258) + 42 at create.c:358
    2. 355 block = crb_malloc(sizeof(Block));
    3. 356 block->statement_list = statement_list;
    4. 357
    5. -> 358 return block;
    6. 359 }
    7. 360
    8. 361 Statement *
    9. (lldb) p statement_list->statement->u.expression_s->type
    10. (ExpressionType) $94 = FUNCTION_CALL_EXPRESSION
    11. (lldb) p statement_list->statement->u.expression_s->u.string_value
    12. (char *) $95 = 0x00000001010001a8 "print"
  22. crb_create_for_statement

    1. frame #0: 0x00000001000060ad crowbar`crb_create_for_statement(init=0x0000000000000000, cond=0x0000000000000000, post=0x0000000000000000, block=0x00000001010003d8) + 29 at create.c:341
    2. 338 {
    3. 339 Statement *st;
    4. 340
    5. -> 341 st = alloc_statement(FOR_STATEMENT);
    6. 342 st->u.for_s.init = init;
    7. 343 st->u.for_s.condition = cond;
    8. 344 st->u.for_s.post = post;
  23. crb_chain_statement_list


  24. ignore the later call....

test case 6

call graph

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注