I have written a python function for gdb to print an array to save me time,to type the same line everytime.
define print_array
print *($arg0)@(sizeof($arg0)/ sizeof($arg0[0])
end
It works like expected, but when I try to print an array of structs, I get the following error :
>>> print_array opcode_list
A syntax error in expression, near `'.
>>>
When I type it by hand, it works without errors.
>>> print *(opcode_list)@(sizeof(opcode_list)/sizeof(opcode_list[0]))
$2 = {[0] = {
opcode_str = 0x401484 "halt",
output = 0
}, [1] = {
opcode_str = 0x401489 "pushc",
output = 1
}, ...
Could someone explain me, what is my fault? And also give me maybe a hint/better solution for this?