Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Markus Teich <markus.teich@stusta.mhn.de>
To: gdb@sourceware.org
Subject: Re: unexpected output from print
Date: Tue, 26 Mar 2013 22:30:00 -0000	[thread overview]
Message-ID: <5152215D.4060605@stusta.mhn.de> (raw)
In-Reply-To: <m3sj3jvufa.fsf@redhat.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'.
> 


  parent reply	other threads:[~2013-03-26 22:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-23 10:01 Markus Teich
2013-03-26 18:12 ` Tom Tromey
     [not found] ` <m3sj3jvufa.fsf@redhat.com>
2013-03-26 22:30   ` Markus Teich [this message]
2013-03-27 13:31     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5152215D.4060605@stusta.mhn.de \
    --to=markus.teich@stusta.mhn.de \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox