public inbox for archer-commits@sourceware.org help / color / mirror / Atom feed
From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/cleanup-checker: fix solib-som.c Date: Fri, 17 May 2013 16:22:00 -0000 [thread overview] Message-ID: <20130517162204.20063.qmail@sourceware.org> (raw) The branch, tromey/cleanup-checker has been updated discards b126c46b967e111bece3f8798f1fcc0f550bf692 (commit) discards 927f199f5b4c929e2e6af9f3fefcff1357c1a9b7 (commit) discards 499055a7be510a935a9e0aa0035cb113e300d221 (commit) discards 889ef3796e2432eb0ea30ccc81d7e7099987cdfc (commit) discards 1b1b855dc118d306eb6c4e55c8f34bc705e51fd9 (commit) discards 754ed97cedaa9d4fa4ba49b4483ce47258e71533 (commit) discards 40e6daa4eced95f1cb2d0c3d5bdafe82da0bcdff (commit) discards 197a244755f95dd4740ae50ce56c323cae77d85e (commit) discards d23377272def84730a2adbd4e5a284c67cf25838 (commit) via 5dff075c4c32032ec8e7f9be971fae85704a57b8 (commit) via d0cc19c575ceed4d38fa10533aaea29fea602e63 (commit) via 1d4ff4f4201e491cf8b229df0c66ca7abd4dfb2e (commit) via 1f4b2f9a2f4a8d1ac3de78a856923cebe51bdc76 (commit) via 34746973a5ba4e36723df5fde3cc26fd793a57a9 (commit) via c494ef293b56ea603bfa3afbc186b9dc8a59a7c2 (commit) via f20f49258f17af6caba82d6f0a3a50180835571f (commit) via 3c80a3520156141ba16416bb9073848c87387f28 (commit) via dfc6c5277fa3dacfe6c9b1f69b00c767d9b2e595 (commit) from b126c46b967e111bece3f8798f1fcc0f550bf692 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 5dff075c4c32032ec8e7f9be971fae85704a57b8 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 d0cc19c575ceed4d38fa10533aaea29fea602e63 Author: Tom Tromey <tromey@redhat.com> Date: Thu May 16 14:43:34 2013 -0600 fix init_cutu_and_read_dies commit 1d4ff4f4201e491cf8b229df0c66ca7abd4dfb2e Author: Tom Tromey <tromey@redhat.com> Date: Thu May 16 14:42:15 2013 -0600 fix dwarf_decode_line_header commit 1f4b2f9a2f4a8d1ac3de78a856923cebe51bdc76 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 34746973a5ba4e36723df5fde3cc26fd793a57a9 Author: Tom Tromey <tromey@redhat.com> 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 c494ef293b56ea603bfa3afbc186b9dc8a59a7c2 Author: Tom Tromey <tromey@redhat.com> 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 f20f49258f17af6caba82d6f0a3a50180835571f Author: Tom Tromey <tromey@redhat.com> 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 (adjust_pc_after_break): Introduce an outer null cleanup. commit 3c80a3520156141ba16416bb9073848c87387f28 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. * 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. * 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. more dangling cleanups commit dfc6c5277fa3dacfe6c9b1f69b00c767d9b2e595 Author: Tom Tromey <tromey@redhat.com> 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 (varobj_update_one): Add an outer null cleanup. ----------------------------------------------------------------------- Summary of changes: gdb/breakpoint.c | 15 ++++++++------- gdb/defs.h | 4 ++++ gdb/infrun.c | 11 +++++------ gdb/linux-tdep.c | 1 + gdb/mi/mi-cmd-var.c | 13 +++++++------ gdb/solib-som.c | 4 +++- 6 files changed, 28 insertions(+), 20 deletions(-) First 500 lines of diff: diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 47539f1..4c34a5c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -6370,15 +6370,16 @@ breakpoint_1 (char *args, int allflag, } } - bkpttbl_chain = make_cleanup (null_cleanup, NULL); if (opts.addressprint) - make_cleanup_ui_out_table_begin_end (uiout, 6, - nr_printable_breakpoints, - "BreakpointTable"); + bkpttbl_chain + = make_cleanup_ui_out_table_begin_end (uiout, 6, + nr_printable_breakpoints, + "BreakpointTable"); else - make_cleanup_ui_out_table_begin_end (uiout, 5, - nr_printable_breakpoints, - "BreakpointTable"); + bkpttbl_chain + = make_cleanup_ui_out_table_begin_end (uiout, 5, + nr_printable_breakpoints, + "BreakpointTable"); if (nr_printable_breakpoints > 0) annotate_breakpoints_headers (); diff --git a/gdb/defs.h b/gdb/defs.h index f82fc17..fbf6edc 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -98,6 +98,10 @@ #include "libiberty.h" #include "hashtab.h" +/* The cleanup checker (see contrib/cleanup_check.py) defines + WITH_ATTRIBUTE_DANGLING_CLEANUP. If this is defined then we can + use the 'dangling_cleanup' attribute to mark functions which are + known to leak a cleanup. */ #ifdef WITH_ATTRIBUTE_DANGLING_CLEANUP #define DANGLING_CLEANUP __attribute__((dangling_cleanup)) #else diff --git a/gdb/infrun.c b/gdb/infrun.c index 4e7091e..b768ffd 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -665,7 +665,7 @@ handle_vfork_child_exec_or_exit (int exec) if (inf->vfork_parent->pending_detach) { struct thread_info *tp; - struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); + struct cleanup *old_chain; struct program_space *pspace; struct address_space *aspace; @@ -677,12 +677,12 @@ handle_vfork_child_exec_or_exit (int exec) { /* If we're handling a child exit, then inferior_ptid points at the inferior's pid, not to a thread. */ - save_inferior_ptid (); + old_chain = save_inferior_ptid (); save_current_program_space (); save_current_inferior (); } else - save_current_space_and_thread (); + old_chain = save_current_space_and_thread (); /* We're letting loose of the parent. */ tp = any_live_thread_of_process (inf->vfork_parent->pid); @@ -2803,11 +2803,10 @@ fetch_inferior_event (void *client_data) /* If an error happens while handling the event, propagate GDB's knowledge of the executing state to the frontend/user running state. */ - ts_old_chain = make_cleanup (null_cleanup, NULL); if (!non_stop) - make_cleanup (finish_thread_state_cleanup, &minus_one_ptid); + ts_old_chain = make_cleanup (finish_thread_state_cleanup, &minus_one_ptid); else - make_cleanup (finish_thread_state_cleanup, &ecs->ptid); + ts_old_chain = make_cleanup (finish_thread_state_cleanup, &ecs->ptid); /* Get executed before make_cleanup_restore_current_thread above to apply still for the thread which has thrown the exception. */ diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index bfb6404..b98401d 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1362,6 +1362,7 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) /* Fills the "to_make_corefile_note" target vector. Builds the note section for a corefile, and returns it in a malloc buffer. */ +DANGLING_CLEANUP char * linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size, linux_collect_thread_registers_ftype collect) diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index c2e8b7a..a069346 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -441,12 +441,14 @@ mi_cmd_var_list_children (char *command, char **argv, int argc) if (from < to) { - struct cleanup *cleanup_children = make_cleanup (null_cleanup, NULL); + struct cleanup *cleanup_children; if (mi_version (uiout) == 1) - make_cleanup_ui_out_tuple_begin_end (uiout, "children"); + cleanup_children + = make_cleanup_ui_out_tuple_begin_end (uiout, "children"); else - make_cleanup_ui_out_list_begin_end (uiout, "children"); + cleanup_children + = make_cleanup_ui_out_list_begin_end (uiout, "children"); for (ix = from; ix < to && VEC_iterate (varobj_p, children, ix, child); ++ix) @@ -700,11 +702,10 @@ mi_cmd_var_update (char *command, char **argv, int argc) else print_values = PRINT_NO_VALUES; - cleanup = make_cleanup (null_cleanup, NULL); if (mi_version (uiout) <= 1) - make_cleanup_ui_out_tuple_begin_end (uiout, "changelist"); + cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist"); else - make_cleanup_ui_out_list_begin_end (uiout, "changelist"); + cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist"); /* Check if the parameter is a "*", which means that we want to update all variables. */ diff --git a/gdb/solib-som.c b/gdb/solib-som.c index f88b539..457e464 100644 --- a/gdb/solib-som.c +++ b/gdb/solib-som.c @@ -698,6 +698,7 @@ som_open_symbol_file_object (void *from_ttyp) int errcode; int from_tty = *(int *)from_ttyp; gdb_byte buf[4]; + struct cleanup *cleanup; if (symfile_objfile) if (!query (_("Attempt to reload symbols from process? "))) @@ -727,10 +728,11 @@ som_open_symbol_file_object (void *from_ttyp) return 0; } - make_cleanup (xfree, filename); + cleanup = make_cleanup (xfree, filename); /* Have a pathname: read the symbol file. */ symbol_file_add_main (filename, from_tty); + do_cleanups (cleanup); return 1; } hooks/post-receive -- Repository for Project Archer.
next reply other threads:[~2013-05-17 16:22 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-05-17 16:22 tromey [this message] 2013-06-18 19:50 tromey
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20130517162204.20063.qmail@sourceware.org \ --to=tromey@sourceware.org \ --cc=archer-commits@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).