Apparently due to my penchant for self-abuse, I'm writing a BASIC interpreter in yacc/lex/glib/c. The BASIC program is stored as an array of GLists, each entry in the array representing a line in the source. Each line is GList of statement_t
s, separated by colons in the original source.
I'm trying to debug an oddity that I think is caused by an improperly built GList, but I'm new to C in lldb so I'm not clear how to pull it apart:
(lldb) p ps->parms._if.then_expression
(GList *) $0 = 0x0000000100704b60
(lldb) po ps->parms._if.then_expression
0x0000000100704b60
(lldb) p (statement_t *)ps->parms._if.then_expression.data
(statement_t *) $0 = 0x00000001014040c0
Fix-it applied, fixed expression was:
(statement_t *)ps->parms._if.then_expression->data
then_expression
is a GList of statement_t's to run if the condition is met. My code always runs only the first of these statements, ignoring the rest, which leads me to believe my .next pointer is wrong. But how to tell? Everything is just a pointer.
I assume I have to cast this out to a statement_t I'm lost on the syntax and the examples that I find are less than useful.