This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Ensure result of make_cleanup is never NULL.


On 04/16/2012 03:40 PM, Joel Brobecker wrote:

>> +/* A fencepost used to mark the end of a cleanup chain.
>> +   The value is chosen to be non-NULL so that make_cleanup never returns NULL,
>> +   and cause a segv if dereferenced.  */
>> +#define CLEANUP_FENCEPOST ((struct cleanup *) 1)
> 
> Just a tiny idea, not really important, but JIC: Could we use an enum
> intead of a define so that GDB prints "CLEANUP_FENCEPOST" rather than
> a numeric value when we print a cleanup pointer that's the fencepost?


No, because what you'll be printing will have type struct cleanup pointer, not
whatever enum it was cast from.

I see at least two ways to get something like that:

- a gdb specific pretty printer for cleanups.

- Make the sentinel a real object:

   static struct cleanup sentinel_cleanup;
   #define CLEANUP_FENCEPOST &sentinel_cleanup

  And get Tromey's "set print symbol" patch in, which IIRC/IIUC, the
  latest version makes GDB print the symbol name corresponding
  to addresses by default.  Then gdb would print something like:

   (gdb) p old_chain
   $1 = 0xfoobar <sentinel_cleanup>

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]