This is the mail archive of the 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]

gcc plugin for checking gdb's exception handlers

I wrote a GCC plugin, using David Malcolm's excellent Python plugin, to
check for proper use of gdb exceptions in the Python code.  I added new
'gdb_throw' and 'gdb_nothrow' attributes and marked a couple spots in
the sources.  The plugin examines all the calls in a file and writes out
a sort of call graph as Python code.  Then, after rebuilding GDB with
the plugin in place, there is a second program that reads all the data,
propagates the "can-throw" property through the call graph, and reports
errors whenever a nothrow function is discovered to throw.  It reports
the path from the function to the throw, like this:

../../archer/gdb/python/python.c:481: error: function gdbpy_decode_line is marked nothrow but can throw
../../archer/gdb/python/python.c:497: info: via call to get_current_arch
../../archer/gdb/arch-utils.c:758: info: via call to get_selected_frame
../../archer/gdb/frame.c:1360: info: via call to error
../../archer/gdb/utils.c:830: info: via call to throw_verror

I also had it mark cleanup functions as 'nothrow', since I thought that
is either the rule or what the rule should be.  This showed a number of
errors, enough that I am not sure what I want to do about it yet.

I'm attaching the plugin and the analysis program.  If you run it
yourself, please note that it still emits some false reports.  You must
examine each one, especially the ones arising from indirect function
calls, to see whether it is real.

I plan to run it periodically to check for new bugs.  To that end I will
probably put in the needed gdb patch, also attached.

I filed a bug for all the reports in the Python code.


Description: gcc plugin

Description: analyzer

Attachment: P
Description: gdb patch

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