public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/13424] New: Display field offsets
@ 2011-11-21 22:26 sphink at gmail dot com
  2011-11-21 22:28 ` [Bug exp/13424] " sphink at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sphink at gmail dot com @ 2011-11-21 22:26 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13424

             Bug #: 13424
           Summary: Display field offsets
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: exp
        AssignedTo: unassigned@sourceware.org
        ReportedBy: sphink@gmail.com
    Classification: Unclassified


Created attachment 6068
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6068
Display C struct field offsets

For figuring out where things will be on a cache line (among other things), it
would be useful to be able to display the byte offset of each field in a C/C++
struct.

That in itself seems pretty straightforward -- I'll attach a patch that does
just that -- but I can't see a good way of enabling it. I wouldn't want it to
be the default, since it's just too noisy. I would want it to be controlled by
'set print field-offsets on' or an optional parameter to 'ptype' or something.
But it appears that typeprint.c only passes an integer 'show' parameter to the
language-specific type printers. I could overload 'show' to be a set of flags
(the existing 1,0,-1 would be full,summary,short, and I would have a new fields
option to or in), but that would require updating all languages (and would
break external compatibility, if there is such a thing.)

What would be the best way to implement something like this?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug exp/13424] Display field offsets
  2011-11-21 22:26 [Bug exp/13424] New: Display field offsets sphink at gmail dot com
@ 2011-11-21 22:28 ` sphink at gmail dot com
  2011-11-22 19:27 ` tromey at redhat dot com
  2013-03-15 17:43 ` tromey at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: sphink at gmail dot com @ 2011-11-21 22:28 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13424

Steve Fink <sphink at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #6068|0                           |1
           is patch|                            |
   Attachment #6068|application/octet-stream    |text/plain
          mime type|                            |

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug exp/13424] Display field offsets
  2011-11-21 22:26 [Bug exp/13424] New: Display field offsets sphink at gmail dot com
  2011-11-21 22:28 ` [Bug exp/13424] " sphink at gmail dot com
@ 2011-11-22 19:27 ` tromey at redhat dot com
  2013-03-15 17:43 ` tromey at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at redhat dot com @ 2011-11-22 19:27 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13424

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com

--- Comment #1 from Tom Tromey <tromey at redhat dot com> 2011-11-22 19:26:26 UTC ---
(In reply to comment #0)
> Created attachment 6068 [details]
> Display C struct field offsets
> 
> For figuring out where things will be on a cache line (among other things), it
> would be useful to be able to display the byte offset of each field in a C/C++
> struct.

You may want to look at pahole.py as well:

http://permalink.gmane.org/gmane.comp.gdb.patches/58385

> That in itself seems pretty straightforward -- I'll attach a patch that does
> just that -- but I can't see a good way of enabling it. I wouldn't want it to
> be the default, since it's just too noisy. I would want it to be controlled by
> 'set print field-offsets on' or an optional parameter to 'ptype' or something.
> But it appears that typeprint.c only passes an integer 'show' parameter to the
> language-specific type printers. I could overload 'show' to be a set of flags
> (the existing 1,0,-1 would be full,summary,short, and I would have a new fields
> option to or in), but that would require updating all languages (and would
> break external compatibility, if there is such a thing.)
> 
> What would be the best way to implement something like this?

There is no external compatibility, you can change the API with impunity.
I would suggest a new flag to ptype, then passing around a
"const struct ptype_options *" to all functions needing it, where
ptype_options is a new struct you create.  It is more typing to add this
kind of thing, but it seems best to me, since it allows for future changes.
We did this kind of thing for value printing a while ago...

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug exp/13424] Display field offsets
  2011-11-21 22:26 [Bug exp/13424] New: Display field offsets sphink at gmail dot com
  2011-11-21 22:28 ` [Bug exp/13424] " sphink at gmail dot com
  2011-11-22 19:27 ` tromey at redhat dot com
@ 2013-03-15 17:43 ` tromey at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at redhat dot com @ 2013-03-15 17:43 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13424

--- Comment #2 from Tom Tromey <tromey at redhat dot com> 2013-03-15 17:43:02 UTC ---
FWIW, we now have struct type_print_options on the trunk.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-15 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-21 22:26 [Bug exp/13424] New: Display field offsets sphink at gmail dot com
2011-11-21 22:28 ` [Bug exp/13424] " sphink at gmail dot com
2011-11-22 19:27 ` tromey at redhat dot com
2013-03-15 17:43 ` tromey at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).