[PATCH 00/40] add cleanup checker and fix cleanup bugs

Tom Tromey
2013-05-09T18:47:11Z

This series adds a cleanup checker and then fixes most of the bugs it
notices.

The series as a whole was built and regression-tested on x86-64 Fedora
18. However, there are a couple of patches that I could not test;
e.g., the machoread.c patch. I would appreciate it if someone could
try these on their machine. The branch is archer.git tromey/cleanup-checker.

In most cases the patches are pretty obvious. I kept them short for
ease of reading.

The cleanup checker itself is described in patch #1. This patch also
describes some of the

After this series, there are still some cleanup-related bugs noticed
by the checker. One of these (in dwarf2read.c) is a false report --
the checker is not perfect and there was no nice workaround here.

The remaining errors are:

disasm.c has some spaghetti code; I didn't try to untangle it to see if
there is a bug here or not:

../../archer/gdb/disasm.c: In function ‘do_mixed_source_and_assembly’:
../../archer/gdb/disasm.c:334:16: error: destructor call with unknown argument [-fpermissive]
../../archer/gdb/disasm.c:335:16: error: destructor call with unknown argument [-fpermissive]
../../archer/gdb/disasm.c:344:1: error: cleanup stack is not empty at return [-fpermissive]
../../archer/gdb/disasm.c:212:19: note: leaked cleanup
../../archer/gdb/disasm.c:211:19: note: leaked cleanup
../../archer/gdb/disasm.c:334:16: error: destructor call with unknown argument [-fpermissive]
../../archer/gdb/disasm.c:335:16: error: destructor call with unknown argument [-fpermissive]

infrun.c bugs, reported to bugzilla:

../../archer/gdb/infrun.c: In function ‘normal_stop’:
../../archer/gdb/infrun.c:6171:1: error: cleanup stack is not empty at return [-fpermissive]
../../archer/gdb/infrun.c:5930:18: note: leaked cleanup
../../archer/gdb/infrun.c:5921:19: note: leaked cleanup
../../archer/gdb/infrun.c: In function ‘keep_going’:
../../archer/gdb/infrun.c:5728:8: error: cleanup stack is not empty at return [-fpermissive]
../../archer/gdb/infrun.c:5669:19: note: leaked cleanup

I wasn't sure what to do about this -- there are many return paths
here that don't deal with the cleanups:

../../archer/gdb/record-full.c: In function ‘record_full_wait_1’:
../../archer/gdb/record-full.c:1492:1: error: cleanup stack is not empty at return [-fpermissive]

Likewise:

../../archer/gdb/record-btrace.c: In function ‘record_btrace_insn_history’:
../../archer/gdb/record-btrace.c:336:1: error: cleanup stack is not empty at return [-fpermissive]
../../archer/gdb/record-btrace.c:274:17: note: leaked cleanup
../../archer/gdb/record-btrace.c: In function ‘record_btrace_call_history’:
../../archer/gdb/record-btrace.c:565:1: error: cleanup stack is not empty at return [-fpermissive]
../../archer/gdb/record-btrace.c:503:17: note: leaked cleanup