[Crash-utility] [Patch 0/2] Request data structures of particular size.

Dave Anderson anderson at redhat.com
Wed Apr 6 21:08:33 UTC 2016



----- Original Message -----
> 
> 
> ----- Original Message -----
> > Dave,
> > 
> > thank you for your comment. I've also reviewed the set of existing gdb
> > functions more carefully. Looks like it wasn't necessary to modify existing
> > code in gdb. It suffice to use another function from the same structure (it
> > hasn't been used before - that is why I hadn't noticed it earlier).
> 
> OK good.
> 
> > I've also rewritten the logic within `whatis` command.
> 
> Yeah, actually the whatis command looks like a good fit for this
> functionality.
> 
> Another few changes I'd like you to make.  If you notice, there are no calls
> from the top-level crash sources directly into gdb functions, but rather they
> all pass through gdb_interface(), which calls into gdb_command_funnel().  It's
> always been done that way in order to keep the top-level crash running in case
> of a fatal bug in the execution of gdb code.  Can you please rework your code
> to use gdb_interface()?  It should be simple -- you'll just have to add a new
> GNU command, and then have gdb_command_funnel() act upon it to call your new
> function.
> 
> Secondly, the only time malloc() should ever be used is if an allocation is
> permanent, so please don't use it in request_types().  Use GETBUF() instead,
> which will be free up the memory after the command is run if you forget to
> call FREEBUF(), or should the command fail prematurely.
> 
> For the same reason, it would be preferable if you can avoid the xmalloc() and
> xrealloc() calls in the gdb code.  Historically the gdb cleanup code has been
> a source of problems when combined with the crash utility.  Would it be possible
> to use GETBUF() in request_types() to pre-allocate enough space for your gdb
> function to accomplish its purpose?

BTW, I admit that I am asking you to replace the xmalloc()/xrealloc() stuff without
really studying your code.  But worse case, it seems like you could call into
your gdb function twice, first to quickly determine the maximum possible number of
structures of the size range, then have request_types() call GETBUF() to get the
required space, and then call back into it a second time to gather them into the
allocated space.  Or perhaps you could use the gnu_request structure to pass in
the addresses of getbuf() and resizebuf(), which are used by GETBUF() and RESIZEBUF().
BTW, feel free to add new fields to the end of the gnu_request structure if it
would be helpful.

Thanks,
  Dave

 

Dave




More information about the Crash-utility mailing list