This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: unexpected output from print
- From: Markus Teich <markus dot teich at stusta dot mhn dot de>
- To: gdb at sourceware dot org
- Date: Tue, 26 Mar 2013 23:29:49 +0100
- Subject: Re: unexpected output from print
- References: <4dbff288e0c76a516273ba1cb19694b4 at mail dot fs dot tum dot de> <m3sj3jvufa dot fsf at redhat dot com>
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'.
>