From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23543 invoked by alias); 13 May 2013 17:45:07 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 23525 invoked by uid 306); 13 May 2013 17:45:06 -0000 Date: Mon, 13 May 2013 17:45:00 -0000 Message-ID: <20130513174506.23441.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/cleanup-checker: introduce scoped cleanups X-Git-Refname: refs/heads/tromey/cleanup-checker X-Git-Reftype: branch X-Git-Oldrev: 9b1fe3dce529c03c56b26b92eadbac1f866ce955 X-Git-Newrev: 212f7dae72349005357393d8c3b80e88c2e2c46b X-SW-Source: 2013-q2/txt/msg00066.txt.bz2 List-Id: The branch, tromey/cleanup-checker has been updated discards 9b1fe3dce529c03c56b26b92eadbac1f866ce955 (commit) discards 28bbcf20b7b4a0f597237b56a7eb8793c65edbed (commit) discards b742ab349892cce15df6d761190d17eb27a23976 (commit) discards 72b491c4ccd7996cf471b85b346616f207e69760 (commit) discards f1ed049596b4deed84518830462a7ffbd371979c (commit) discards 09983ec5522012abad22c2484ede6d58c346cf26 (commit) discards c76ac86917cfd5f8d783730da496285ac7d956d2 (commit) discards cdcd1ee9c3501362c7071ec6b0e818d5ef775809 (commit) discards bb421a989e7dc3696315823b8918092f0ee174c8 (commit) discards 6d00e10eddf7b9b5594aedb29d2e2135eb116800 (commit) discards 09f8d24b18b1f4beea87459625e0ce2a6bf03992 (commit) discards a0b282774d0e5948ea2655ac2ec496cacea7a9ba (commit) discards 29862d1dbc5bb0ffb1057fe4775efc0d0c83bdf0 (commit) discards 27ac4476e9e4f7a238ca9f86ec955ef6d2d21c02 (commit) discards 9de1593e2a53e2414bfb06ccd238a2a4adc148be (commit) discards 22b53119e9c8e26a32ff9300d698725e29cd123c (commit) discards 5bd523b8ded5668a3e8ad94f2951300d4eebcecf (commit) discards 8151eef178cd96ab3106cccaa3afc8ece5b69d71 (commit) discards 1ebfefe7d65c7532c9e13534b43915d6c0f3661e (commit) discards f839ed581f8468feb9294637cf8e8367de36080c (commit) discards 0c04640cda1b579c51d4e8025be9202a374f040b (commit) discards 0567c8d5e10110e8c6590c0b1ca9bcfad6500f49 (commit) discards 76ff0a4abfd2d95bee57e14b151c26f4ad42e80c (commit) discards f5a385fdac093cd96ac660b38a2a9ba199b98044 (commit) discards ab1481fe59388b02c51c672114261bcb40261ca7 (commit) discards 4904a5c8b2929216849840bc807a85ea30300176 (commit) discards 568e3554958cb42488bc51f5e2bd8b5cd817803c (commit) discards 9950c2e4c9891c1b716d6c6d32107ddd7e97c5a5 (commit) via 212f7dae72349005357393d8c3b80e88c2e2c46b (commit) via ac28d0b42cadec26606c351c4dc0da64b4ad7cc9 (commit) via e13ea91044ecb6b7e11ef6a0948a6344ffd74c7b (commit) via b5934aa76217694c13b6942ceb8cdc1347b3fe90 (commit) via b908d1f6d6bb9abe29ae0d51b50590ef2b05b2a8 (commit) via 62c38fe0b1ff8bf404a80e3fdcaf7674447342d5 (commit) via 68aa964f224cd625de302c7a92cf04002ced6011 (commit) via 3126887c2a009b84551f6928146274eb257d299c (commit) via 1b6aab822d8534f9aa988c4a6decebbbc7cc9682 (commit) via cd87ddaa4a8f00efdda393d1e46c97026061c60f (commit) via 0e4714eb136cb739e765b48bf92577f4d97a845f (commit) via 0045f22ad9b72875d5ac8cea97490ae0d0cd5e9b (commit) via afc715666e5fa331f966e3039b0c235155ce1277 (commit) via d8eab1fc5ef85749c7323128f719c9f7f6d62a66 (commit) via 2d3e0116baaa0352c711db1cbb2149a40c84fd48 (commit) via f3940903f9784069c2b7291830fd1a5d05bc595e (commit) via d2a26c8f60250b73c0af1dc69afd7e24d07709f5 (commit) via 19ad7176bb73d31dcf94ec0c73739b2d3d906719 (commit) via 41aceedec390eee91fc7ea6cb64ab83c88ae7f2a (commit) via 581961da08a63cfee0d973a33ef7faa3c87b143f (commit) via 84e0e8372df7f377bb9352ea0412ce8412459cc1 (commit) via 4325d09461e89376402d4c594c34d4d51ee54eb2 (commit) via a737657e27e1595d5b04bdbbd772be1b7a746696 (commit) via cd06d044eb69a3e50650744f950179eeed15e3b6 (commit) via 8aaa4bff619497e49e8a61a54df0b7f82779bdaa (commit) via 3b154a472ffac9cea9c09221ece6af9e77b31625 (commit) via 4fa96e4172912d0b76468717cc3571bed32dd2cd (commit) via 7c03920f78b234c426fdb1307a8035b268d21562 (commit) from 9b1fe3dce529c03c56b26b92eadbac1f866ce955 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 212f7dae72349005357393d8c3b80e88c2e2c46b Author: Tom Tromey Date: Thu May 9 11:44:45 2013 -0600 introduce scoped cleanups This adds scoped cleanups to gdb. A scoped cleanup is a more efficient, and checkable, alternative to the common idiom: cleanup = make_cleanup (null_cleanup, NULL); ... do_cleanups (cleanup); ... where the cleanup is always run when exiting the scope. The efficiency comes from stack allocating the scoped cleanup. This is probably minor. However, I've noticed myself sometimes avoiding null cleanups on this basis, and it is nice to erase that bias. The checking comes from using a GCC extension when available. This check ensures that the scoped cleanup was either run or discarded when the scope exits. commit ac28d0b42cadec26606c351c4dc0da64b4ad7cc9 Author: Tom Tromey Date: Wed May 8 14:57:11 2013 -0600 fix up xml-support.c xml-support.c has a function that returns a cleanup via an out parameter. This changes this function to be a normal cleanup constructor -- returning the cleanup directly and returning the other result via an out parameter. This is sort of a hack, but it lets the checker work here. I also noticed that gdb_xml_create_parser_and_cleanup is not really needed, so I removed it. * xml-support.c (gdb_xml_create_parser_and_cleanup_1): Return a cleanup. Remove 'old_chain' argument. Add 'parser_result' argument. (gdb_xml_create_parser_and_cleanup): Remove. (gdb_xml_parse_quick): Use gdb_xml_create_parser_and_cleanup_1. (xml_process_xincludes): Update. * xml-support.h (gdb_xml_create_parser_and_cleanup): Don't declare. commit e13ea91044ecb6b7e11ef6a0948a6344ffd74c7b Author: Tom Tromey Date: Wed May 8 14:52:26 2013 -0600 fix compile_rx_or_error compile_rx_or_error looks like a constructor, but it can return NULL. This patch changes it to remove the NULL return, making it work like any other cleanup constructor. This is a stylistic patch but I think it is also better for code to follow the normal conventions. * probe.c (collect_probes): Check arguments for NULL before calling compile_rx_or_error. * utils.c (compile_rx_or_error): Require 'rx' to be non-NULL. Remove NULL return. commit b5934aa76217694c13b6942ceb8cdc1347b3fe90 Author: Tom Tromey Date: Tue May 7 11:57:54 2013 -0600 some fixes to infrun.c This fixes some of the problems in infrun.c that the checker reported. I filed the remaining problems as bugs. This patch is purely stylistic. * infrun.c (handle_vfork_child_exec_or_exit) (fetch_inferior_event, adjust_pc_after_break): Introduce an outer null cleanup. commit b908d1f6d6bb9abe29ae0d51b50590ef2b05b2a8 Author: Tom Tromey Date: Tue May 7 11:36:46 2013 -0600 fix breakpoint_1 This is a stylistic change to make breakpoint_1 analyzable. The issue here is maybe fixable in the analyzer with some work. * breakpoint.c (breakpoint_1): Introduce an outer null cleanup. commit 62c38fe0b1ff8bf404a80e3fdcaf7674447342d5 Author: Tom Tromey Date: Tue May 7 11:34:59 2013 -0600 introduce dangling_cleanup attribute and change source to use it Some functions leak cleanups on purpose. However, these functions aren't "constructors" in the cleanup-checker sense, as they do not return the cleanup. This patch adds an attribute that can be used to mark these functions. This avoids a bunch of false reports from the checker. This patch is really a huge hack. It is basically giving up on cleanly checking the use of cleanups. You can see this most easily by noticing that I elected not to have this property propagate through the call chain. Still, I figured I'd see what people thought of this patch. Without it the checker is harder to use, as you must know which functions are ignorable. Maybe some of these are fixable with a bit more thought. * ada-lang.c (old_renaming_is_invisible): Use DANGLING_CLEANUP. * breakpoint.c (breakpoint_re_set_default): Use DANGLING_CLEANUP. * c-exp.y (operator_stoken): Use DANGLING_CLEANUP. * coffread.c (coff_locate_sections): Use DANGLING_CLEANUP. * contrib/cleanup_check.py (leaks_cleanup): New global. (note_dangling_cleanup, leaves_dangling_cleanup): New functions. (CleanupChecker.compute_master): Add comment. Check leaves_dangling_cleanup. (CleanupChecker.check_cleanups): Don't mention special constructors to the user. (register_attributes): New function. Register it with gcc. * defs.h (DANGLING_CLEANUP): New define. * dwarf2read.c (read_cutu_die_from_dwo, handle_DW_AT_stmt_list) (setup_type_unit_groups, dwarf2_add_field, dwarf2_add_typedef) (dwarf2_add_member_fn, psymtab_include_file_name) (dwarf_decode_lines): Use DANGLING_CLEANUP. * linux-nat.c (linux_child_pid_to_exec_file): Use DANGLING_CLEANUP. * python/py-prettyprint.c (push_dummy_python_frame): Use DANGLING_CLEANUP. * stabsread.c (read_member_functions, read_struct_fields) (read_baseclasses): Use DANGLING_CLEANUP. * utils.h (gdb_bfd_errmsg): Use DANGLING_CLEANUP. commit 68aa964f224cd625de302c7a92cf04002ced6011 Author: Tom Tromey Date: Tue May 7 10:55:56 2013 -0600 fix mi-cmd-var.c This is a stylistic change in mi-cmd-var.c that adds outer cleanups where needed by the checker. * mi/mi-cmd-var.c (mi_cmd_var_list_children): Add an outer null cleanup. (mi_cmd_var_update, varobj_update_one): Likewise. commit 3126887c2a009b84551f6928146274eb257d299c Author: Tom Tromey Date: Tue May 7 10:54:48 2013 -0600 fix cli-script.c read_command_lines_1 had some (IMNSHO) spaghetti-ish code for cleanup handling. This makes the code much simpler to understand, by introducing an outer cleanup. This is another case where a stylistic change for the checker is also nice for the reader. * cli/cli-script.c (read_command_lines_1): Use a null cleanup for 'old_chain'. Do not check 'head' before processing cleanups. commit 1b6aab822d8534f9aa988c4a6decebbbc7cc9682 Author: Tom Tromey Date: Tue May 7 09:23:12 2013 -0600 fix mi-cmd-stack.c mi-cmd-stack.d had a conditional cleanup, "cleanup_tuple" that confused the checker. However, there was no need for this, since it was only used via do_cleanups at the end of the function, just before another call to do_cleanups. So, while this is a stylistic patch for the checker, I also consider it a generic improvement for readers of the code. * mi/mi-cmd-stack.c (list_arg_or_local): Remove "cleanup_tuple". commit cd87ddaa4a8f00efdda393d1e46c97026061c60f Author: Tom Tromey Date: Tue May 7 09:03:52 2013 -0600 fix dbxread.c This is a stylistic change to make some code in dbxread.c analyzable by the checker. * dbxread.c (dbx_read_symtab): Declare 'back_to' in a more inner scope. Unconditionally call do_cleanups. commit 0e4714eb136cb739e765b48bf92577f4d97a845f Author: Tom Tromey Date: Tue May 7 09:01:51 2013 -0600 fix source.c find_and_open_source can leak a cleanup. * source.c (find_and_open_source): Call do_cleanups. commit 0045f22ad9b72875d5ac8cea97490ae0d0cd5e9b Author: Tom Tromey Date: Tue May 7 08:53:19 2013 -0600 fix linux-thread-db.c This is a stylistic change to make it so the checker can analyze a function in linux-thread-db.c. * linux-thread-db.c (thread_db_load_search): Unconditionally call do_cleanups. commit afc715666e5fa331f966e3039b0c235155ce1277 Author: Tom Tromey Date: Mon May 6 13:47:54 2013 -0600 fix in solib-aix.c solib_aix_bfd_open has an early "return" that doesn't run cleanups. This fixes the problem by dropping the null_cleanup and using a later cleanup as the master cleanup for the function. * solib-aix.c (solib_aix_bfd_open): Don't use a null cleanup for 'cleanup'; instead use a later one. commit d8eab1fc5ef85749c7323128f719c9f7f6d62a66 Author: Tom Tromey Date: Thu Mar 7 07:43:40 2013 -0700 use explicit returns to avoid checker confusion The checker does not understand the idiom if (except.reason < 0) { do_cleanups (whatever); GDB_PY_HANDLE_EXCEPTION (except); } because it doesn't realize that the nested 'if' actually has the same condition. This fixes instances of this to be more explicit. * python/py-breakpoint.c (bppy_get_commands): Use explicit, unconditional return. * python/py-frame.c (frapy_read_var): Likewise. * python/python.c (gdbpy_decode_line): Likewise. commit 2d3e0116baaa0352c711db1cbb2149a40c84fd48 Author: Tom Tromey Date: Tue Mar 5 14:43:27 2013 -0700 fix cp-namespace.c cp_lookup_symbol_imports_or_template could return without running cleanups. * cp-namespace.c (cp_lookup_symbol_imports_or_template): Call do_cleanups on all return paths. commit f3940903f9784069c2b7291830fd1a5d05bc595e Author: Tom Tromey Date: Tue Mar 5 14:36:21 2013 -0700 fix top.c execute_command can leak a cleanup along one return path. * top.c (execute_command): Discard 'cleanup_if_error' cleanups. commit d2a26c8f60250b73c0af1dc69afd7e24d07709f5 Author: Tom Tromey Date: Tue Mar 5 14:33:18 2013 -0700 fix one bug in stabsread.c Some code in stabsread.c can return without running cleanups. * stabsread.c (read_struct_type): Call do_cleanups along all return paths. commit 19ad7176bb73d31dcf94ec0c73739b2d3d906719 Author: Tom Tromey Date: Tue Mar 5 14:31:14 2013 -0700 fix mipsread.c Some code in mipsread.c could leak cleanups along some return paths. * mipsread.c (read_alphacoff_dynamic_symtab): Call do_cleanups along all return paths. commit 41aceedec390eee91fc7ea6cb64ab83c88ae7f2a Author: Tom Tromey Date: Tue Mar 5 14:22:40 2013 -0700 fix one bug in symfile.c find_separate_debug_file could leak a cleanup along some return paths. * symfile.c (find_separate_debug_file): Call do_cleanups along all return paths. commit 581961da08a63cfee0d973a33ef7faa3c87b143f Author: Tom Tromey Date: Tue Mar 5 14:21:16 2013 -0700 fix symtab.c search_symbols had some bad code resulting in a cleanup being both discarded and run. * symtab.c (search_symbols): Introduce a null cleanup for 'retval_chain'. commit 84e0e8372df7f377bb9352ea0412ce8412459cc1 Author: Tom Tromey Date: Tue Mar 5 14:13:35 2013 -0700 fix py-value.c Some code in py-value.c could exit a loop without running some cleanups made in the loop. * python/py-value.c (valpy_binop): Call do_cleanups before exiting loop. commit 4325d09461e89376402d4c594c34d4d51ee54eb2 Author: Tom Tromey Date: Tue Mar 5 14:11:25 2013 -0700 fix py-prettyprint.c print_children, in py-prettyprint.c, could call do_cleanups twice on the same cleanup. * python/py-prettyprint.c (print_children): Remove extra do_cleanups call. commit a737657e27e1595d5b04bdbbd772be1b7a746696 Author: Tom Tromey Date: Tue Mar 5 14:10:29 2013 -0700 fix py-frame.c A couple return paths in frapy_read_var were missing do_cleanups calls. * python/py-frame.c (frapy_read_var): Call do_cleanups along all return paths. commit cd06d044eb69a3e50650744f950179eeed15e3b6 Author: Tom Tromey Date: Tue Mar 5 14:08:39 2013 -0700 fix py-breakpoint.c One return path in bppy_get_commands was missing a do_cleanups call. * python/py-breakpoint.c (bppy_get_commands): Call do_cleanups along all return paths. commit 8aaa4bff619497e49e8a61a54df0b7f82779bdaa Author: Tom Tromey Date: Tue Mar 5 14:05:33 2013 -0700 simplify cli-logging.c for analysis This is another stylistic patch. It changes cli-logging.c to be analyzable by the checker, again following the method of adding an outer cleanup and unconditionally calling do_cleanups. * cli/cli-logging.c (set_logging_redirect): Unconditionally call do_cleanups. commit 3b154a472ffac9cea9c09221ece6af9e77b31625 Author: Tom Tromey Date: Tue Mar 5 14:04:14 2013 -0700 fix varobj.c c_value_of_root is missing a call to do_cleanups at one return. This fixes the problem by removing that return and letting control fall through. * varobj.c (c_value_of_root): Call do_cleanups along all return paths. commit 4fa96e4172912d0b76468717cc3571bed32dd2cd Author: Tom Tromey Date: Tue Mar 5 14:00:20 2013 -0700 make a cleanup unconditionally in tracepoint.c This is another cosmetic patch. It introduces an "outer" cleanup in trace_dump_command and arranges to unconditionally call do_cleanups. This lets the checker analyze the function. * tracepoint.c (trace_dump_command): Unconditionally call do_cleanups. commit 7c03920f78b234c426fdb1307a8035b268d21562 Author: Tom Tromey Date: Mon Mar 4 14:08:50 2013 -0700 fix two buglets in breakpoint.c First, output_thread_groups leaks a cleanup along one return path. Second, parse_cmd_to_aexpr could return without running its cleanups, if there was an exception in a TRY_CATCH. * breakpoint.c (output_thread_groups, parse_cmd_to_aexpr): Call do_cleanups earlier. ----------------------------------------------------------------------- Summary of changes: gdb/breakpoint.c | 10 ++++------ gdb/utils.c | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) First 500 lines of diff: diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index a9f1921..47539f1 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5805,8 +5805,7 @@ output_thread_groups (struct ui_out *uiout, VEC(int) *inf_num, int mi_only) { - struct cleanup *back_to = make_cleanup_ui_out_list_begin_end (uiout, - field_name); + struct cleanup *back_to; int is_mi = ui_out_is_mi_like_p (uiout); int inf; int i; @@ -5814,10 +5813,9 @@ output_thread_groups (struct ui_out *uiout, /* For backward compatibility, don't display inferiors in CLI unless there are several. Always display them for MI. */ if (!is_mi && mi_only) - { - do_cleanups (back_to); - return; - } + return; + + back_to = make_cleanup_ui_out_list_begin_end (uiout, field_name); for (i = 0; VEC_iterate (int, inf_num, i, inf); ++i) { diff --git a/gdb/utils.c b/gdb/utils.c index fa54e10..18ee9bb 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1135,6 +1135,8 @@ compile_rx_or_error (regex_t *pattern, const char *rx, const char *message) { int code; + gdb_assert (rx != NULL); + code = regcomp (pattern, rx, REG_NOSUB); if (code != 0) { hooks/post-receive -- Repository for Project Archer.