[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GDB and compiler-operations
From: |
Tom Tromey |
Subject: |
Re: GDB and compiler-operations |
Date: |
Fri, 07 Sep 2018 13:59:41 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) |
>>>>> "Stefan" == Stefan Monnier <address@hidden> 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
- Re: Lisp_Marker size on 32bit systems, (continued)
- Re: Lisp_Marker size on 32bit systems, Paul Eggert, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Eli Zaretskii, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Paul Eggert, 2018/09/07
- GDB and compiler-operations (was: Lisp_Marker size on 32bit systems), Stefan Monnier, 2018/09/07
- Re: GDB and compiler-operations (was: Lisp_Marker size on 32bit systems), Eli Zaretskii, 2018/09/07
- Re: GDB and compiler-operations, Andreas Schwab, 2018/09/07
- Re: GDB and compiler-operations (was: Lisp_Marker size on 32bit systems), Paul Eggert, 2018/09/07
- Re: GDB and compiler-operations, Stefan Monnier, 2018/09/07
- Re: GDB and compiler-operations, Eli Zaretskii, 2018/09/07
- Re: GDB and compiler-operations, Paul Eggert, 2018/09/07
- Re: GDB and compiler-operations,
Tom Tromey <=
- Re: Lisp_Marker size on 32bit systems, Eli Zaretskii, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Paul Eggert, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Eli Zaretskii, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Paul Eggert, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Eli Zaretskii, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Paul Eggert, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Eli Zaretskii, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Stefan Monnier, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Paul Eggert, 2018/09/07
- Re: Lisp_Marker size on 32bit systems, Stefan Monnier, 2018/09/07