all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: GDB and compiler-operations
Date: Fri, 07 Sep 2018 13:59:41 -0600	[thread overview]
Message-ID: <875zzhxemq.fsf@tromey.com> (raw)
In-Reply-To: <jwv36uljtfb.fsf-monnier+gmane.emacs.devel@gnu.org> (Stefan Monnier's message of "Fri, 07 Sep 2018 10:12:06 -0400")

>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

Stefan> Along the way I discovered that while `sizeof` works great, `offsetof`
Stefan> gives me an error:
Stefan>     No symbol "offsetof" in current context.
Stefan> any idea why this is (and how to fix it)?

Other people answered the why.  To fix it you have two options.

One, define an offsetof macro:

(gdb) macro define offsetof(type, field) ((int) (((type *) 0)->field))

The gdb C expression parser will automatically use macros you define
interactively.


Two, instead of using offsetof to inspect a type, upgrade to a newish
(8.1 or better) gdb and use "ptype/o":

    (gdb) ptype/o struct Lisp_Vector
    /* offset    |  size */  type = struct Lisp_Vector {
    /*    0      |     8 */    union vectorlike_header {
    /*                 8 */        ptrdiff_t size;
    /*                 1 */        char gcaligned;

                                   /* total size (bytes):    8 */
                               } header;
    /*    8      |     0 */    Lisp_Object contents[];

                               /* total size (bytes):    8 */
                             }

The output here is modeled on the pahole utility.

If you can't upgrade gdb, there's a "pahole.py" script out there that
adds a pahole command to gdb instead.  I can email it if you really
need it, but some distros installed it by default.  So you could just
try "(gdb) pahole struct Lisp_Vector".

Tom



  parent reply	other threads:[~2018-09-07 19:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06  0:41 Lisp_Marker size on 32bit systems Stefan Monnier
2018-09-06  6:51 ` Paul Eggert
2018-09-06 12:17   ` Stefan Monnier
2018-09-07  7:15     ` Paul Eggert
2018-09-07  8:05       ` Eli Zaretskii
2018-09-07 13:45         ` Paul Eggert
2018-09-07 14:12           ` GDB and compiler-operations (was: Lisp_Marker size on 32bit systems) Stefan Monnier
2018-09-07 14:23             ` Eli Zaretskii
2018-09-07 15:16             ` GDB and compiler-operations Andreas Schwab
2018-09-07 15:48             ` GDB and compiler-operations (was: Lisp_Marker size on 32bit systems) Paul Eggert
2018-09-07 15:58               ` GDB and compiler-operations Stefan Monnier
2018-09-07 17:11                 ` Eli Zaretskii
2018-09-07 17:15                 ` Paul Eggert
2018-09-07 19:59             ` Tom Tromey [this message]
2018-09-07 14:19           ` Lisp_Marker size on 32bit systems Eli Zaretskii
2018-09-07 16:27             ` Paul Eggert
2018-09-07 17:16               ` Eli Zaretskii
2018-09-07 18:13                 ` Paul Eggert
2018-09-07 18:32                   ` Eli Zaretskii
2018-09-07 19:05                     ` Paul Eggert
2018-09-07 19:22                       ` Eli Zaretskii
2018-09-07 12:16       ` Stefan Monnier
2018-09-07 19:04         ` Paul Eggert
2018-09-07 19:45           ` Stefan Monnier
2018-09-07 21:03             ` Paul Eggert
2018-09-08  1:54               ` Stefan Monnier
2018-09-08  3:04                 ` Paul Eggert
2018-09-08  3:10                   ` Stefan Monnier

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=875zzhxemq.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.