unexpected output from print
Markus Teich
markus.teich@stusta.mhn.de
Tue Mar 26 22:30:00 GMT 2013
Thanks,
that helped a lot.
@Tom: I am already using the machine interface, but unfortunately the
functions for symbol querying are not implemented in gdbmi (the C
library), therefore i parse the output of -data-evaluate-expression
manually.
Since gdbmi is not developed actively anymore: Is there a better way to
use the gdb machine interface from a C program?
--Markus
Am 26.03.2013 02:09, schrieb Sergio Durigan Junior:
> On Saturday, March 23 2013, Markus Teich wrote:
>
>> Yesterday i stumbled upon an unexpected case, where gdb would output a
>> single value without the attribute name in a struct:
>> __in6_u = {__u6_addr8 = "325243A2", '\000' <repeats 11 times>,
>> __u6_addr16 = {41941, 12865, 0, 0, 0, 0, 0, 0}, __u6_addr32 =
>> {843162581, 0, 0, 0}}
>
> This is because GDB is telling you what's the value of every byte of
> this union according to the interpretation each field's type. `uint8_t'
> is actually `unsigned char' on most architectures, so it is treating the
> `__u6_addr8' field as an array of characters.
>
> If you use pretty-printing, you will see things more organized. Try
> `set print pretty on', and print the struct again. Then you will
> understand that the output is actually something like:
>
> __in6_u = {
> __u6_addr8 = "325243A2", '\000' <repeats 11 times>,
> __u6_addr16 = {41941, 12865, 0, 0, 0, 0, 0, 0},
> __u6_addr32 = {843162581, 0, 0, 0}
> }
>
> I.e., the `'\000' <repeats 11 times>' part refers to the first field,
> and is not a second-field-without-a-name as you guessed.
>
> In short: if you want GDB to stop printing the '\000' part, try using
> `set print null-stop on'.
>
More information about the Gdb
mailing list