Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 17, 2013 Debug information for enumerator values | ||||
---|---|---|---|---|
| ||||
I've implemented this in gdc. https://github.com/D-Programming-GDC/GDC/commit/021dda8feaba282fec60600729ba8abc2c64cf81 --- enum enum_byte : byte { kE1, kE2, kE3 } enum enum_ubyte : ubyte { kE1, kE2, kE3 } enum enum_short : short { kE1, kE2, kE3 } enum enum_ushort : ushort { kE1, kE2, kE3 } enum enum_int : int { kE1, kE2, kE3 } enum enum_uint : uint { kE1, kE2, kE3 } enum enum_long : long { kE1, kE2, kE3 } enum enum_ulong : ulong { kE1, kE2, kE3 } void main() { enum_byte var_byte; enum_ubyte var_ubyte; enum_short var_short; enum_ushort var_ushort; enum_int var_int; enum_uint var_uint; enum_long var_long; enum_ulong var_ulong; } --- (gdb) print var_byte $1 = test.enum_byte.kE1 (gdb) print var_ubyte $2 = test.enum_ubyte.kE1 (gdb) print var_short $3 = test.enum_short.kE1 (gdb) print var_ushort $4 = test.enum_ushort.kE1 (gdb) print var_int $5 = test.enum_int.kE1 (gdb) print var_uint $6 = test.enum_uint.kE1 (gdb) print var_long $7 = test.enum_long.kE1 (gdb) print var_ulong $8 = test.enum_ulong.kE1 (gdb) print (ulong)var_ulong $9 = 0 (gdb) print (byte)'test.enum_uint.kE2' $10 = 1 '\001' (gdb) print ('test.enum_ulong')3 $11 = (test.enum_ulong.kE2 | test.enum_ulong.kE3) (gdb) print ('test.enum_ulong')2 $12 = test.enum_ulong.kE3 (gdb) print ('test.enum_ulong')4 $13 = (unknown: 4) What do you think? Is <module>.<name>.<member> too verbose, or just right? :-) Regards Iain |
September 17, 2013 Re: Debug information for enumerator values | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On Tuesday, 17 September 2013 at 09:52:37 UTC, Iain Buclaw wrote:
> (gdb) print ('test.enum_ulong')3
> $11 = (test.enum_ulong.kE2 | test.enum_ulong.kE3)
>
> (gdb) print ('test.enum_ulong')2
> $12 = test.enum_ulong.kE3
>
> What do you think? Is <module>.<name>.<member> too verbose, or just right? :-)
>
> Regards
> Iain
Kickass! I think it's "just right"... _BUT_ in case of multiple values, I would prefer something like this:
$11 = test.enum_ulong(kE2 | kE3)
|
September 17, 2013 Re: Debug information for enumerator values | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tove | On 17 September 2013 11:02, Tove <tove@fransson.se> wrote: > On Tuesday, 17 September 2013 at 09:52:37 UTC, Iain Buclaw wrote: >> >> (gdb) print ('test.enum_ulong')3 >> $11 = (test.enum_ulong.kE2 | test.enum_ulong.kE3) >> >> (gdb) print ('test.enum_ulong')2 >> $12 = test.enum_ulong.kE3 >> >> What do you think? Is <module>.<name>.<member> too verbose, or just right? :-) >> >> Regards >> Iain > > > Kickass! I think it's "just right"... _BUT_ in case of multiple values, I would prefer something like this: > > $11 = test.enum_ulong(kE2 | kE3) Need to open a bug report on 'wishlist' items in gdb D support. As I plan to get round to hacking it sometime soon... -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; |
September 17, 2013 Re: Debug information for enumerator values | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On 17 September 2013 10:52, Iain Buclaw <ibuclaw@ubuntu.com> wrote: > I've implemented this in gdc. > > https://github.com/D-Programming-GDC/GDC/commit/021dda8feaba282fec60600729ba8abc2c64cf81 > > Now done the same for manifest constants. https://github.com/D-Programming-GDC/GDC/commit/6b40c481068530374abb0819b80c7d2ef09072fd --- enum A { a = 42, b = 45 } enum foo = A.a; void main() { enum bar = A.b; enum baz = &main; return; } -- (gdb) print 'test.foo' $1 = enum.A.a (gdb) print bar $2 = enum.A.b (gdb) print baz $3 = (void (* const)(void)) 0x402a00 <D main> (gdb) p (int)bar $4 = 45 Note that these values are purely in the debug code only - they are not addressable in memory, and are not emitted in non-debug object files/binaries - meaning there is no bloat added. (gdb) p &'test.foo' Can't take address of "test.foo" which isn't an lvalue. (gdb) p &baz Can't take address of "baz" which isn't an lvalue. Hope this helps those who use CTFE a lot. ;-) -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; |
Copyright © 1999-2021 by the D Language Foundation