public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/cleanup-checker: change scoped cleanups to stack cleanups
@ 2013-05-30 19:47 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2013-05-30 19:47 UTC (permalink / raw)
  To: archer-commits

The branch, tromey/cleanup-checker has been updated
  discards  f26e60871e12e8ba7651cf88cb402200f8226d16 (commit)
  discards  a01403135f477831cccb1c3fa34f7f29eaf75fd9 (commit)
  discards  7ef4cda889445acfa00ca6307f5d5082d170d337 (commit)
  discards  a589e2334228c4fcb03fd952487424f0c2f46849 (commit)
  discards  63e1de180de13d471acba8f9493bb2da783f94fc (commit)
  discards  94b88420d562d1eca9174ec3e4e75a2785fa10dc (commit)
  discards  b1f69b82ad0c660e7a9e9b3c2802b538a1422f72 (commit)
  discards  6ef5185fb4c9e56ea2ad8d1a946f3b100788a9c8 (commit)
  discards  97a878aafcb9fb5d96d58d338eced4e33d0f44f3 (commit)
  discards  ec58b0fde961f2690bbbd96dba05fa95f8b6a372 (commit)
  discards  aefbc7f812bd6ba29b325259db6671e8445e9336 (commit)
  discards  b7a812dd4917127092506d553e272af5dae850a4 (commit)
  discards  ef9c480111a8690c75cdd6511548cb67937d8fec (commit)
  discards  a668032e7290ea919107eba7ef30e3cc692d7e4c (commit)
  discards  d6e43a22bc6881d76531ae50aca5890e54e1dd27 (commit)
  discards  c60d61364ef9495e1bc2abfac706c1df3910703e (commit)
  discards  8afb1df85d77506299baa184e21a84659f821fd6 (commit)
  discards  91b04b4ff6734b84ac86698fe9b997b6e4bfd2ec (commit)
  discards  b1d0a17cae829f4803e620c276a621dcb52e9e70 (commit)
  discards  61b2347fe4723b9be3d610512204e751eafa121c (commit)
  discards  22303b7ab5507251ef6018ce38c6f6d2821b49f1 (commit)
  discards  adce7f2e66dda08496454edc49ae2aa804b478a5 (commit)
  discards  c1ad672225924b65e17ccc0d3e1d2e4828712b04 (commit)
  discards  294545274a140f585698e2eaee4ca9b958e5207c (commit)
  discards  2c4db0257b18006ccf91c6f4d8c34e3f4acd289c (commit)
  discards  cfbd88c558cfc279dbd3f9cc01c66ba9a21bfbae (commit)
  discards  fbea9698cc7400f45814f240fcf673c86da1e894 (commit)
  discards  06360a9cc6af1e97ab93d3e4df846661471795ee (commit)
  discards  146c23de22a86621ae3df48df3931ff583ec13c7 (commit)
  discards  295839dd2db778b3ed4ebe68698ee2c88fc58bf6 (commit)
  discards  42597c626b6a50c12ae1c536af7699833bcf405c (commit)
  discards  caafb116e6b59a94b57380a0fa94cb8d661b9b60 (commit)
  discards  d3aa36bc23f87e037dd15cd2079ce455529ba08b (commit)
  discards  18664281b5239bd2ad4a71da9996ac0d954177c3 (commit)
  discards  fba82b589b0763593e6bb75d56bd7de657e93b23 (commit)
  discards  c7f93129734fb626289298553df2db1d7750fbe9 (commit)
  discards  5720e111bb16a99efda26e83fc2cc97bb890bfc6 (commit)
  discards  74488941a0ead3b187855c69f2643198380574ac (commit)
  discards  ed48d1632192d31b18c521df2d3361ea7bdedc0e (commit)
  discards  2f9549fe28ebfc1a2afb86e299e607e8ef39139b (commit)
  discards  601e6f52fee68b32ed30e5fc9a21d87a5fa2b041 (commit)
  discards  52c39ec0b2a607f93da2eb8ef91627154a079519 (commit)
  discards  e0e3ef9045db29818d54f5cd9477e07bd17721ed (commit)
  discards  2043ac58d38452c033d26579f0f17a301943f7f8 (commit)
       via  1163d87cec2348c2acb6ad06415ef0e61f4f4aa5 (commit)
       via  b6e163b3a938bce45068e9f2a10e426cda839e98 (commit)
       via  edbf6e3319e07b5e43f51269f2a11b22cbc65dd5 (commit)
       via  28b40ea4c398d6e7095baf1fc4f1beeff6045997 (commit)
       via  376481e607beb50e4f0593640f708d07f4cb4195 (commit)
       via  9f722af56bccd9c856cbd2dfc4408348c395d240 (commit)
       via  33976bedbdfbfc144da375e84c2f7cfcd5abb4b8 (commit)
       via  6868414a37859e8f455d7180bb243d89d8889120 (commit)
       via  772ba0012061d30809885e891dd022bb999115de (commit)
       via  9a9a177185ba7001908265435d00f0eb2ebfe3cf (commit)
       via  c260d1c1076b7376edf5e78a35387e490a6a7c1b (commit)
       via  d8122e3514d9882af265f540f7685c0e8b0134e9 (commit)
       via  55b9ec9fe370014dafe940eb31b2606ac3bbce98 (commit)
       via  b1f88d6b4edadd346881ab799412d3b77c964741 (commit)
       via  493ae1d2b38acb0253e698d847efed3b2c01000a (commit)
       via  cd35c0f4d29935cedbe55903abab49fda6376d90 (commit)
       via  60adeb1b551428ac5ae33365c80981db3c676cce (commit)
       via  0abc7a2bdbfb6c3e08c7d89dae7a50297c18ccd0 (commit)
       via  232cf858dc9952f123510778333b2e8ab2dc56f9 (commit)
       via  2ddc5b46e057658b157c26045d74d7d3bbc0c271 (commit)
       via  c5b4e875304c5faf3658e6de1e45d27e4284976c (commit)
       via  5e779115609a2353599ff1a8949b1f562075030f (commit)
       via  5a6ba404ea5b0b9966902369a19218194bb15b76 (commit)
       via  4284b1547b5e95baa1d4121fce9879cf055b8f72 (commit)
       via  071bf1d63dae39f38e3c59208d436c71ec22e534 (commit)
       via  fa5ef4de3adb10fbe3bfb7e758434b315fad9fea (commit)
       via  f2be34e2d2574ca696ad9dfc7122a24a0d582fb7 (commit)
       via  db1d5ba6b2833a2b4fdd360032e5090e9e575bff (commit)
       via  69342dcbbf2ae3793102b3e1450d337910a30e97 (commit)
       via  45e4ebaf10de18859d5b1160854b4b4f9fc7593e (commit)
       via  40228b361e712cd089fff53b7156e2dbfa5181b4 (commit)
       via  a4e3ade070c28d8a59db0413c62720b2f89d4b7c (commit)
       via  95a415b69583178c93bac6b1660e5f2077962200 (commit)
       via  f5603f3daefe89a252201aff5ac977e75309c080 (commit)
       via  dc4a73ac5c6cb797b92c8884d7266d7f4a7b506a (commit)
       via  0caafac6f41bfdb77efa9e2828c2bac9d7d93860 (commit)
       via  b888adba161204724ff72d0c18f78c63e9322a95 (commit)
       via  fe3883c5a86d66f9c29239b71226fae0f358ba08 (commit)
       via  88f77f91c9b0a13109802f2bb44a9d42c16f91ea (commit)
       via  2ee2dd5484d40040254d5ac82c3d07de5057abfe (commit)
       via  5810e2b26a920f0a8eb4ea29a3a8084ad04ebc91 (commit)
       via  8a710779dd2d0e55b9d03e3b6f07ee9ffef590b9 (commit)
       via  b86531d6abb565e5973706271b514c8b92e7629b (commit)
       via  8b50a13a31f4ef572b16144fe832bcd2fd08ece7 (commit)
       via  fcf3be2b715c1defb0e199ac01be903d301372a8 (commit)
       via  0a35c53f8ae0814dddc3a45fc48564945c314a2c (commit)
       via  943e0de82e5997ef54acb296fe71501e5617802a (commit)
      from  f26e60871e12e8ba7651cf88cb402200f8226d16 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 1163d87cec2348c2acb6ad06415ef0e61f4f4aa5
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 13:41:30 2013 -0600

    change scoped cleanups to stack cleanups
    
    This adds a generic feature to allow cleanups to be allocated on the
    stack.  A convenience macro is provided which uses alloca; so this
    should not be used in loops.
    
    This also converts linespec.c to use the new code.

commit b6e163b3a938bce45068e9f2a10e426cda839e98
Author: Tom Tromey <tromey@redhat.com>
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 edbf6e3319e07b5e43f51269f2a11b22cbc65dd5
Author: Tom Tromey <tromey@redhat.com>
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.
    
    	* 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.
    	* linux-tdep.c (linux_make_corefile_notes): 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 28b40ea4c398d6e7095baf1fc4f1beeff6045997
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri May 17 09:40:41 2013 -0600

    fix solib-som.c
    
    som_open_symbol_file_object was leaking a cleanup.
    
    	* solib-som.c (som_open_symbol_file_object): Call do_cleanups.

commit 376481e607beb50e4f0593640f708d07f4cb4195
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 16 14:43:34 2013 -0600

    fix init_cutu_and_read_dies

commit 9f722af56bccd9c856cbd2dfc4408348c395d240
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 16 14:42:15 2013 -0600

    fix dwarf_decode_line_header

commit 33976bedbdfbfc144da375e84c2f7cfcd5abb4b8
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Mar 4 11:20:36 2013 -0700

    add README.archer

commit 6868414a37859e8f455d7180bb243d89d8889120
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:44:54 2013 +0000

    maintenance_expand_symtabs leaks a cleanup
    
    It turns out that maintenance_expand_symtabs was missing a call to
    do_cleanups.  I found this using the cleanup checker.
    
    	* symmisc.c (maintenance_expand_symtabs): Call do_cleanups.

commit 772ba0012061d30809885e891dd022bb999115de
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:41:38 2013 +0000

    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 does not need to
    be exported any more.
    
    	* xml-support.c (gdb_xml_create_parser_and_cleanup): Rename from
    	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 old version.
    	(gdb_xml_parse_quick): Update.
    	(xml_process_xincludes): Update.
    	* xml-support.h (gdb_xml_create_parser_and_cleanup): Don't
    	declare.

commit 9a9a177185ba7001908265435d00f0eb2ebfe3cf
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:39:34 2013 +0000

    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 c260d1c1076b7376edf5e78a35387e490a6a7c1b
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:37:50 2013 +0000

    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 (adjust_pc_after_break): Introduce an outer null
    	cleanup.

commit d8122e3514d9882af265f540f7685c0e8b0134e9
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:37:12 2013 +0000

    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 (varobj_update_one): Add an outer null cleanup.

commit 55b9ec9fe370014dafe940eb31b2606ac3bbce98
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:36:29 2013 +0000

    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 b1f88d6b4edadd346881ab799412d3b77c964741
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:35:40 2013 +0000

    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 493ae1d2b38acb0253e698d847efed3b2c01000a
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:34:18 2013 +0000

    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 cd35c0f4d29935cedbe55903abab49fda6376d90
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:33:40 2013 +0000

    fix source.c
    
    find_and_open_source can leak a cleanup.
    
    	* source.c (find_and_open_source): Call do_cleanups.

commit 60adeb1b551428ac5ae33365c80981db3c676cce
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:31:48 2013 +0000

    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 0abc7a2bdbfb6c3e08c7d89dae7a50297c18ccd0
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:30:59 2013 +0000

    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 232cf858dc9952f123510778333b2e8ab2dc56f9
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:30:03 2013 +0000

    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 2ddc5b46e057658b157c26045d74d7d3bbc0c271
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 17:29:06 2013 +0000

    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.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                |  207 ++++++++++++++++++++++++++++++++++++++++++
 gdb/cleanups.c               |   80 ++++++-----------
 gdb/cleanups.h               |   64 +++++++++----
 gdb/contrib/cleanup_check.py |    2 +-
 gdb/linespec.c               |   91 ++++++++----------
 gdb/mips-linux-tdep.c        |  115 +++++++++++------------
 gdb/utils.c                  |    8 +-
 gdb/utils.h                  |    2 +
 gdb/windows-nat.c            |    2 +-
 gdb/xml-support.c            |   16 ++--
 10 files changed, 392 insertions(+), 195 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3921b17..7c134f6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,210 @@
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* symmisc.c (maintenance_expand_symtabs): Call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* xml-support.c (gdb_xml_create_parser_and_cleanup): Rename from
+	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 old version.
+	(gdb_xml_parse_quick): Update.
+	(xml_process_xincludes): Update.
+	* xml-support.h (gdb_xml_create_parser_and_cleanup): Don't
+	declare.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* 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.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* infrun.c (adjust_pc_after_break): Introduce an outer null
+	cleanup.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* mi/mi-cmd-var.c (varobj_update_one): Add an outer null cleanup.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* cli/cli-script.c (read_command_lines_1): Use a null cleanup
+	for 'old_chain'.  Do not check 'head' before processing
+	cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* mi/mi-cmd-stack.c (list_arg_or_local): Remove
+	"cleanup_tuple".
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* dbxread.c (dbx_read_symtab): Declare 'back_to' in a more
+	inner scope.  Unconditionally call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* source.c (find_and_open_source): Call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* linux-thread-db.c (thread_db_load_search): Unconditionally
+	call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* solib-aix.c (solib_aix_bfd_open): Don't use a null cleanup
+	for 'cleanup'; instead use a later one.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* 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.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Call
+	do_cleanups on all return paths.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* top.c (execute_command): Discard 'cleanup_if_error' cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* stabsread.c (read_struct_type): Call do_cleanups along
+	all return paths.
+
+2013-05-30  Maciej W. Rozycki  <macro@codesourcery.com>
+
+	* mips-linux-tdep.c: Adjust formatting throughout.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* mipsread.c (read_alphacoff_dynamic_symtab): Call do_cleanups
+	along all return paths.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* symfile.c (find_separate_debug_file): Call do_cleanups
+	along all return paths.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* symtab.c (search_symbols): Introduce a null cleanup for
+	'retval_chain'.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* python/py-value.c (valpy_binop): Call do_cleanups before
+	exiting loop.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* python/py-prettyprint.c (print_children): Remove extra
+	do_cleanups call.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* python/py-frame.c (frapy_read_var): Call do_cleanups along
+	all return paths.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* python/py-breakpoint.c (bppy_get_commands): Call do_cleanups
+	along all return paths.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* cli/cli-logging.c (set_logging_redirect): Unconditionally
+	call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* varobj.c (c_value_of_root): Call do_cleanups along all
+	return paths.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* tracepoint.c (trace_dump_command): Unconditionally call
+	do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* breakpoint.c (output_thread_groups, parse_cmd_to_aexpr): Call
+	do_cleanups earlier.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* machoread.c (macho_symfile_read): Assign first cleanup to
+	'back_to'.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* m32r-rom.c (m32r_load): Call do_cleanups at all returns.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* mi/mi-main.c (list_available_thread_groups): Call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* inf-ptrace.c (inf_ptrace_create_inferior): Unconditionally
+	call discard_cleanups.
+	(inf_ptrace_attach): Likewise.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* remote-mips.c (mips_exit_debug): Call do_cleanups on all
+	return paths.
+	(mips_initialize): Likewise.
+	(common_open): Call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* utils.c (internal_vproblem): Call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* linespec.c (find_linespec_symbols): Don't reassign to 'cleanup'.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* cli/cli-script.c (setup_user_args): Don't return after error.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* somread.c (som_symtab_read): Call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* printcmd.c (print_command_1): Unconditionally call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* cli/cli-cmds.c (cd_command, alias_command): Call do_cleanups.
+	* cli/cli-dump.c (restore_binary_file): Call do_cleanups.
+	* interps.c (interpreter_exec_cmd): Call do_cleanups.
+	* source.c (show_substitute_path_command): Call do_cleanups.
+	(unset_substitute_path_command, set_substitute_path_command):
+	Likewise.
+	* symfile.c (load_command): Call do_cleanups.
+
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+	* contrib/cleanup_check.py: New file.
+	* contrib/gcc-with-excheck: Add option parsing.
+
+2013-05-30  Joel Brobecker  <brobecker@adacore.com>
+
+	* windows-nat.c (windows_delete_thread): Add missing space
+	in cast expression.
+
 2013-05-30  Hafiz Abid Qadeer  <abidh@codesourcery.com>
 
 	* inferior.c (top level): Include tilde.h.
diff --git a/gdb/cleanups.c b/gdb/cleanups.c
index 0f44ae4..398e0fc 100644
--- a/gdb/cleanups.c
+++ b/gdb/cleanups.c
@@ -20,30 +20,6 @@
 #include "defs.h"
 #include "gdb_assert.h"
 
-/* The cleanup list records things that have to be undone
-   if an error happens (descriptors to be closed, memory to be freed, etc.)
-   Each link in the chain records a function to call and an
-   argument to give it.
-
-   Use make_cleanup to add an element to the cleanup chain.
-   Use do_cleanups to do all cleanup actions back to a given
-   point in the chain.  Use discard_cleanups to remove cleanups
-   from the chain back to a given point, not doing them.
-
-   If the argument is pointer to allocated memory, then you need
-   to additionally set the 'free_arg' member to a function that will
-   free that memory.  This function will be called both when the cleanup
-   is executed and when it's discarded.  */
-
-struct real_cleanup
-{
-  struct cleanup base;
-
-  void (*function) (void *);
-  void (*free_arg) (void *);
-  void *arg;
-};
-
 /* Used to mark the end of a cleanup chain.
    The value is chosen so that it:
    - is non-NULL so that make_cleanup never returns NULL,
@@ -54,7 +30,7 @@ struct real_cleanup
    This is const for a bit of extra robustness.
    It is initialized to coax gcc into putting it into .rodata.
    All fields are initialized to survive -Wextra.  */
-static const struct real_cleanup sentinel_cleanup = { { 0, 0, 0 }, 0, 0, 0 };
+static const struct cleanup sentinel_cleanup = { 0, 0, 0, 0, 0, 0 };
 
 /* Handy macro to use when referring to sentinel_cleanup.  */
 #define SENTINEL_CLEANUP ((struct cleanup *) &sentinel_cleanup)
@@ -80,15 +56,16 @@ static struct cleanup *
 make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
 		  void *arg,  void (*free_arg) (void *))
 {
-  struct real_cleanup *new = XNEW (struct real_cleanup);
+  struct cleanup *new
+    = (struct cleanup *) xmalloc (sizeof (struct cleanup));
   struct cleanup *old_chain = *pmy_chain;
 
-  new->base.next = *pmy_chain;
-  new->base.scoped = 0;
+  new->next = *pmy_chain;
+  new->stack = 0;
   new->function = function;
   new->free_arg = free_arg;
   new->arg = arg;
-  *pmy_chain = &new->base;
+  *pmy_chain = new;
 
   gdb_assert (old_chain != NULL);
   return old_chain;
@@ -153,17 +130,13 @@ do_my_cleanups (struct cleanup **pmy_chain,
   while ((ptr = *pmy_chain) != old_chain)
     {
       *pmy_chain = ptr->next;	/* Do this first in case of recursion.  */
-      if (ptr->scoped)
+      (*ptr->function) (ptr->arg);
+      if (ptr->free_arg)
+	(*ptr->free_arg) (ptr->arg);
+      if (ptr->stack)
 	ptr->cleaned_up = 1;
       else
-	{
-	  struct real_cleanup *rc = (struct real_cleanup *) ptr;
-
-	  (*rc->function) (rc->arg);
-	  if (rc->free_arg)
-	    (*rc->free_arg) (rc->arg);
-	  xfree (ptr);
-	}
+	xfree (ptr);
     }
 }
 
@@ -208,16 +181,12 @@ discard_my_cleanups (struct cleanup **pmy_chain,
   while ((ptr = *pmy_chain) != old_chain)
     {
       *pmy_chain = ptr->next;
-      if (ptr->scoped)
+      if (ptr->free_arg)
+	(*ptr->free_arg) (ptr->arg);
+      if (ptr->stack)
 	ptr->cleaned_up = 1;
       else
-	{
-	  struct real_cleanup *rc = (struct real_cleanup *) ptr;
-
-	  if (rc->free_arg)
-	    (*rc->free_arg) (rc->arg);
-	  xfree (ptr);
-	}
+	xfree (ptr);
     }
 }
 
@@ -314,15 +283,19 @@ null_cleanup (void *arg)
 /* Initialize a scoped cleanup.  */
 
 struct cleanup *
-init_scoped_cleanup (struct scoped_cleanup *cl)
+init_stack_cleanup (struct cleanup *cl, make_cleanup_ftype *func,
+		    void *datum, make_cleanup_dtor_ftype *dtor)
 {
   struct cleanup *old_chain = cleanup_chain;
 
-  cl->base.next = cleanup_chain;
-  cleanup_chain = &cl->base;
+  cl->next = cleanup_chain;
+  cleanup_chain = cl;
 
-  cl->base.scoped = 1;
-  cl->base.cleaned_up = 0;
+  cl->function = func;
+  cl->free_arg = dtor;
+  cl->arg = datum;
+  cl->stack = 1;
+  cl->cleaned_up = 0;
 
   return old_chain;
 }
@@ -332,9 +305,10 @@ init_scoped_cleanup (struct scoped_cleanup *cl)
 /* Verify that a scoped cleanup was in fact handled.  */
 
 void
-cleanup_close_scope (struct scoped_cleanup *cl)
+cleanup_close_scope (struct cleanup *cl)
 {
-  if (!cl->base.cleaned_up)
+  gdb_assert (cl->stack);
+  if (!cl->cleaned_up)
     internal_warning (__FILE__, __LINE__, "scoped cleanup leaked");
 }
 
diff --git a/gdb/cleanups.h b/gdb/cleanups.h
index e16a9fa..3f49e80 100644
--- a/gdb/cleanups.h
+++ b/gdb/cleanups.h
@@ -45,6 +45,15 @@ extern struct cleanup *make_cleanup_dtor (make_cleanup_ftype *, void *,
 
 extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
 
+/* Allocate a cleanup on the stack, with alloca, and initialize
+   it.  Use like make_cleanup.  */
+
+#define make_stack_cleanup(FUNC, ARG) \
+  (init_stack_cleanup (alloca (sizeof (struct cleanup)), (FUNC), (ARG), NULL))
+
+#define make_stack_cleanup_dtor(FUNC, ARG, DTOR) \
+  (init_stack_cleanup (alloca (sizeof (struct cleanup)), (FUNC), (ARG), (DTOR)))
+
 /* A special value to pass to do_cleanups and do_final_cleanups
    to tell them to do all cleanups.  */
 extern struct cleanup *all_cleanups (void);
@@ -67,16 +76,33 @@ extern void restore_final_cleanups (struct cleanup *);
 extern void null_cleanup (void *);
 
 
-/* You should continue to treat this as opaque.  It is defined here
-   so that scoped cleanups can be stack-allocated and specially
-   treated.  */
+/* You should continue to treat this as opaque.  It is defined here so
+   that scoped cleanups can be stack-allocated and specially treated.
+
+   The cleanup list records things that have to be undone
+   if an error happens (descriptors to be closed, memory to be freed, etc.)
+   Each link in the chain records a function to call and an
+   argument to give it.
+
+   Use make_cleanup to add an element to the cleanup chain.
+   Use do_cleanups to do all cleanup actions back to a given
+   point in the chain.  Use discard_cleanups to remove cleanups
+   from the chain back to a given point, not doing them.
+
+   If the argument is pointer to allocated memory, then you need
+   to additionally set the 'free_arg' member to a function that will
+   free that memory.  This function will be called both when the cleanup
+   is executed and when it's discarded.  */
 
 struct cleanup
 {
+  void (*function) (void *);
+  void (*free_arg) (void *);
+  void *arg;
   struct cleanup *next;
 
-  /* True if this is a scoped cleanup.  */
-  unsigned scoped : 1;
+  /* True if this is a stack-allocated cleanup.  */
+  unsigned stack : 1;
 
   /* True if this is scoped cleanup has been cleaned up or discarded.
      Not used for ordinary cleanups.  */
@@ -84,15 +110,10 @@ struct cleanup
   unsigned cleaned_up : 1;
 };
 
-/* This is used for scoped cleanups.  It should be treated as
-   opaque.  */
-
-struct scoped_cleanup
-{
-  struct cleanup base;
-};
-
-extern struct cleanup *init_scoped_cleanup (struct scoped_cleanup *);
+extern struct cleanup *init_stack_cleanup (struct cleanup *,
+					   make_cleanup_ftype *,
+					   void *,
+					   make_cleanup_dtor_ftype *);
 
 #if defined (__GNUC__) && __GNUC__ >= 4
 
@@ -104,7 +125,7 @@ extern struct cleanup *init_scoped_cleanup (struct scoped_cleanup *);
 #define SCOPED_CLEANUP_ATTRIBUTE \
   __attribute__ ((cleanup (cleanup_close_scope)))
 
-extern void cleanup_close_scope (struct scoped_cleanup *);
+extern void cleanup_close_scope (struct cleanup *);
 
 #else
 
@@ -116,9 +137,14 @@ extern void cleanup_close_scope (struct scoped_cleanup *);
    cleaned up or discarded whenever the scope is exited.  When
    possible, this is checked at runtime.  */
 
-#define SCOPED_CLEANUP(name)						\
-  struct scoped_cleanup name ## __LINE__				\
-    SCOPED_CLEANUP_ATTRIBUTE;						\
-  struct cleanup *name = init_scoped_cleanup (& (name ## __LINE__))
+#define SCOPED_CLEANUP_DTOR(NAME, FUNC, DATA, DTOR)			\
+  struct cleanup NAME ## __LINE__ SCOPED_CLEANUP_ATTRIBUTE;		\
+  struct cleanup *NAME = init_stack_cleanup (& (NAME ## __LINE__),	\
+					     (FUNC), (DATA), (DTOR))
+
+#define SCOPED_CLEANUP(NAME, FUNC, DATA)				\
+  SCOPED_CLEANUP_DTOR(NAME, (FUNC), (DATA), NULL)
+
+#define SCOPED_NULL_CLEANUP(NAME) SCOPED_CLEANUP (NAME, null_cleanup, NULL)
 
 #endif /* CLEANUPS_H */
diff --git a/gdb/contrib/cleanup_check.py b/gdb/contrib/cleanup_check.py
index 8c6fd74..a93af4c 100644
--- a/gdb/contrib/cleanup_check.py
+++ b/gdb/contrib/cleanup_check.py
@@ -54,7 +54,7 @@ special_names = set(['do_final_cleanups', 'discard_final_cleanups',
                      'restore_cleanups', 'restore_final_cleanups',
                      'exceptions_state_mc_init',
                      'make_my_cleanup2', 'make_final_cleanup', 'all_cleanups',
-                     'save_my_cleanups', 'quit_target', 'init_scoped_cleanup'])
+                     'save_my_cleanups', 'quit_target', 'init_stack_cleanup'])
 
 def needs_special_treatment(decl):
     return decl.name in special_names
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 0714cc3..2b58618 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1267,11 +1267,11 @@ filter_results (struct linespec_state *self,
 	{
 	  const struct linespec_canonical_name *canonical;
 	  char *fullform;
-	  struct cleanup *cleanup;
+	  SCOPED_NULL_CLEANUP (cleanup);
 
 	  canonical = &self->canonical_names[j];
 	  fullform = canonical_to_fullform (canonical);
-	  cleanup = make_cleanup (xfree, fullform);
+	  make_cleanup (xfree, fullform);
 
 	  if (strcmp (name, fullform) == 0)
 	    add_sal_to_sals_basic (&lsal.sals, &result->sals[j]);


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-30 19:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30 19:47 [SCM] tromey/cleanup-checker: change scoped cleanups to stack cleanups tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).