diff --git a/gdb-cxx-performance-1of2.patch b/gdb-cxx-performance-1of2.patch new file mode 100644 index 0000000..90773ec --- /dev/null +++ b/gdb-cxx-performance-1of2.patch @@ -0,0 +1,209 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00034.html + +### src/gdb/ChangeLog 2013/06/05 20:43:53 1.15689 +### src/gdb/ChangeLog 2013/06/05 22:28:51 1.15690 +## -1,3 +1,14 @@ ++2013-06-05 Doug Evans ++ Keith Seitz ++ ++ PR 15519 ++ * cp-namespace.c (find_symbol_in_baseclass): Call ++ cp_lookup_symbol_in_namespace instead of cp_lookup_symbol_namespace. ++ Check result of call to lookup_symbol_static. ++ Call lookup_static_symbol_aux unconditionally. ++ Call check_typedef on base types before accessing them. ++ (cp_lookup_nested_symbol): Fix comment. ++ + 2013-06-05 Luis Machado + + * gnu-v3-abi.c (gnuv3_skip_trampoline): Handle thunk +--- src/gdb/cp-namespace.c 2013/05/30 17:29:06 1.67 ++++ src/gdb/cp-namespace.c 2013/06/05 22:28:51 1.68 +@@ -720,36 +720,40 @@ + for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i) + { + size_t len; ++ struct type *base_type = TYPE_BASECLASS (parent_type, i); + const char *base_name = TYPE_BASECLASS_NAME (parent_type, i); + + if (base_name == NULL) + continue; + + /* Search this particular base class. */ +- sym = cp_lookup_symbol_namespace (base_name, name, block, VAR_DOMAIN); ++ sym = cp_lookup_symbol_in_namespace (base_name, name, block, ++ VAR_DOMAIN, 0); + if (sym != NULL) + break; + ++ /* Now search all static file-level symbols. We have to do this for ++ things like typedefs in the class. First search in this symtab, ++ what we want is possibly there. */ + len = strlen (base_name) + 2 + strlen (name) + 1; + concatenated_name = xrealloc (concatenated_name, len); + xsnprintf (concatenated_name, len, "%s::%s", base_name, name); + sym = lookup_symbol_static (concatenated_name, block, VAR_DOMAIN); ++ if (sym != NULL) ++ break; + +- /* If there is currently no BLOCK, e.g., the inferior hasn't yet +- been started, then try searching all STATIC_BLOCK symbols in +- all objfiles. */ +- if (block == NULL) +- { +- sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN); +- if (sym != NULL) +- break; +- } ++ /* Nope. We now have to search all static blocks in all objfiles, ++ even if block != NULL, because there's no guarantees as to which ++ symtab the symbol we want is in. */ ++ sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN); ++ if (sym != NULL) ++ break; + + /* If this class has base classes, search them next. */ +- if (TYPE_N_BASECLASSES (TYPE_BASECLASS (parent_type, i)) > 0) ++ CHECK_TYPEDEF (base_type); ++ if (TYPE_N_BASECLASSES (base_type) > 0) + { +- sym = find_symbol_in_baseclass (TYPE_BASECLASS (parent_type, i), +- name, block); ++ sym = find_symbol_in_baseclass (base_type, name, block); + if (sym != NULL) + break; + } +@@ -797,8 +801,8 @@ + if (sym != NULL) + return sym; + +- /* Now search all static file-level symbols. Not strictly +- correct, but more useful than an error. We do not try to ++ /* Now search all static file-level symbols. We have to do this ++ for things like typedefs in the class. We do not try to + guess any imported namespace as even the fully specified + namespace search is already not C++ compliant and more + assumptions could make it too magic. */ +### src/gdb/testsuite/ChangeLog 2013/06/05 20:38:37 1.3685 +### src/gdb/testsuite/ChangeLog 2013/06/05 22:28:51 1.3686 +## -1,3 +1,11 @@ ++2013-06-05 Doug Evans ++ Keith Seitz ++ ++ * gdb.cp/derivation2.cc: New file. ++ * gdb.cp/derivation.cc (main): Call foo2. ++ * gdb.cp/derivation.exp: Add tests for typedefs in another ++ file, and when there's an active block. ++ + 2013-06-05 Luis Machado + + * gdb.cp/virtfunc.exp (make_one_vtable_result): Handle extra output +--- src/gdb/testsuite/gdb.cp/derivation2.cc ++++ src/gdb/testsuite/gdb.cp/derivation2.cc 2013-06-10 12:35:14.881272247 +0000 +@@ -0,0 +1,49 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ */ ++ ++/* A copy of some classes in derivation.cc so that we can test symbol lookup ++ in other CUs. */ ++ ++class A2 { ++public: ++ typedef int value_type; ++ value_type a; ++ ++ A2() ++ { ++ a=1; ++ } ++}; ++ ++class D2 : public A2 { ++public: ++ value_type d; ++ ++ D2() ++ { ++ d=7; ++ } ++}; ++ ++void ++foo2 () ++{ ++ D2 d2_instance; ++ d2_instance.a = 42; ++ d2_instance.d = 43; ++} +--- src/gdb/testsuite/gdb.cp/derivation.cc 2013/01/01 06:33:27 1.5 ++++ src/gdb/testsuite/gdb.cp/derivation.cc 2013/06/05 22:28:51 1.6 +@@ -16,6 +16,8 @@ + along with this program. If not, see . + */ + ++extern void foo2 (); /* from derivation2.cc */ ++ + namespace N { + typedef double value_type; + struct Base { typedef int value_type; }; +@@ -306,9 +308,7 @@ + N::Derived::value_type d = 1; + N::value_type n = 3.0; + dobj.doit (); ++ foo2 (); + return 0; + + } +- +- +- +--- src/gdb/testsuite/gdb.cp/derivation.exp 2013/01/01 06:33:27 1.24 ++++ src/gdb/testsuite/gdb.cp/derivation.exp 2013/06/05 22:28:51 1.25 +@@ -32,14 +32,15 @@ + + load_lib "cp-support.exp" + +-standard_testfile .cc ++standard_testfile derivation.cc derivation2.cc + +-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { ++if {[prepare_for_testing $testfile.exp $testfile \ ++ [list $srcfile $srcfile2] {debug c++}]} { + return -1 + } + + # Check inheritance of typedefs. +-foreach klass {"A" "D" "E" "F"} { ++foreach klass {"A" "D" "E" "F" "A2" "D2"} { + gdb_test "ptype ${klass}::value_type" "type = int" + gdb_test "whatis ${klass}::value_type" "type = int" + gdb_test "p (${klass}::value_type) 0" " = 0" +@@ -57,6 +58,13 @@ + continue + } + ++# Check inheritance of typedefs again, but this time with an active block. ++foreach klass {"A" "D" "A2" "D2"} { ++ gdb_test "ptype ${klass}::value_type" "type = int" ++ gdb_test "whatis ${klass}::value_type" "type = int" ++ gdb_test "p (${klass}::value_type) 0" " = 0" ++} ++ + gdb_test "up" ".*main.*" "up from marker1" + + # Print class types and values. diff --git a/gdb-cxx-performance-2of2.patch b/gdb-cxx-performance-2of2.patch new file mode 100644 index 0000000..205698d --- /dev/null +++ b/gdb-cxx-performance-2of2.patch @@ -0,0 +1,58 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00044.html + +### src/gdb/testsuite/ChangeLog 2013/06/06 19:00:13 1.3688 +### src/gdb/testsuite/ChangeLog 2013/06/06 19:02:26 1.3689 +## -1,3 +1,7 @@ ++2013-06-06 Doug Evans ++ ++ * gdb.cp/derivation.exp: Make tests have unique names. ++ + 2013-06-06 Tom Tromey + + * gdb.base/dump.exp (capture_value): Don't put expression into +--- src/gdb/testsuite/gdb.cp/derivation.exp 2013/06/05 22:28:51 1.25 ++++ src/gdb/testsuite/gdb.cp/derivation.exp 2013/06/06 19:02:27 1.26 +@@ -40,15 +40,17 @@ + } + + # Check inheritance of typedefs. +-foreach klass {"A" "D" "E" "F" "A2" "D2"} { +- gdb_test "ptype ${klass}::value_type" "type = int" +- gdb_test "whatis ${klass}::value_type" "type = int" +- gdb_test "p (${klass}::value_type) 0" " = 0" +-} +-foreach klass {"Z" "ZZ"} { +- gdb_test "ptype ${klass}::value_type" "type = float" +- gdb_test "whatis ${klass}::value_type" "type = float" +- gdb_test "p (${klass}::value_type) 0" " = 0" ++with_test_prefix "before run" { ++ foreach klass {"A" "D" "E" "F" "A2" "D2"} { ++ gdb_test "ptype ${klass}::value_type" "type = int" ++ gdb_test "whatis ${klass}::value_type" "type = int" ++ gdb_test "p (${klass}::value_type) 0" " = 0" ++ } ++ foreach klass {"Z" "ZZ"} { ++ gdb_test "ptype ${klass}::value_type" "type = float" ++ gdb_test "whatis ${klass}::value_type" "type = float" ++ gdb_test "p (${klass}::value_type) 0" " = 0" ++ } + } + + # Set it up at a breakpoint so we can play with the variable values. +@@ -59,10 +61,12 @@ + } + + # Check inheritance of typedefs again, but this time with an active block. +-foreach klass {"A" "D" "A2" "D2"} { +- gdb_test "ptype ${klass}::value_type" "type = int" +- gdb_test "whatis ${klass}::value_type" "type = int" +- gdb_test "p (${klass}::value_type) 0" " = 0" ++with_test_prefix "at marker1" { ++ foreach klass {"A" "D" "A2" "D2"} { ++ gdb_test "ptype ${klass}::value_type" "type = int" ++ gdb_test "whatis ${klass}::value_type" "type = int" ++ gdb_test "p (${klass}::value_type) 0" " = 0" ++ } + } + + gdb_test "up" ".*main.*" "up from marker1" diff --git a/gdb-dlopen-stap-probe-1of7.patch b/gdb-dlopen-stap-probe-1of7.patch deleted file mode 100644 index cb74802..0000000 --- a/gdb-dlopen-stap-probe-1of7.patch +++ /dev/null @@ -1,119 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2013-05/msg00625.html -Subject: [RFA 1/7] Probes API convenience patch - - ---uuKVzAmB+c+zQlhu -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline - -This patch exposes part of the probes API in a more convenient -way. I've included it for completeness, but it has previously -been approved: - - http://www.cygwin.com/ml/gdb-patches/2012-07/msg00340.html - ---uuKVzAmB+c+zQlhu -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="rtld-probes-1-convenience.patch" - -2013-05-16 Gary Benson - - * probe.h (get_probe_argument_count): New declaration. - (evaluate_probe_argument): Likewise. - * probe.c (get_probe_argument_count): New function. - (evaluate_probe_argument): Likewise. - (probe_safe_evaluate_at_pc): Use the above new functions. - -diff --git a/gdb/probe.h b/gdb/probe.h -index 8d44ca2..1d29b87 100644 ---- a/gdb/probe.h -+++ b/gdb/probe.h -@@ -214,6 +214,16 @@ extern void info_probes_for_ops (char *arg, int from_tty, - - extern struct cmd_list_element **info_probes_cmdlist_get (void); - -+/* Return the argument count of the specified probe. */ -+ -+extern unsigned get_probe_argument_count (struct probe *probe); -+ -+/* Evaluate argument N of the specified probe. N must be between 0 -+ inclusive and get_probe_argument_count exclusive. */ -+ -+extern struct value *evaluate_probe_argument (struct probe *probe, -+ unsigned n); -+ - /* A convenience function that finds a probe at the PC in FRAME and - evaluates argument N, with 0 <= N < number_of_args. If there is no - probe at that location, or if the probe does not have enough arguments, -diff --git a/gdb/probe.c b/gdb/probe.c -index 77f3b13..a61f4ea 100644 ---- a/gdb/probe.c -+++ b/gdb/probe.c -@@ -608,28 +608,55 @@ info_probes_command (char *arg, int from_tty) - - /* See comments in probe.h. */ - -+unsigned -+get_probe_argument_count (struct probe *probe) -+{ -+ const struct sym_probe_fns *probe_fns; -+ -+ gdb_assert (probe->objfile != NULL); -+ gdb_assert (probe->objfile->sf != NULL); -+ -+ probe_fns = probe->objfile->sf->sym_probe_fns; -+ -+ gdb_assert (probe_fns != NULL); -+ -+ return probe_fns->sym_get_probe_argument_count (probe); -+} -+ -+/* See comments in probe.h. */ -+ -+struct value * -+evaluate_probe_argument (struct probe *probe, unsigned n) -+{ -+ const struct sym_probe_fns *probe_fns; -+ -+ gdb_assert (probe->objfile != NULL); -+ gdb_assert (probe->objfile->sf != NULL); -+ -+ probe_fns = probe->objfile->sf->sym_probe_fns; -+ -+ gdb_assert (probe_fns != NULL); -+ -+ return probe_fns->sym_evaluate_probe_argument (probe, n); -+} -+ -+/* See comments in probe.h. */ -+ - struct value * - probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n) - { - struct probe *probe; -- const struct sym_probe_fns *probe_fns; - unsigned n_args; - - probe = find_probe_by_pc (get_frame_pc (frame)); - if (!probe) - return NULL; - -- gdb_assert (probe->objfile != NULL); -- gdb_assert (probe->objfile->sf != NULL); -- gdb_assert (probe->objfile->sf->sym_probe_fns != NULL); -- -- probe_fns = probe->objfile->sf->sym_probe_fns; -- n_args = probe_fns->sym_get_probe_argument_count (probe); -- -+ n_args = get_probe_argument_count (probe); - if (n >= n_args) - return NULL; - -- return probe_fns->sym_evaluate_probe_argument (probe, n); -+ return evaluate_probe_argument (probe, n); - } - - /* See comment in probe.h. */ - ---uuKVzAmB+c+zQlhu-- - diff --git a/gdb-dlopen-stap-probe-1of9.patch b/gdb-dlopen-stap-probe-1of9.patch new file mode 100644 index 0000000..2419dc9 --- /dev/null +++ b/gdb-dlopen-stap-probe-1of9.patch @@ -0,0 +1,102 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00012.html + +### src/gdb/ChangeLog 2013/06/04 02:44:34 1.15680 +### src/gdb/ChangeLog 2013/06/04 12:50:20 1.15681 +## -1,3 +1,11 @@ ++2013-06-04 Gary Benson ++ ++ * probe.h (get_probe_argument_count): New declaration. ++ (evaluate_probe_argument): Likewise. ++ * probe.c (get_probe_argument_count): New function. ++ (evaluate_probe_argument): Likewise. ++ (probe_safe_evaluate_at_pc): Use the above new functions. ++ + 2013-06-04 Alan Modra + + * ppc-tdep.h (ppc_insns_match_pattern): Update prototype. +--- src/gdb/probe.c 2013/05/30 17:39:34 1.8 ++++ src/gdb/probe.c 2013/06/04 12:50:20 1.9 +@@ -611,28 +611,55 @@ + + /* See comments in probe.h. */ + ++unsigned ++get_probe_argument_count (struct probe *probe) ++{ ++ const struct sym_probe_fns *probe_fns; ++ ++ gdb_assert (probe->objfile != NULL); ++ gdb_assert (probe->objfile->sf != NULL); ++ ++ probe_fns = probe->objfile->sf->sym_probe_fns; ++ ++ gdb_assert (probe_fns != NULL); ++ ++ return probe_fns->sym_get_probe_argument_count (probe); ++} ++ ++/* See comments in probe.h. */ ++ ++struct value * ++evaluate_probe_argument (struct probe *probe, unsigned n) ++{ ++ const struct sym_probe_fns *probe_fns; ++ ++ gdb_assert (probe->objfile != NULL); ++ gdb_assert (probe->objfile->sf != NULL); ++ ++ probe_fns = probe->objfile->sf->sym_probe_fns; ++ ++ gdb_assert (probe_fns != NULL); ++ ++ return probe_fns->sym_evaluate_probe_argument (probe, n); ++} ++ ++/* See comments in probe.h. */ ++ + struct value * + probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n) + { + struct probe *probe; +- const struct sym_probe_fns *probe_fns; + unsigned n_args; + + probe = find_probe_by_pc (get_frame_pc (frame)); + if (!probe) + return NULL; + +- gdb_assert (probe->objfile != NULL); +- gdb_assert (probe->objfile->sf != NULL); +- gdb_assert (probe->objfile->sf->sym_probe_fns != NULL); +- +- probe_fns = probe->objfile->sf->sym_probe_fns; +- n_args = probe_fns->sym_get_probe_argument_count (probe); +- ++ n_args = get_probe_argument_count (probe); + if (n >= n_args) + return NULL; + +- return probe_fns->sym_evaluate_probe_argument (probe, n); ++ return evaluate_probe_argument (probe, n); + } + + /* See comment in probe.h. */ +--- src/gdb/probe.h 2013/01/01 06:32:49 1.4 ++++ src/gdb/probe.h 2013/06/04 12:50:21 1.5 +@@ -214,6 +214,16 @@ + + extern struct cmd_list_element **info_probes_cmdlist_get (void); + ++/* Return the argument count of the specified probe. */ ++ ++extern unsigned get_probe_argument_count (struct probe *probe); ++ ++/* Evaluate argument N of the specified probe. N must be between 0 ++ inclusive and get_probe_argument_count exclusive. */ ++ ++extern struct value *evaluate_probe_argument (struct probe *probe, ++ unsigned n); ++ + /* A convenience function that finds a probe at the PC in FRAME and + evaluates argument N, with 0 <= N < number_of_args. If there is no + probe at that location, or if the probe does not have enough arguments, diff --git a/gdb-dlopen-stap-probe-2of7.patch b/gdb-dlopen-stap-probe-2of7.patch deleted file mode 100644 index 3606cec..0000000 --- a/gdb-dlopen-stap-probe-2of7.patch +++ /dev/null @@ -1,198 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2013-05/msg00627.html -Subject: [RFA 2/7] API for inhibiting section map updates - - ---bPg9NdpM9EETxvqt -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline - -This patch adds a couple of functions to allow section map updates -to be temporarily inhibited. Without this ability, the calls to -evaluate_probe_argument in svr4_handle_solib_event trigger a section -map update every time a group of shared objects are mapped, which -significantly affects performance. The updates are unnecessary in -this case as the sections in question are in the runtime linker and -so already in the section map. - ---bPg9NdpM9EETxvqt -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="rtld-probes-2-inhibit-sm-updates.patch" - -2013-05-16 Gary Benson - - * objfiles.h (inhibit_section_map_updates): New function - declaration. - (resume_section_map_updates): Likewise. - (resume_section_map_updates_cleanup): Likewise. - * objfiles.c (objfile_pspace_info): Removed field - "objfiles_changed_p". New fields "new_objfiles_available", - "section_map_dirty" and "inhibit_updates". - (allocate_objfile): Set new_objfiles_available. - (free_objfile): Set section_map_dirty. - (objfile_relocate1): Likewise. - (in_plt_section): Likewise. - (find_pc_section): Update the conditions under which the - section map will be updated. - (inhibit_section_map_updates): New function. - (resume_section_map_updates): Likewise. - (resume_section_map_updates_cleanup): Likewise. - -diff --git a/gdb/objfiles.h b/gdb/objfiles.h -index 93149e2..0b7eea9 100644 ---- a/gdb/objfiles.h -+++ b/gdb/objfiles.h -@@ -501,6 +501,22 @@ extern int in_plt_section (CORE_ADDR, char *); - modules. */ - DECLARE_REGISTRY(objfile); - -+/* In normal use, the section map will be rebuilt by FIND_PC_SECTION -+ if objfiles have been added, removed or relocated since it was last -+ called. Calling INHIBIT_SECTION_MAP_UPDATES will inhibit this -+ behavior until RESUME_SECTION_MAP_UPDATES is called. If you call -+ INHIBIT_SECTION_MAP_UPDATES you must ensure that every call to -+ FIND_PC_SECTION in the inhibited region relates to a section that -+ is already in the section map and has not since been removed or -+ relocated. */ -+extern void inhibit_section_map_updates (void); -+ -+/* Resume automatically rebuilding the section map as required. */ -+extern void resume_section_map_updates (void); -+ -+/* Version of the above suitable for use as a cleanup. */ -+extern void resume_section_map_updates_cleanup (void *arg); -+ - extern void default_iterate_over_objfiles_in_search_order - (struct gdbarch *gdbarch, - iterate_over_objfiles_in_search_order_cb_ftype *cb, -diff --git a/gdb/objfiles.c b/gdb/objfiles.c -index 3e49ea2..3af1064 100644 ---- a/gdb/objfiles.c -+++ b/gdb/objfiles.c -@@ -67,9 +67,18 @@ struct objfile *rt_common_objfile; /* For runtime common symbols */ - - struct objfile_pspace_info - { -- int objfiles_changed_p; - struct obj_section **sections; - int num_sections; -+ -+ /* Nonzero if object files have been added since the section map -+ was last updated. */ -+ int new_objfiles_available; -+ -+ /* Nonzero if the section map MUST be updated before use. */ -+ int section_map_dirty; -+ -+ /* Nonzero if section map updates should be inhibited if possible. */ -+ int inhibit_updates; - }; - - /* Per-program-space data key. */ -@@ -317,7 +326,7 @@ allocate_objfile (bfd *abfd, int flags) - objfile->flags |= flags; - - /* Rebuild section map next time we need it. */ -- get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1; -+ get_objfile_pspace_data (objfile->pspace)->new_objfiles_available = 1; - - return objfile; - } -@@ -646,7 +655,7 @@ free_objfile (struct objfile *objfile) - obstack_free (&objfile->objfile_obstack, 0); - - /* Rebuild section map next time we need it. */ -- get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1; -+ get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1; - - xfree (objfile); - } -@@ -826,7 +835,7 @@ objfile_relocate1 (struct objfile *objfile, - } - - /* Rebuild section map next time we need it. */ -- get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1; -+ get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1; - - /* Update the table in exec_ops, used to read memory. */ - ALL_OBJFILE_OSECTIONS (objfile, s) -@@ -1291,11 +1300,14 @@ static void - update_section_map (struct program_space *pspace, - struct obj_section ***pmap, int *pmap_size) - { -+ struct objfile_pspace_info *pspace_info; - int alloc_size, map_size, i; - struct obj_section *s, **map; - struct objfile *objfile; - -- gdb_assert (get_objfile_pspace_data (pspace)->objfiles_changed_p != 0); -+ pspace_info = get_objfile_pspace_data (current_program_space); -+ gdb_assert (pspace_info->section_map_dirty != 0 -+ || pspace_info->new_objfiles_available != 0); - - map = *pmap; - xfree (map); -@@ -1365,7 +1377,9 @@ find_pc_section (CORE_ADDR pc) - return s; - - pspace_info = get_objfile_pspace_data (current_program_space); -- if (pspace_info->objfiles_changed_p != 0) -+ if (pspace_info->section_map_dirty -+ || (pspace_info->new_objfiles_available -+ && !pspace_info->inhibit_updates)) - { - update_section_map (current_program_space, - &pspace_info->sections, -@@ -1373,7 +1387,8 @@ find_pc_section (CORE_ADDR pc) - - /* Don't need updates to section map until objfiles are added, - removed or relocated. */ -- pspace_info->objfiles_changed_p = 0; -+ pspace_info->new_objfiles_available = 0; -+ pspace_info->section_map_dirty = 0; - } - - /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to -@@ -1414,14 +1429,38 @@ in_plt_section (CORE_ADDR pc, char *name) - } - - --/* Set objfiles_changed_p so section map will be rebuilt next time it -+/* Set section_map_dirty so section map will be rebuilt next time it - is used. Called by reread_symbols. */ - - void - objfiles_changed (void) - { - /* Rebuild section map next time we need it. */ -- get_objfile_pspace_data (current_program_space)->objfiles_changed_p = 1; -+ get_objfile_pspace_data (current_program_space)->section_map_dirty = 1; -+} -+ -+/* See comments in objfiles.h. */ -+ -+void -+inhibit_section_map_updates (void) -+{ -+ get_objfile_pspace_data (current_program_space)->inhibit_updates = 1; -+} -+ -+/* See comments in objfiles.h. */ -+ -+void -+resume_section_map_updates (void) -+{ -+ get_objfile_pspace_data (current_program_space)->inhibit_updates = 0; -+} -+ -+/* See comments in objfiles.h. */ -+ -+void -+resume_section_map_updates_cleanup (void *arg) -+{ -+ resume_section_map_updates (); - } - - /* The default implementation for the "iterate_over_objfiles_in_search_order" - ---bPg9NdpM9EETxvqt-- - diff --git a/gdb-dlopen-stap-probe-2of9.patch b/gdb-dlopen-stap-probe-2of9.patch new file mode 100644 index 0000000..131a79a --- /dev/null +++ b/gdb-dlopen-stap-probe-2of9.patch @@ -0,0 +1,181 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00013.html + +### src/gdb/ChangeLog 2013/06/04 12:50:20 1.15681 +### src/gdb/ChangeLog 2013/06/04 12:53:33 1.15682 +## -1,5 +1,24 @@ + 2013-06-04 Gary Benson + ++ * objfiles.h (inhibit_section_map_updates): New function ++ declaration. ++ (resume_section_map_updates): Likewise. ++ (resume_section_map_updates_cleanup): Likewise. ++ * objfiles.c (objfile_pspace_info): Removed field ++ "objfiles_changed_p". New fields "new_objfiles_available", ++ "section_map_dirty" and "inhibit_updates". ++ (allocate_objfile): Set new_objfiles_available. ++ (free_objfile): Set section_map_dirty. ++ (objfile_relocate1): Likewise. ++ (in_plt_section): Likewise. ++ (find_pc_section): Update the conditions under which the ++ section map will be updated. ++ (inhibit_section_map_updates): New function. ++ (resume_section_map_updates): Likewise. ++ (resume_section_map_updates_cleanup): Likewise. ++ ++2013-06-04 Gary Benson ++ + * probe.h (get_probe_argument_count): New declaration. + (evaluate_probe_argument): Likewise. + * probe.c (get_probe_argument_count): New function. +--- src/gdb/objfiles.c 2013/05/06 19:15:17 1.160 ++++ src/gdb/objfiles.c 2013/06/04 12:53:34 1.161 +@@ -67,9 +67,18 @@ + + struct objfile_pspace_info + { +- int objfiles_changed_p; + struct obj_section **sections; + int num_sections; ++ ++ /* Nonzero if object files have been added since the section map ++ was last updated. */ ++ int new_objfiles_available; ++ ++ /* Nonzero if the section map MUST be updated before use. */ ++ int section_map_dirty; ++ ++ /* Nonzero if section map updates should be inhibited if possible. */ ++ int inhibit_updates; + }; + + /* Per-program-space data key. */ +@@ -317,7 +326,7 @@ + objfile->flags |= flags; + + /* Rebuild section map next time we need it. */ +- get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1; ++ get_objfile_pspace_data (objfile->pspace)->new_objfiles_available = 1; + + return objfile; + } +@@ -646,7 +655,7 @@ + obstack_free (&objfile->objfile_obstack, 0); + + /* Rebuild section map next time we need it. */ +- get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1; ++ get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1; + + xfree (objfile); + } +@@ -826,7 +835,7 @@ + } + + /* Rebuild section map next time we need it. */ +- get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1; ++ get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1; + + /* Update the table in exec_ops, used to read memory. */ + ALL_OBJFILE_OSECTIONS (objfile, s) +@@ -1291,11 +1300,14 @@ + update_section_map (struct program_space *pspace, + struct obj_section ***pmap, int *pmap_size) + { ++ struct objfile_pspace_info *pspace_info; + int alloc_size, map_size, i; + struct obj_section *s, **map; + struct objfile *objfile; + +- gdb_assert (get_objfile_pspace_data (pspace)->objfiles_changed_p != 0); ++ pspace_info = get_objfile_pspace_data (pspace); ++ gdb_assert (pspace_info->section_map_dirty != 0 ++ || pspace_info->new_objfiles_available != 0); + + map = *pmap; + xfree (map); +@@ -1365,7 +1377,9 @@ + return s; + + pspace_info = get_objfile_pspace_data (current_program_space); +- if (pspace_info->objfiles_changed_p != 0) ++ if (pspace_info->section_map_dirty ++ || (pspace_info->new_objfiles_available ++ && !pspace_info->inhibit_updates)) + { + update_section_map (current_program_space, + &pspace_info->sections, +@@ -1373,7 +1387,8 @@ + + /* Don't need updates to section map until objfiles are added, + removed or relocated. */ +- pspace_info->objfiles_changed_p = 0; ++ pspace_info->new_objfiles_available = 0; ++ pspace_info->section_map_dirty = 0; + } + + /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to +@@ -1414,14 +1429,38 @@ + } + + +-/* Set objfiles_changed_p so section map will be rebuilt next time it ++/* Set section_map_dirty so section map will be rebuilt next time it + is used. Called by reread_symbols. */ + + void + objfiles_changed (void) + { + /* Rebuild section map next time we need it. */ +- get_objfile_pspace_data (current_program_space)->objfiles_changed_p = 1; ++ get_objfile_pspace_data (current_program_space)->section_map_dirty = 1; ++} ++ ++/* See comments in objfiles.h. */ ++ ++void ++inhibit_section_map_updates (struct program_space *pspace) ++{ ++ get_objfile_pspace_data (pspace)->inhibit_updates = 1; ++} ++ ++/* See comments in objfiles.h. */ ++ ++void ++resume_section_map_updates (struct program_space *pspace) ++{ ++ get_objfile_pspace_data (pspace)->inhibit_updates = 0; ++} ++ ++/* See comments in objfiles.h. */ ++ ++void ++resume_section_map_updates_cleanup (void *arg) ++{ ++ resume_section_map_updates (arg); + } + + /* The default implementation for the "iterate_over_objfiles_in_search_order" +--- src/gdb/objfiles.h 2013/05/06 19:15:17 1.106 ++++ src/gdb/objfiles.h 2013/06/04 12:53:34 1.107 +@@ -501,6 +501,22 @@ + modules. */ + DECLARE_REGISTRY(objfile); + ++/* In normal use, the section map will be rebuilt by find_pc_section ++ if objfiles have been added, removed or relocated since it was last ++ called. Calling inhibit_section_map_updates will inhibit this ++ behavior until resume_section_map_updates is called. If you call ++ inhibit_section_map_updates you must ensure that every call to ++ find_pc_section in the inhibited region relates to a section that ++ is already in the section map and has not since been removed or ++ relocated. */ ++extern void inhibit_section_map_updates (struct program_space *pspace); ++ ++/* Resume automatically rebuilding the section map as required. */ ++extern void resume_section_map_updates (struct program_space *pspace); ++ ++/* Version of the above suitable for use as a cleanup. */ ++extern void resume_section_map_updates_cleanup (void *arg); ++ + extern void default_iterate_over_objfiles_in_search_order + (struct gdbarch *gdbarch, + iterate_over_objfiles_in_search_order_cb_ftype *cb, diff --git a/gdb-dlopen-stap-probe-3of7.patch b/gdb-dlopen-stap-probe-3of7.patch deleted file mode 100644 index 93251ca..0000000 --- a/gdb-dlopen-stap-probe-3of7.patch +++ /dev/null @@ -1,314 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2013-05/msg00626.html -Subject: [RFA 3/7] New gdbserver functionality - - ---Kc9HNjpzOXVc7FFU -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline - -This patch updates gdbserver to allow arguments to be passed in the -annex of qXfer:libraries-svr4:read to allow that function to transfer -partial lists of libraries. The ability of gdbserver to support -these arguments is indicated by a qSupported response containing -"augmented-libraries-svr4-read+". - ---Kc9HNjpzOXVc7FFU -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="rtld-probes-3-gdbserver.patch" - -2013-05-16 Gary Benson - - * server.c (handle_query): Add "augmented-libraries-svr4-read+" - to qSupported response when appropriate. - (handle_qxfer_libraries_svr4): Allow qXfer:libraries-svr4:read - with nonzero-length annex. - * linux-low.c (linux_qxfer_libraries_svr4): Parse and handle - arguments supplied in annex. - -diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c -index 6bb36d8..0a8f68b 100644 ---- a/gdb/gdbserver/server.c -+++ b/gdb/gdbserver/server.c -@@ -1115,8 +1115,7 @@ handle_qxfer_libraries_svr4 (const char *annex, - if (writebuf != NULL) - return -2; - -- if (annex[0] != '\0' || !target_running () -- || the_target->qxfer_libraries_svr4 == NULL) -+ if (!target_running () || the_target->qxfer_libraries_svr4 == NULL) - return -1; - - return the_target->qxfer_libraries_svr4 (annex, readbuf, writebuf, offset, len); -@@ -1743,7 +1742,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) - PBUFSIZ - 1); - - if (the_target->qxfer_libraries_svr4 != NULL) -- strcat (own_buf, ";qXfer:libraries-svr4:read+"); -+ strcat (own_buf, ";qXfer:libraries-svr4:read+" -+ ";augmented-libraries-svr4-read+"); - else - { - /* We do not have any hook to indicate whether the non-SVR4 target -diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c -index 72c51e0..beb3b8f 100644 ---- a/gdb/gdbserver/linux-low.c -+++ b/gdb/gdbserver/linux-low.c -@@ -5677,6 +5677,12 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, - }; - const struct link_map_offsets *lmo; - unsigned int machine; -+ int ptr_size; -+ CORE_ADDR lm_addr = 0, lm_prev = 0; -+ int allocated = 1024; -+ char *p; -+ CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev; -+ int header_done = 0; - - if (writebuf != NULL) - return -2; -@@ -5687,128 +5693,146 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, - xsnprintf (filename, sizeof filename, "/proc/%d/exe", pid); - is_elf64 = elf_64_file_p (filename, &machine); - lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets; -+ ptr_size = is_elf64 ? 8 : 4; - -- if (priv->r_debug == 0) -- priv->r_debug = get_r_debug (pid, is_elf64); -+ if (annex[0] == '\0') -+ { -+ int r_version = 0; - -- /* We failed to find DT_DEBUG. Such situation will not change for this -- inferior - do not retry it. Report it to GDB as E01, see for the reasons -- at the GDB solib-svr4.c side. */ -- if (priv->r_debug == (CORE_ADDR) -1) -- return -1; -+ if (priv->r_debug == 0) -+ priv->r_debug = get_r_debug (pid, is_elf64); - -- if (priv->r_debug == 0) -- { -- document = xstrdup ("\n"); -+ /* We failed to find DT_DEBUG. Such situation will not change -+ for this inferior - do not retry it. Report it to GDB as -+ E01, see for the reasons at the GDB solib-svr4.c side. */ -+ if (priv->r_debug == (CORE_ADDR) -1) -+ return -1; -+ -+ if (priv->r_debug != 0) -+ { -+ if (linux_read_memory (priv->r_debug + lmo->r_version_offset, -+ (unsigned char *) &r_version, -+ sizeof (r_version)) != 0 -+ || r_version != 1) -+ { -+ warning ("unexpected r_debug version %d", r_version); -+ } -+ else if (read_one_ptr (priv->r_debug + lmo->r_map_offset, -+ &lm_addr, ptr_size) != 0) -+ { -+ warning ("unable to read r_map from 0x%lx", -+ (long) priv->r_debug + lmo->r_map_offset); -+ } -+ } - } - else - { -- int allocated = 1024; -- char *p; -- const int ptr_size = is_elf64 ? 8 : 4; -- CORE_ADDR lm_addr, lm_prev, l_name, l_addr, l_ld, l_next, l_prev; -- int r_version, header_done = 0; -- -- document = xmalloc (allocated); -- strcpy (document, "r_debug + lmo->r_version_offset, -- (unsigned char *) &r_version, -- sizeof (r_version)) != 0 -- || r_version != 1) -+ while (annex[0] != '\0') - { -- warning ("unexpected r_debug version %d", r_version); -- goto done; -+ const char *sep; -+ CORE_ADDR *addrp; -+ int len; -+ -+ sep = strchr (annex, '='); -+ if (!sep) -+ break; -+ -+ len = sep - annex; -+ if (len == 5 && !strncmp (annex, "start", 5)) -+ addrp = &lm_addr; -+ else if (len == 4 && !strncmp (annex, "prev", 4)) -+ addrp = &lm_prev; -+ else -+ { -+ annex = strchr (sep, ';'); -+ if (!annex) -+ break; -+ annex++; -+ continue; -+ } -+ -+ annex = decode_address_to_semicolon (addrp, sep + 1); - } -+ } - -- if (read_one_ptr (priv->r_debug + lmo->r_map_offset, -- &lm_addr, ptr_size) != 0) -+ document = xmalloc (allocated); -+ strcpy (document, "l_name_offset, -+ &l_name, ptr_size) == 0 -+ && read_one_ptr (lm_addr + lmo->l_addr_offset, -+ &l_addr, ptr_size) == 0 -+ && read_one_ptr (lm_addr + lmo->l_ld_offset, -+ &l_ld, ptr_size) == 0 -+ && read_one_ptr (lm_addr + lmo->l_prev_offset, -+ &l_prev, ptr_size) == 0 -+ && read_one_ptr (lm_addr + lmo->l_next_offset, -+ &l_next, ptr_size) == 0) -+ { -+ unsigned char libname[PATH_MAX]; -+ -+ if (lm_prev != l_prev) - { -- warning ("unable to read r_map from 0x%lx", -- (long) priv->r_debug + lmo->r_map_offset); -- goto done; -+ warning ("Corrupted shared library list: 0x%lx != 0x%lx", -+ (long) lm_prev, (long) l_prev); -+ break; - } - -- lm_prev = 0; -- while (read_one_ptr (lm_addr + lmo->l_name_offset, -- &l_name, ptr_size) == 0 -- && read_one_ptr (lm_addr + lmo->l_addr_offset, -- &l_addr, ptr_size) == 0 -- && read_one_ptr (lm_addr + lmo->l_ld_offset, -- &l_ld, ptr_size) == 0 -- && read_one_ptr (lm_addr + lmo->l_prev_offset, -- &l_prev, ptr_size) == 0 -- && read_one_ptr (lm_addr + lmo->l_next_offset, -- &l_next, ptr_size) == 0) -+ /* Not checking for error because reading may stop before -+ we've got PATH_MAX worth of characters. */ -+ libname[0] = '\0'; -+ linux_read_memory (l_name, libname, sizeof (libname) - 1); -+ libname[sizeof (libname) - 1] = '\0'; -+ if (libname[0] != '\0') - { -- unsigned char libname[PATH_MAX]; -+ /* 6x the size for xml_escape_text below. */ -+ size_t len = 6 * strlen ((char *) libname); -+ char *name; - -- if (lm_prev != l_prev) -+ if (!header_done) - { -- warning ("Corrupted shared library list: 0x%lx != 0x%lx", -- (long) lm_prev, (long) l_prev); -- break; -+ /* Terminate `", -- name, (unsigned long) lm_addr, -- (unsigned long) l_addr, (unsigned long) l_ld); -- free (name); -- } -- else if (lm_prev == 0) -- { -- sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); -- p = p + strlen (p); -+ document = xrealloc (document, 2 * allocated); -+ allocated *= 2; -+ p = document + document_len; - } - -- if (l_next == 0) -- break; -- -- lm_prev = lm_addr; -- lm_addr = l_next; -+ name = xml_escape_text ((char *) libname); -+ p += sprintf (p, "", -+ name, (unsigned long) lm_addr, -+ (unsigned long) l_addr, (unsigned long) l_ld); -+ free (name); - } -- done: -- if (!header_done) -+ else if (lm_prev == 0) - { -- /* Empty list; terminate `"); -+ sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); -+ p = p + strlen (p); - } -- else -- strcpy (p, ""); -+ -+ lm_prev = lm_addr; -+ lm_addr = l_next; - } - -+ if (!header_done) -+ { -+ /* Empty list; terminate `"); -+ } -+ else -+ strcpy (p, ""); -+ - document_len = strlen (document); - if (offset < document_len) - document_len -= offset; - ---Kc9HNjpzOXVc7FFU-- - diff --git a/gdb-dlopen-stap-probe-3of9.patch b/gdb-dlopen-stap-probe-3of9.patch new file mode 100644 index 0000000..951f4bd --- /dev/null +++ b/gdb-dlopen-stap-probe-3of9.patch @@ -0,0 +1,298 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00014.html + +### src/gdb/gdbserver/ChangeLog 2013/05/31 19:14:33 1.720 +### src/gdb/gdbserver/ChangeLog 2013/06/04 12:59:20 1.721 +## -1,3 +1,12 @@ ++2013-06-04 Gary Benson ++ ++ * server.c (handle_query): Add "augmented-libraries-svr4-read+" ++ to qSupported response when appropriate. ++ (handle_qxfer_libraries_svr4): Allow qXfer:libraries-svr4:read ++ with nonzero-length annex. ++ * linux-low.c (linux_qxfer_libraries_svr4): Parse and handle ++ arguments supplied in annex. ++ + 2013-05-31 Doug Evans + + * linux-x86-low.c (ps_get_thread_area): Properly extend address to +--- src/gdb/gdbserver/linux-low.c 2013/05/23 17:17:50 1.237 ++++ src/gdb/gdbserver/linux-low.c 2013/06/04 12:59:21 1.238 +@@ -5728,6 +5728,12 @@ + }; + const struct link_map_offsets *lmo; + unsigned int machine; ++ int ptr_size; ++ CORE_ADDR lm_addr = 0, lm_prev = 0; ++ int allocated = 1024; ++ char *p; ++ CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev; ++ int header_done = 0; + + if (writebuf != NULL) + return -2; +@@ -5738,128 +5744,144 @@ + xsnprintf (filename, sizeof filename, "/proc/%d/exe", pid); + is_elf64 = elf_64_file_p (filename, &machine); + lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets; ++ ptr_size = is_elf64 ? 8 : 4; + +- if (priv->r_debug == 0) +- priv->r_debug = get_r_debug (pid, is_elf64); +- +- /* We failed to find DT_DEBUG. Such situation will not change for this +- inferior - do not retry it. Report it to GDB as E01, see for the reasons +- at the GDB solib-svr4.c side. */ +- if (priv->r_debug == (CORE_ADDR) -1) +- return -1; +- +- if (priv->r_debug == 0) ++ while (annex[0] != '\0') + { +- document = xstrdup ("\n"); ++ const char *sep; ++ CORE_ADDR *addrp; ++ int len; ++ ++ sep = strchr (annex, '='); ++ if (sep == NULL) ++ break; ++ ++ len = sep - annex; ++ if (len == 5 && strncmp (annex, "start", 5) == 0) ++ addrp = &lm_addr; ++ else if (len == 4 && strncmp (annex, "prev", 4) == 0) ++ addrp = &lm_prev; ++ else ++ { ++ annex = strchr (sep, ';'); ++ if (annex == NULL) ++ break; ++ annex++; ++ continue; ++ } ++ ++ annex = decode_address_to_semicolon (addrp, sep + 1); + } +- else ++ ++ if (lm_addr == 0) + { +- int allocated = 1024; +- char *p; +- const int ptr_size = is_elf64 ? 8 : 4; +- CORE_ADDR lm_addr, lm_prev, l_name, l_addr, l_ld, l_next, l_prev; +- int r_version, header_done = 0; +- +- document = xmalloc (allocated); +- strcpy (document, "r_debug + lmo->r_version_offset, +- (unsigned char *) &r_version, +- sizeof (r_version)) != 0 +- || r_version != 1) ++ int r_version = 0; ++ ++ if (priv->r_debug == 0) ++ priv->r_debug = get_r_debug (pid, is_elf64); ++ ++ /* We failed to find DT_DEBUG. Such situation will not change ++ for this inferior - do not retry it. Report it to GDB as ++ E01, see for the reasons at the GDB solib-svr4.c side. */ ++ if (priv->r_debug == (CORE_ADDR) -1) ++ return -1; ++ ++ if (priv->r_debug != 0) + { +- warning ("unexpected r_debug version %d", r_version); +- goto done; ++ if (linux_read_memory (priv->r_debug + lmo->r_version_offset, ++ (unsigned char *) &r_version, ++ sizeof (r_version)) != 0 ++ || r_version != 1) ++ { ++ warning ("unexpected r_debug version %d", r_version); ++ } ++ else if (read_one_ptr (priv->r_debug + lmo->r_map_offset, ++ &lm_addr, ptr_size) != 0) ++ { ++ warning ("unable to read r_map from 0x%lx", ++ (long) priv->r_debug + lmo->r_map_offset); ++ } + } ++ } ++ ++ document = xmalloc (allocated); ++ strcpy (document, "l_name_offset, ++ &l_name, ptr_size) == 0 ++ && read_one_ptr (lm_addr + lmo->l_addr_offset, ++ &l_addr, ptr_size) == 0 ++ && read_one_ptr (lm_addr + lmo->l_ld_offset, ++ &l_ld, ptr_size) == 0 ++ && read_one_ptr (lm_addr + lmo->l_prev_offset, ++ &l_prev, ptr_size) == 0 ++ && read_one_ptr (lm_addr + lmo->l_next_offset, ++ &l_next, ptr_size) == 0) ++ { ++ unsigned char libname[PATH_MAX]; + +- if (read_one_ptr (priv->r_debug + lmo->r_map_offset, +- &lm_addr, ptr_size) != 0) ++ if (lm_prev != l_prev) + { +- warning ("unable to read r_map from 0x%lx", +- (long) priv->r_debug + lmo->r_map_offset); +- goto done; ++ warning ("Corrupted shared library list: 0x%lx != 0x%lx", ++ (long) lm_prev, (long) l_prev); ++ break; + } + +- lm_prev = 0; +- while (read_one_ptr (lm_addr + lmo->l_name_offset, +- &l_name, ptr_size) == 0 +- && read_one_ptr (lm_addr + lmo->l_addr_offset, +- &l_addr, ptr_size) == 0 +- && read_one_ptr (lm_addr + lmo->l_ld_offset, +- &l_ld, ptr_size) == 0 +- && read_one_ptr (lm_addr + lmo->l_prev_offset, +- &l_prev, ptr_size) == 0 +- && read_one_ptr (lm_addr + lmo->l_next_offset, +- &l_next, ptr_size) == 0) ++ /* Not checking for error because reading may stop before ++ we've got PATH_MAX worth of characters. */ ++ libname[0] = '\0'; ++ linux_read_memory (l_name, libname, sizeof (libname) - 1); ++ libname[sizeof (libname) - 1] = '\0'; ++ if (libname[0] != '\0') + { +- unsigned char libname[PATH_MAX]; ++ /* 6x the size for xml_escape_text below. */ ++ size_t len = 6 * strlen ((char *) libname); ++ char *name; + +- if (lm_prev != l_prev) ++ if (!header_done) + { +- warning ("Corrupted shared library list: 0x%lx != 0x%lx", +- (long) lm_prev, (long) l_prev); +- break; ++ /* Terminate `", +- name, (unsigned long) lm_addr, +- (unsigned long) l_addr, (unsigned long) l_ld); +- free (name); +- } +- else if (lm_prev == 0) +- { +- sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); +- p = p + strlen (p); +- } ++ /* Expand to guarantee sufficient storage. */ ++ uintptr_t document_len = p - document; + +- if (l_next == 0) +- break; ++ document = xrealloc (document, 2 * allocated); ++ allocated *= 2; ++ p = document + document_len; ++ } + +- lm_prev = lm_addr; +- lm_addr = l_next; ++ name = xml_escape_text ((char *) libname); ++ p += sprintf (p, "", ++ name, (unsigned long) lm_addr, ++ (unsigned long) l_addr, (unsigned long) l_ld); ++ free (name); + } +- done: +- if (!header_done) ++ else if (lm_prev == 0) + { +- /* Empty list; terminate `"); ++ sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); ++ p = p + strlen (p); + } +- else +- strcpy (p, ""); ++ ++ lm_prev = lm_addr; ++ lm_addr = l_next; + } + ++ if (!header_done) ++ { ++ /* Empty list; terminate `"); ++ } ++ else ++ strcpy (p, ""); ++ + document_len = strlen (document); + if (offset < document_len) + document_len -= offset; +--- src/gdb/gdbserver/server.c 2013/05/24 11:28:06 1.191 ++++ src/gdb/gdbserver/server.c 2013/06/04 12:59:21 1.192 +@@ -1115,8 +1115,7 @@ + if (writebuf != NULL) + return -2; + +- if (annex[0] != '\0' || !target_running () +- || the_target->qxfer_libraries_svr4 == NULL) ++ if (!target_running () || the_target->qxfer_libraries_svr4 == NULL) + return -1; + + return the_target->qxfer_libraries_svr4 (annex, readbuf, writebuf, offset, len); +@@ -1743,7 +1742,8 @@ + PBUFSIZ - 1); + + if (the_target->qxfer_libraries_svr4 != NULL) +- strcat (own_buf, ";qXfer:libraries-svr4:read+"); ++ strcat (own_buf, ";qXfer:libraries-svr4:read+" ++ ";augmented-libraries-svr4-read+"); + else + { + /* We do not have any hook to indicate whether the non-SVR4 target diff --git a/gdb-dlopen-stap-probe-4of7.patch b/gdb-dlopen-stap-probe-4of7.patch deleted file mode 100644 index 224c366..0000000 --- a/gdb-dlopen-stap-probe-4of7.patch +++ /dev/null @@ -1,146 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2013-05/msg00628.html -Subject: [RFA 4/7] GDB support for new gdbserver functionality - - ---CaPKgh3XHpq3rEUV -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline - -This patch adds client support for the new gdbserver functionality -provided by patch 3 of this series. - ---CaPKgh3XHpq3rEUV -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="rtld-probes-4-remote.patch" - -2013-05-16 Gary Benson - - * target.h (target_ops): New field - "to_augmented_libraries_svr4_read". - (target_augmented_libraries_svr4_read): New macro. - * target.c (update_current_target): Handle - to_augmented_libraries_svr4_read. - * remote.c (remote_state): New field - "augmented_libraries_svr4_read". - (remote_augmented_libraries_svr4_read_feature): New function. - (remote_protocol_features): Add entry for - "augmented-libraries-svr4-read". - (remote_augmented_libraries_svr4_read): New function. - (init_remote_ops): Initialize - remote_ops.to_augmented_libraries_svr4_read. - -diff --git a/gdb/target.h b/gdb/target.h -index e937d39..a8587e8 100644 ---- a/gdb/target.h -+++ b/gdb/target.h -@@ -941,6 +941,10 @@ struct target_ops - (inclusive) to function END (exclusive). */ - void (*to_call_history_range) (ULONGEST begin, ULONGEST end, int flags); - -+ /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a -+ non-empty annex. */ -+ int (*to_augmented_libraries_svr4_read) (void); -+ - int to_magic; - /* Need sub-structure for target machine related rather than comm related? - */ -@@ -1809,6 +1813,9 @@ extern char *target_fileio_read_stralloc (const char *filename); - #define target_can_use_agent() \ - (*current_target.to_can_use_agent) () - -+#define target_augmented_libraries_svr4_read() \ -+ (*current_target.to_augmented_libraries_svr4_read) () -+ - /* Command logging facility. */ - - #define target_log_command(p) \ -diff --git a/gdb/target.c b/gdb/target.c -index 8653dac..519b97f 100644 ---- a/gdb/target.c -+++ b/gdb/target.c -@@ -731,6 +731,7 @@ update_current_target (void) - INHERIT (to_traceframe_info, t); - INHERIT (to_use_agent, t); - INHERIT (to_can_use_agent, t); -+ INHERIT (to_augmented_libraries_svr4_read, t); - INHERIT (to_magic, t); - INHERIT (to_supports_evaluation_of_breakpoint_conditions, t); - INHERIT (to_can_run_breakpoint_commands, t); -@@ -975,6 +976,9 @@ update_current_target (void) - de_fault (to_can_use_agent, - (int (*) (void)) - return_zero); -+ de_fault (to_augmented_libraries_svr4_read, -+ (int (*) (void)) -+ return_zero); - de_fault (to_execution_direction, default_execution_direction); - - #undef de_fault -diff --git a/gdb/remote.c b/gdb/remote.c -index 51bf025..e1cf8a4 100644 ---- a/gdb/remote.c -+++ b/gdb/remote.c -@@ -343,6 +343,10 @@ struct remote_state - /* True if the stub can collect strings using tracenz bytecode. */ - int string_tracing; - -+ /* True if the stub supports qXfer:libraries-svr4:read with a -+ non-empty annex. */ -+ int augmented_libraries_svr4_read; -+ - /* Nonzero if the user has pressed Ctrl-C, but the target hasn't - responded to that. */ - int ctrlc_pending_p; -@@ -3931,6 +3935,16 @@ remote_string_tracing_feature (const struct protocol_feature *feature, - rs->string_tracing = (support == PACKET_ENABLE); - } - -+static void -+remote_augmented_libraries_svr4_read_feature -+ (const struct protocol_feature *feature, -+ enum packet_support support, const char *value) -+{ -+ struct remote_state *rs = get_remote_state (); -+ -+ rs->augmented_libraries_svr4_read = (support == PACKET_ENABLE); -+} -+ - static struct protocol_feature remote_protocol_features[] = { - { "PacketSize", PACKET_DISABLE, remote_packet_size, -1 }, - { "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet, -@@ -3941,6 +3955,8 @@ static struct protocol_feature remote_protocol_features[] = { - PACKET_qXfer_libraries }, - { "qXfer:libraries-svr4:read", PACKET_DISABLE, remote_supported_packet, - PACKET_qXfer_libraries_svr4 }, -+ { "augmented-libraries-svr4-read", PACKET_DISABLE, -+ remote_augmented_libraries_svr4_read_feature, -1 }, - { "qXfer:memory-map:read", PACKET_DISABLE, remote_supported_packet, - PACKET_qXfer_memory_map }, - { "qXfer:spu:read", PACKET_DISABLE, remote_supported_packet, -@@ -11343,6 +11359,14 @@ remote_read_btrace (struct btrace_target_info *tinfo, - return btrace; - } - -+static int -+remote_augmented_libraries_svr4_read (void) -+{ -+ struct remote_state *rs = get_remote_state (); -+ -+ return rs->augmented_libraries_svr4_read; -+} -+ - static void - init_remote_ops (void) - { -@@ -11465,6 +11489,8 @@ Specify the serial device it is connected to\n\ - remote_ops.to_disable_btrace = remote_disable_btrace; - remote_ops.to_teardown_btrace = remote_teardown_btrace; - remote_ops.to_read_btrace = remote_read_btrace; -+ remote_ops.to_augmented_libraries_svr4_read = -+ remote_augmented_libraries_svr4_read; - } - - /* Set up the extended remote vector by making a copy of the standard - ---CaPKgh3XHpq3rEUV-- - diff --git a/gdb-dlopen-stap-probe-4of9.patch b/gdb-dlopen-stap-probe-4of9.patch new file mode 100644 index 0000000..859c581 --- /dev/null +++ b/gdb-dlopen-stap-probe-4of9.patch @@ -0,0 +1,35 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00015.html + +### src/gdb/ChangeLog 2013/06/04 12:53:33 1.15682 +### src/gdb/ChangeLog 2013/06/04 13:02:15 1.15683 +## -1,5 +1,9 @@ + 2013-06-04 Gary Benson + ++ * NEWS: Update. ++ ++2013-06-04 Gary Benson ++ + * objfiles.h (inhibit_section_map_updates): New function + declaration. + (resume_section_map_updates): Likewise. +Index: gdb-7.6/gdb/NEWS +=================================================================== +--- gdb-7.6.orig/gdb/NEWS 2013-06-10 14:27:02.071184153 +0200 ++++ gdb-7.6/gdb/NEWS 2013-06-10 14:28:34.391145339 +0200 +@@ -4,6 +4,16 @@ + * Newly installed $prefix/bin/gcore acts as a shell interface for the + GDB command gcore. + ++* New remote packets ++ ++qXfer:libraries-svr4:read's annex ++ The previously unused annex of the qXfer:libraries-svr4:read packet ++ is now used to support passing an argument list. The remote stub ++ reports support for this argument list to GDB's qSupported query. ++ The defined arguments are "start" and "prev", used to reduce work ++ necessary for library list updating, resulting in significant ++ speedup. ++ + *** Changes in GDB 7.6 + + * Target record has been renamed to record-full. diff --git a/gdb-dlopen-stap-probe-5of7.patch b/gdb-dlopen-stap-probe-5of7.patch deleted file mode 100644 index 2ea873d..0000000 --- a/gdb-dlopen-stap-probe-5of7.patch +++ /dev/null @@ -1,1089 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2013-05/msg00632.html -Subject: [RFA 5/7] Improved linker-debugger interface - - ---qse+WBH4guesipZ+ -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline - -This patch implements the probes-based runtime linker interface. -It works as follows: - - - On inferior startup, GDB searches the dynamic linker for a - number of named probes. - - - If all probes are found, GDB sets a breakpoint on each one. - Otherwise, the standard function _dl_debug_state is used. - - - When using probes, a per-pspace list is maintained of all - libraries currently loaded by the inferior. It's updated - as necessary every time a solib event stop occurs. - - - When using probes, svr4_current_sos will return a copy of - the cached list. When not using probes the entire list - will be fetched from the inferior as before. - - - If any error occurs, GDB will print a warning and revert to - the standard interface. - ---qse+WBH4guesipZ+ -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="rtld-probes-5-main-changes.patch" - -2013-05-16 Gary Benson - - * breakpoint.h (handle_solib_event): Moved function declaration - to solib.h. - * breakpoint.c (handle_solib_event): Moved function to solib.c. - (bpstat_stop_status): Pass new argument to handle_solib_event. - * solib.h (update_solib_breakpoints): New function declaration. - (handle_solib_event): Moved function declaration from - breakpoint.h. - * solib.c (update_solib_breakpoints): New function. - (handle_solib_event): Moved function from breakpoint.c. - Updated to call solib_ops->handle_event if not NULL. - * solist.h (target_so_ops): New fields "update_breakpoints" and - "handle_event". - * infrun.c (set_stop_on_solib_events): New function. - (_initialize_infrun): Use the above for "set - stop-on-solib-events". - (handle_inferior_event): Pass new argument to handle_solib_event. - * solib-svr4.c (probe.h): New include. - (svr4_free_library_list): New forward declaration. - (probe_action): New enum. - (probe_info): New struct. - (probe_info): New static variable. - (NUM_PROBES): New definition. - (svr4_info): New fields "using_xfer", "probes_table" and - "solib_list". - (free_probes_table): New function. - (free_solib_list): New function. - (svr4_pspace_data_cleanup): Free probes table and solib list. - (svr4_copy_library_list): New function. - (svr4_current_sos_via_xfer_libraries): New parameter "annex". - (svr4_read_so_list): New parameter "prev_lm". - (svr4_current_sos_direct): Renamed from "svr4_current_sos". - (svr4_current_sos): New function. - (probe_and_action): New struct. - (hash_probe_and_action): New function. - (equal_probe_and_action): Likewise. - (register_solib_event_probe): Likewise. - (solib_event_probe_at): Likewise. - (solib_event_probe_action): Likewise. - (solist_update_full): Likewise. - (solist_update_incremental): Likewise. - (disable_probes_interface_cleanup): Likewise. - (svr4_handle_solib_event): Likewise. - (svr4_update_solib_event_breakpoint): Likewise. - (svr4_update_solib_event_breakpoints): Likewise. - (svr4_create_solib_event_breakpoints): Likewise. - (enable_break): Free probes table before creating breakpoints. - Use svr4_create_solib_event_breakpoints to create breakpoints. - (svr4_solib_create_inferior_hook): Free the solib list. - (_initialize_svr4_solib): Initialise - svr4_so_ops.handle_solib_event and svr4_so_ops.update_breakpoints. - -Index: gdb-7.6/gdb/breakpoint.h -=================================================================== ---- gdb-7.6.orig/gdb/breakpoint.h 2013-05-19 16:16:20.551087270 +0200 -+++ gdb-7.6/gdb/breakpoint.h 2013-05-19 16:16:20.837086948 +0200 -@@ -1552,8 +1552,6 @@ extern int user_breakpoint_p (struct bre - /* Attempt to determine architecture of location identified by SAL. */ - extern struct gdbarch *get_sal_arch (struct symtab_and_line sal); - --extern void handle_solib_event (void); -- - extern void breakpoint_free_objfile (struct objfile *objfile); - - extern void breakpoints_relocate (struct objfile *objfile, -Index: gdb-7.6/gdb/solib.h -=================================================================== ---- gdb-7.6.orig/gdb/solib.h 2013-01-01 07:32:51.000000000 +0100 -+++ gdb-7.6/gdb/solib.h 2013-05-19 16:16:20.838086946 +0200 -@@ -90,4 +90,12 @@ extern CORE_ADDR gdb_bfd_lookup_symbol_f - void *), - void *data); - -+/* Enable or disable optional solib event breakpoints as appropriate. */ -+ -+extern void update_solib_breakpoints (void); -+ -+/* Handle an solib event by calling solib_add. */ -+ -+extern void handle_solib_event (void); -+ - #endif /* SOLIB_H */ -Index: gdb-7.6/gdb/solib.c -=================================================================== ---- gdb-7.6.orig/gdb/solib.c 2013-05-19 16:16:20.468087363 +0200 -+++ gdb-7.6/gdb/solib.c 2013-05-19 16:16:20.838086946 +0200 -@@ -1221,6 +1221,38 @@ no_shared_libraries (char *ignored, int - objfile_purge_solibs (); - } - -+/* See solib.h. */ -+ -+void -+update_solib_breakpoints (void) -+{ -+ struct target_so_ops *ops = solib_ops (target_gdbarch ()); -+ -+ if (ops->update_breakpoints != NULL) -+ ops->update_breakpoints (); -+} -+ -+/* See solib.h. */ -+ -+void -+handle_solib_event (void) -+{ -+ struct target_so_ops *ops = solib_ops (target_gdbarch ()); -+ -+ if (ops->handle_event != NULL) -+ ops->handle_event (); -+ -+ clear_program_space_solib_cache (current_inferior ()->pspace); -+ -+ /* Check for any newly added shared libraries if we're supposed to -+ be adding them automatically. Switch terminal for any messages -+ produced by breakpoint_re_set. */ -+ target_terminal_ours_for_output (); -+ solib_add (NULL, 0, ¤t_target, auto_solib_add); -+ target_terminal_inferior (); -+} -+ -+ - /* Reload shared libraries, but avoid reloading the same symbol file - we already have loaded. */ - -Index: gdb-7.6/gdb/solist.h -=================================================================== ---- gdb-7.6.orig/gdb/solist.h 2013-01-01 07:32:51.000000000 +0100 -+++ gdb-7.6/gdb/solist.h 2013-05-19 16:16:20.838086946 +0200 -@@ -148,6 +148,19 @@ struct target_so_ops - core file (in particular, for readonly sections). */ - int (*keep_data_in_core) (CORE_ADDR vaddr, - unsigned long size); -+ -+ /* Enable or disable optional solib event breakpoints as -+ appropriate. This should be called whenever -+ stop_on_solib_events is changed. This pointer can be -+ NULL, in which case no enabling or disabling is necessary -+ for this target. */ -+ void (*update_breakpoints) (void); -+ -+ /* Target-specific processing of solib events that will be -+ performed before solib_add is called. This pointer can be -+ NULL, in which case no specific preprocessing is necessary -+ for this target. */ -+ void (*handle_event) (void); - }; - - /* Free the memory associated with a (so_list *). */ -Index: gdb-7.6/gdb/infrun.c -=================================================================== ---- gdb-7.6.orig/gdb/infrun.c 2013-05-19 16:16:20.508087318 +0200 -+++ gdb-7.6/gdb/infrun.c 2013-05-19 16:16:20.840086944 +0200 -@@ -370,6 +370,16 @@ static struct symbol *step_start_functio - /* Nonzero if we want to give control to the user when we're notified - of shared library events by the dynamic linker. */ - int stop_on_solib_events; -+ -+/* Enable or disable optional shared library event breakpoints -+ as appropriate when the above flag is changed. */ -+ -+static void -+set_stop_on_solib_events (char *args, int from_tty, struct cmd_list_element *c) -+{ -+ update_solib_breakpoints (); -+} -+ - static void - show_stop_on_solib_events (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) -@@ -7335,7 +7345,7 @@ Show stopping for shared library events. - If nonzero, gdb will give control to the user when the dynamic linker\n\ - notifies gdb of shared library events. The most common event of interest\n\ - to the user would be loading/unloading of a new library."), -- NULL, -+ set_stop_on_solib_events, - show_stop_on_solib_events, - &setlist, &showlist); - -Index: gdb-7.6/gdb/solib-svr4.c -=================================================================== ---- gdb-7.6.orig/gdb/solib-svr4.c 2013-05-19 16:16:20.468087363 +0200 -+++ gdb-7.6/gdb/solib-svr4.c 2013-05-19 16:21:40.285816084 +0200 -@@ -47,9 +47,12 @@ - #include "exceptions.h" - #include "gdb_bfd.h" - -+#include "probe.h" -+ - static struct link_map_offsets *svr4_fetch_link_map_offsets (void); - static int svr4_have_link_map_offsets (void); - static void svr4_relocate_main_executable (void); -+static void svr4_free_library_list (void *p_list); - - /* Link map info to include in an allocated so_list entry. */ - -@@ -106,6 +109,55 @@ static const char * const main_name_lis - NULL - }; - -+/* What to do when a probe stop occurs. */ -+ -+enum probe_action -+ { -+ /* Something went seriously wrong. Stop using probes and -+ revert to using the older interface. */ -+ PROBES_INTERFACE_FAILED, -+ -+ /* No action is required. The shared object list is still -+ valid. */ -+ DO_NOTHING, -+ -+ /* The shared object list should be reloaded entirely. */ -+ FULL_RELOAD, -+ -+ /* Attempt to incrementally update the shared object list. If -+ the update fails or is not possible, fall back to reloading -+ the list in full. */ -+ UPDATE_OR_RELOAD, -+ }; -+ -+/* A probe's name and its associated action. */ -+ -+struct probe_info -+{ -+ /* The name of the probe. */ -+ const char *name; -+ -+ /* What to do when a probe stop occurs. */ -+ enum probe_action action; -+}; -+ -+/* A list of named probes and their associated actions. If all -+ probes are present in the dynamic linker then the probes-based -+ interface will be used. */ -+ -+static const struct probe_info probe_info[] = -+{ -+ { "init_start", DO_NOTHING }, -+ { "init_complete", FULL_RELOAD }, -+ { "map_start", DO_NOTHING }, -+ { "map_failed", DO_NOTHING }, -+ { "reloc_complete", UPDATE_OR_RELOAD }, -+ { "unmap_start", DO_NOTHING }, -+ { "unmap_complete", FULL_RELOAD }, -+}; -+ -+#define NUM_PROBES ARRAY_SIZE (probe_info) -+ - /* Return non-zero if GDB_SO_NAME and INFERIOR_SO_NAME represent - the same shared library. */ - -@@ -313,17 +365,56 @@ struct svr4_info - CORE_ADDR interp_text_sect_high; - CORE_ADDR interp_plt_sect_low; - CORE_ADDR interp_plt_sect_high; -+ -+ /* Nonzero if the list of objects was last obtained from the target -+ via qXfer:libraries-svr4:read. */ -+ int using_xfer; -+ -+ /* Table mapping breakpoint addresses to probes and actions, used -+ by the probes-based interface. */ -+ htab_t probes_table; -+ -+ /* List of objects loaded into the inferior, used by the probes- -+ based interface. */ -+ struct so_list *solib_list; - }; - - /* Per-program-space data key. */ - static const struct program_space_data *solib_svr4_pspace_data; - -+/* Free the probes table. */ -+ -+static void -+free_probes_table (struct svr4_info *info) -+{ -+ if (info->probes_table == NULL) -+ return; -+ -+ htab_delete (info->probes_table); -+ info->probes_table = NULL; -+} -+ -+/* Free the solib list. */ -+ -+static void -+free_solib_list (struct svr4_info *info) -+{ -+ svr4_free_library_list (&info->solib_list); -+ info->solib_list = NULL; -+} -+ - static void - svr4_pspace_data_cleanup (struct program_space *pspace, void *arg) - { - struct svr4_info *info; - - info = program_space_data (pspace, solib_svr4_pspace_data); -+ if (info == NULL) -+ return; -+ -+ free_probes_table (info); -+ free_solib_list (info); -+ - xfree (info); - } - -@@ -982,6 +1073,36 @@ svr4_free_library_list (void *p_list) - } - } - -+/* Copy library list. */ -+ -+static struct so_list * -+svr4_copy_library_list (struct so_list *src) -+{ -+ struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); -+ struct so_list *dst = NULL; -+ struct so_list **link = &dst; -+ -+ while (src != NULL) -+ { -+ struct so_list *new; -+ -+ new = XZALLOC (struct so_list); -+ -+ memcpy (new, src, sizeof (struct so_list)); -+ -+ new->lm_info = xmalloc (lmo->link_map_size); -+ memcpy (new->lm_info, src->lm_info, lmo->link_map_size); -+ -+ new->next = NULL; -+ *link = new; -+ link = &new->next; -+ -+ src = src->next; -+ } -+ -+ return dst; -+} -+ - #ifdef HAVE_LIBEXPAT - - #include "xml-support.h" -@@ -1097,14 +1218,19 @@ svr4_parse_libraries (const char *docume - return 0; - } - --/* Attempt to get so_list from target via qXfer:libraries:read packet. -+/* Attempt to get so_list from target via qXfer:libraries-svr4:read packet. - - Return 0 if packet not supported, *SO_LIST_RETURN is not modified in such - case. Return 1 if *SO_LIST_RETURN contains the library list, it may be -- empty, caller is responsible for freeing all its entries. */ -+ empty, caller is responsible for freeing all its entries. -+ -+ Note that ANNEX must be NULL if the remote does not explicitly allow -+ qXfer:libraries-svr4:read packets with non-empty annexes. Support for -+ this can be checked using target_augmented_libraries_svr4_read (). */ - - static int --svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list) -+svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list, -+ const char *annex) - { - char *svr4_library_document; - int result; -@@ -1113,7 +1239,7 @@ svr4_current_sos_via_xfer_libraries (str - /* Fetch the list of shared libraries. */ - svr4_library_document = target_read_stralloc (¤t_target, - TARGET_OBJECT_LIBRARIES_SVR4, -- NULL); -+ annex); - if (svr4_library_document == NULL) - return 0; - -@@ -1127,7 +1253,8 @@ svr4_current_sos_via_xfer_libraries (str - #else - - static int --svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list) -+svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list, -+ const char *annex) - { - return 0; - } -@@ -1161,15 +1288,17 @@ svr4_default_sos (void) - return new; - } - --/* Read the whole inferior libraries chain starting at address LM. Add the -- entries to the tail referenced by LINK_PTR_PTR. Ignore the first entry if -- IGNORE_FIRST and set global MAIN_LM_ADDR according to it. */ -+/* Read the whole inferior libraries chain starting at address LM. -+ Expect the first entry in the chain's previous entry to be PREV_LM. -+ Add the entries to the tail referenced by LINK_PTR_PTR. Ignore the -+ first entry if IGNORE_FIRST and set global MAIN_LM_ADDR according -+ to it. Returns nonzero upon success. */ - --static void --svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr, -- int ignore_first) -+static int -+svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm, -+ struct so_list ***link_ptr_ptr, int ignore_first) - { -- CORE_ADDR prev_lm = 0, next_lm; -+ CORE_ADDR next_lm; - - for (; lm != 0; prev_lm = lm, lm = next_lm) - { -@@ -1185,7 +1314,7 @@ svr4_read_so_list (CORE_ADDR lm, struct - if (new->lm_info == NULL) - { - do_cleanups (old_chain); -- break; -+ return 0; - } - - next_lm = new->lm_info->l_next; -@@ -1196,7 +1325,7 @@ svr4_read_so_list (CORE_ADDR lm, struct - paddress (target_gdbarch (), prev_lm), - paddress (target_gdbarch (), new->lm_info->l_prev)); - do_cleanups (old_chain); -- break; -+ return 0; - } - - /* For SVR4 versions, the first entry in the link map is for the -@@ -1291,17 +1420,19 @@ svr4_read_so_list (CORE_ADDR lm, struct - **link_ptr_ptr = new; - *link_ptr_ptr = &new->next; - } -+ -+ return 1; - } - --/* Implement the "current_sos" target_so_ops method. */ -+/* Read the full list of currently loaded shared objects directly from -+ the inferior. */ - - static struct so_list * --svr4_current_sos (void) -+svr4_current_sos_direct (struct svr4_info *info) - { - CORE_ADDR lm; - struct so_list *head = NULL; - struct so_list **link_ptr = &head; -- struct svr4_info *info; - struct cleanup *back_to; - int ignore_first; - struct svr4_library_list library_list; -@@ -1314,19 +1445,16 @@ svr4_current_sos (void) - Unfortunately statically linked inferiors will also fall back through this - suboptimal code path. */ - -- if (svr4_current_sos_via_xfer_libraries (&library_list)) -+ info->using_xfer = svr4_current_sos_via_xfer_libraries (&library_list, -+ NULL); -+ if (info->using_xfer) - { - if (library_list.main_lm) -- { -- info = get_svr4_info (); -- info->main_lm_addr = library_list.main_lm; -- } -+ info->main_lm_addr = library_list.main_lm; - - return library_list.head ? library_list.head : svr4_default_sos (); - } - -- info = get_svr4_info (); -- - /* Always locate the debug struct, in case it has moved. */ - info->debug_base = 0; - locate_base (info); -@@ -1349,7 +1477,7 @@ svr4_current_sos (void) - `struct so_list' nodes. */ - lm = solib_svr4_r_map (info); - if (lm) -- svr4_read_so_list (lm, &link_ptr, ignore_first); -+ svr4_read_so_list (lm, 0, &link_ptr, ignore_first); - - /* On Solaris, the dynamic linker is not in the normal list of - shared objects, so make sure we pick it up too. Having -@@ -1357,7 +1485,7 @@ svr4_current_sos (void) - for skipping dynamic linker resolver code. */ - lm = solib_svr4_r_ldsomap (info); - if (lm) -- svr4_read_so_list (lm, &link_ptr, 0); -+ svr4_read_so_list (lm, 0, &link_ptr, 0); - - discard_cleanups (back_to); - -@@ -1367,6 +1495,22 @@ svr4_current_sos (void) - return head; - } - -+/* Implement the "current_sos" target_so_ops method. */ -+ -+static struct so_list * -+svr4_current_sos (void) -+{ -+ struct svr4_info *info = get_svr4_info (); -+ -+ /* If we are using the probes interface and the solib list has -+ been cached then we simply return that. */ -+ if (info->solib_list != NULL) -+ return svr4_copy_library_list (info->solib_list); -+ -+ /* Otherwise obtain the solib list directly from the inferior. */ -+ return svr4_current_sos_direct (info); -+} -+ - /* Get the address of the link_map for a given OBJFILE. */ - - CORE_ADDR -@@ -1449,6 +1593,434 @@ exec_entry_point (struct bfd *abfd, stru - return gdbarch_addr_bits_remove (target_gdbarch (), addr); - } - -+/* A probe and its associated action. */ -+ -+struct probe_and_action -+{ -+ /* The probe. */ -+ struct probe *probe; -+ -+ /* The action. */ -+ enum probe_action action; -+}; -+ -+/* Returns a hash code for the probe_and_action referenced by p. */ -+ -+static hashval_t -+hash_probe_and_action (const void *p) -+{ -+ const struct probe_and_action *pa = p; -+ -+ return (hashval_t) pa->probe->address; -+} -+ -+/* Returns non-zero if the probe_and_actions referenced by p1 and p2 -+ are equal. */ -+ -+static int -+equal_probe_and_action (const void *p1, const void *p2) -+{ -+ const struct probe_and_action *pa1 = p1; -+ const struct probe_and_action *pa2 = p2; -+ -+ return pa1->probe->address == pa2->probe->address; -+} -+ -+/* Register a solib event probe and its associated action in the -+ probes table. */ -+ -+static void -+register_solib_event_probe (struct probe *probe, enum probe_action action) -+{ -+ struct svr4_info *info = get_svr4_info (); -+ struct probe_and_action lookup, *pa; -+ void **slot; -+ -+ /* Create the probes table, if necessary. */ -+ if (info->probes_table == NULL) -+ { -+ info->probes_table = htab_create_alloc (1, hash_probe_and_action, -+ equal_probe_and_action, -+ xfree, xcalloc, xfree); -+ } -+ -+ lookup.probe = probe; -+ slot = htab_find_slot (info->probes_table, &lookup, INSERT); -+ gdb_assert (*slot == HTAB_EMPTY_ENTRY); -+ -+ pa = XCNEW (struct probe_and_action); -+ pa->probe = probe; -+ pa->action = action; -+ -+ *slot = pa; -+} -+ -+/* Get the solib event probe at the specified location, and the -+ action associated with it. Returns NULL if no solib event probe -+ was found. */ -+ -+static struct probe_and_action * -+solib_event_probe_at (struct svr4_info *info, CORE_ADDR address) -+{ -+ struct probe lookup_probe; -+ struct probe_and_action lookup; -+ void **slot; -+ -+ lookup_probe.address = address; -+ lookup.probe = &lookup_probe; -+ slot = htab_find_slot (info->probes_table, &lookup, NO_INSERT); -+ -+ if (slot == NULL) -+ return NULL; -+ -+ return (struct probe_and_action *) *slot; -+} -+ -+/* Decide what action to take when the specified solib event probe is -+ hit. */ -+ -+static enum probe_action -+solib_event_probe_action (struct probe_and_action *pa) -+{ -+ enum probe_action action; -+ unsigned probe_argc; -+ -+ action = pa->action; -+ if (action == DO_NOTHING || action == PROBES_INTERFACE_FAILED) -+ return action; -+ -+ gdb_assert (action == FULL_RELOAD || action == UPDATE_OR_RELOAD); -+ -+ /* Check that an appropriate number of arguments has been supplied. -+ We expect: -+ arg0: Lmid_t lmid (mandatory) -+ arg1: struct r_debug *debug_base (mandatory) -+ arg2: struct link_map *new (optional, for incremental updates) */ -+ probe_argc = get_probe_argument_count (pa->probe); -+ if (probe_argc == 2) -+ action = FULL_RELOAD; -+ else if (probe_argc < 2) -+ action = PROBES_INTERFACE_FAILED; -+ -+ return action; -+} -+ -+/* Populate the shared object list by reading the entire list of -+ shared objects from the inferior. Returns nonzero on success. */ -+ -+static int -+solist_update_full (struct svr4_info *info) -+{ -+ svr4_free_library_list (&info->solib_list); -+ info->solib_list = svr4_current_sos_direct (info); -+ -+ return 1; -+} -+ -+/* Update the shared object list starting from the link-map entry -+ passed by the linker in the probe's third argument. Returns -+ nonzero if the list was successfully updated, or zero to indicate -+ failure. */ -+ -+static int -+solist_update_incremental (struct svr4_info *info, CORE_ADDR lm) -+{ -+ struct so_list *tail; -+ CORE_ADDR prev_lm; -+ -+ /* Fall back to a full update if we haven't read anything yet. */ -+ if (info->solib_list == NULL) -+ return 0; -+ -+ /* Fall back to a full update if we are using a remote target -+ that does not support incremental transfers. */ -+ if (info->using_xfer && !target_augmented_libraries_svr4_read()) -+ return 0; -+ -+ /* Walk to the end of the list. */ -+ for (tail = info->solib_list; tail->next; tail = tail->next); -+ prev_lm = tail->lm_info->lm_addr; -+ -+ /* Read the new objects. */ -+ if (info->using_xfer) -+ { -+ struct svr4_library_list library_list; -+ char annex[64]; -+ -+ xsnprintf (annex, sizeof (annex), "start=%lx;prev=%lx", lm, prev_lm); -+ if (!svr4_current_sos_via_xfer_libraries (&library_list, annex)) -+ return 0; -+ -+ tail->next = library_list.head; -+ } -+ else -+ { -+ struct so_list **link = &tail->next; -+ -+ if (!svr4_read_so_list (lm, prev_lm, &link, 0)) -+ return 0; -+ } -+ -+ return 1; -+} -+ -+/* Disable the probes-based linker interface and revert to the -+ original interface. We don't reset the breakpoints as the -+ ones set up for the probes-based interface are adequate. */ -+ -+static void -+disable_probes_interface_cleanup (void *arg) -+{ -+ struct svr4_info *info = get_svr4_info (); -+ -+ warning (_("Probes-based dynamic linker interface failed.\n" -+ "Reverting to original interface.\n")); -+ -+ free_probes_table (info); -+ free_solib_list (info); -+} -+ -+/* Update the solib list as appropriate when using the -+ probes-based linker interface. Do nothing if using the -+ standard interface. */ -+ -+static void -+svr4_handle_solib_event (void) -+{ -+ struct svr4_info *info = get_svr4_info (); -+ struct probe_and_action *pa; -+ enum probe_action action; -+ struct cleanup *old_chain, *usm_chain; -+ struct value *val; -+ CORE_ADDR pc, debug_base, lm = 0; -+ int is_initial_ns; -+ -+ /* Do nothing if not using the probes interface. */ -+ if (info->probes_table == NULL) -+ return; -+ -+ /* If anything goes wrong we revert to the original linker -+ interface. */ -+ old_chain = make_cleanup (disable_probes_interface_cleanup, NULL); -+ -+ pc = regcache_read_pc (get_current_regcache ()); -+ pa = solib_event_probe_at (info, pc); -+ if (pa == NULL) -+ goto error; -+ -+ action = solib_event_probe_action (pa); -+ if (action == PROBES_INTERFACE_FAILED) -+ goto error; -+ -+ if (action == DO_NOTHING) -+ return; -+ -+ /* EVALUATE_PROBE_ARGUMENT looks up symbols in the dynamic linker -+ using FIND_PC_SECTION. FIND_PC_SECTION is accelerated by a cache -+ called the section map. The section map is invalidated every -+ time a shared library is loaded or unloaded, and if the inferior -+ is generating a lot of shared library events then the section map -+ will be updated every time SVR4_HANDLE_SOLIB_EVENT is called. -+ We called FIND_PC_SECTION in SVR4_CREATE_SOLIB_EVENT_BREAKPOINTS, -+ so we can guarantee that the dynamic linker's sections are in the -+ section map. We can therefore inhibit section map updates across -+ these calls to EVALUATE_PROBE_ARGUMENT and save a lot of time. */ -+ inhibit_section_map_updates (); -+ usm_chain = make_cleanup (resume_section_map_updates_cleanup, NULL); -+ -+ val = evaluate_probe_argument (pa->probe, 1); -+ if (val == NULL) -+ goto error; -+ -+ debug_base = value_as_address (val); -+ if (debug_base == 0) -+ goto error; -+ -+ /* Always locate the debug struct, in case it moved. */ -+ info->debug_base = 0; -+ if (locate_base (info) == 0) -+ goto error; -+ -+ /* Do not process namespaces other than the initial one. */ -+ if (debug_base != info->debug_base) -+ action = DO_NOTHING; -+ -+ if (action == UPDATE_OR_RELOAD) -+ { -+ val = evaluate_probe_argument (pa->probe, 2); -+ if (val != NULL) -+ lm = value_as_address (val); -+ -+ if (lm == 0) -+ action = FULL_RELOAD; -+ } -+ -+ /* Resume section map updates. */ -+ do_cleanups (usm_chain); -+ -+ if (action == UPDATE_OR_RELOAD) -+ { -+ if (!solist_update_incremental (info, lm)) -+ action = FULL_RELOAD; -+ } -+ -+ if (action == FULL_RELOAD) -+ { -+ if (!solist_update_full (info)) -+ goto error; -+ } -+ -+ discard_cleanups (old_chain); -+ return; -+ -+ error: -+ /* We should never reach here, but if we do we disable the -+ probes interface and revert to the original interface. */ -+ -+ do_cleanups (old_chain); -+} -+ -+/* Helper function for svr4_update_solib_event_breakpoints. */ -+ -+static int -+svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg) -+{ -+ struct svr4_info *info = get_svr4_info (); -+ struct bp_location *loc; -+ -+ if (b->type != bp_shlib_event) -+ return 0; /* Continue iterating. */ -+ -+ for (loc = b->loc; loc; loc = loc->next) -+ { -+ struct probe_and_action *pa = solib_event_probe_at (info, loc->address); -+ -+ if (pa != NULL) -+ { -+ if (pa->action == DO_NOTHING) -+ b->enable_state = (stop_on_solib_events -+ ? bp_enabled : bp_disabled); -+ -+ return 0; /* Continue iterating. */ -+ } -+ } -+ -+ return 0; /* Continue iterating. */ -+} -+ -+/* Enable or disable optional solib event breakpoints as appropriate. -+ Called whenever stop_on_solib_events is changed. */ -+ -+static void -+svr4_update_solib_event_breakpoints (void) -+{ -+ struct svr4_info *info = get_svr4_info (); -+ -+ if (info->probes_table) -+ iterate_over_breakpoints (svr4_update_solib_event_breakpoint, NULL); -+} -+ -+/* Create and register solib event breakpoints. */ -+ -+static void -+svr4_create_probe_breakpoints (struct gdbarch *gdbarch, -+ VEC (probe_p) **probes) -+{ -+ int i; -+ -+ for (i = 0; i < NUM_PROBES; i++) -+ { -+ enum probe_action action = probe_info[i].action; -+ struct probe *probe; -+ int ix; -+ -+ for (ix = 0; -+ VEC_iterate (probe_p, probes[i], ix, probe); -+ ++ix) -+ { -+ create_solib_event_breakpoint (gdbarch, probe->address); -+ register_solib_event_probe (probe, action); -+ } -+ } -+ -+ svr4_update_solib_event_breakpoints (); -+} -+ -+/* Both the SunOS and the SVR4 dynamic linkers call a marker function -+ before and after mapping and unmapping shared libraries. The sole -+ purpose of this method is to allow debuggers to set a breakpoint so -+ they can track these changes. -+ -+ Some versions of the glibc dynamic linker contain named probes -+ to allow more fine grained stopping. Given the address of the -+ original marker function, this function attempts to find these -+ probes, and if found, sets breakpoints on those instead. If the -+ probes aren't found, a single breakpoint is set on the original -+ marker function. */ -+ -+static void -+svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch, -+ CORE_ADDR address) -+{ -+ struct svr4_info *info = get_svr4_info (); -+ struct obj_section *os; -+ -+ os = find_pc_section (address); -+ if (os != NULL) -+ { -+ int with_prefix; -+ -+ for (with_prefix = 0; with_prefix <= 1; with_prefix++) -+ { -+ VEC (probe_p) *probes[NUM_PROBES]; -+ int all_probes_found = 1; -+ int i; -+ -+ memset (probes, 0, sizeof (probes)); -+ for (i = 0; i < NUM_PROBES; i++) -+ { -+ char name[32] = { '\0' }; -+ -+ /* Fedora 17, RHEL 6.2, and RHEL 6.3 shipped with an -+ early version of the probes code in which the probes' -+ names were prefixed with "rtld_" and the "map_failed" -+ probe did not exist. The locations of the probes are -+ otherwise the same, so we check for probes with -+ prefixed names if probes with unprefixed names are -+ not present. */ -+ -+ if (with_prefix) -+ strncat (name, "rtld_", sizeof (name) - strlen (name) - 1); -+ -+ strncat (name, probe_info[i].name, -+ sizeof (name) - strlen (name) - 1); -+ -+ probes[i] = find_probes_in_objfile (os->objfile, "rtld", name); -+ -+ if (!strcmp (name, "rtld_map_failed")) -+ continue; -+ -+ if (!VEC_length (probe_p, probes[i])) -+ { -+ all_probes_found = 0; -+ break; -+ } -+ } -+ -+ if (all_probes_found) -+ svr4_create_probe_breakpoints (gdbarch, probes); -+ -+ for (i = 0; i < NUM_PROBES; i++) -+ VEC_free (probe_p, probes[i]); -+ -+ if (all_probes_found) -+ return; -+ } -+ } -+ -+ create_solib_event_breakpoint (gdbarch, address); -+} -+ - /* Helper function for gdb_bfd_lookup_symbol. */ - - static int -@@ -1501,6 +2073,8 @@ enable_break (struct svr4_info *info, in - info->interp_text_sect_low = info->interp_text_sect_high = 0; - info->interp_plt_sect_low = info->interp_plt_sect_high = 0; - -+ free_probes_table (info); -+ - /* If we already have a shared library list in the target, and - r_debug contains r_brk, set the breakpoint there - this should - mean r_brk has already been relocated. Assume the dynamic linker -@@ -1532,7 +2106,7 @@ enable_break (struct svr4_info *info, in - That knowledge is encoded in the address, if it's Thumb the low bit - is 1. However, we've stripped that info above and it's not clear - what all the consequences are of passing a non-addr_bits_remove'd -- address to create_solib_event_breakpoint. The call to -+ address to svr4_create_solib_event_breakpoints. The call to - find_pc_section verifies we know about the address and have some - hope of computing the right kind of breakpoint to use (via - symbol info). It does mean that GDB needs to be pointed at a -@@ -1570,7 +2144,7 @@ enable_break (struct svr4_info *info, in - + bfd_section_size (tmp_bfd, interp_sect); - } - -- create_solib_event_breakpoint (target_gdbarch (), sym_addr); -+ svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr); - return 1; - } - } -@@ -1728,7 +2302,8 @@ enable_break (struct svr4_info *info, in - - if (sym_addr != 0) - { -- create_solib_event_breakpoint (target_gdbarch (), load_addr + sym_addr); -+ svr4_create_solib_event_breakpoints (target_gdbarch (), -+ load_addr + sym_addr); - xfree (interp_name); - return 1; - } -@@ -1754,7 +2329,7 @@ enable_break (struct svr4_info *info, in - sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), - sym_addr, - ¤t_target); -- create_solib_event_breakpoint (target_gdbarch (), sym_addr); -+ svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr); - return 1; - } - } -@@ -1770,7 +2345,7 @@ enable_break (struct svr4_info *info, in - sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), - sym_addr, - ¤t_target); -- create_solib_event_breakpoint (target_gdbarch (), sym_addr); -+ svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr); - return 1; - } - } -@@ -2266,6 +2841,9 @@ svr4_solib_create_inferior_hook (int fro - - info = get_svr4_info (); - -+ /* Free the probes-based interface's solib list. */ -+ free_solib_list (info); -+ - /* Relocate the main executable if necessary. */ - svr4_relocate_main_executable (); - -@@ -2507,4 +3085,6 @@ _initialize_svr4_solib (void) - svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol; - svr4_so_ops.same = svr4_same; - svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core; -+ svr4_so_ops.update_breakpoints = svr4_update_solib_event_breakpoints; -+ svr4_so_ops.handle_event = svr4_handle_solib_event; - } -Index: gdb-7.6/gdb/breakpoint.c -=================================================================== ---- gdb-7.6.orig/gdb/breakpoint.c 2013-05-19 16:16:20.606087208 +0200 -+++ gdb-7.6/gdb/breakpoint.c 2013-05-19 16:21:55.288805269 +0200 -@@ -5361,25 +5361,6 @@ handle_jit_event (void) - target_terminal_inferior (); - } - --/* Handle an solib event by calling solib_add. */ -- --void --handle_solib_event (void) --{ -- clear_program_space_solib_cache (current_inferior ()->pspace); -- -- /* Check for any newly added shared libraries if we're supposed to -- be adding them automatically. Switch terminal for any messages -- produced by breakpoint_re_set. */ -- target_terminal_ours_for_output (); --#ifdef SOLIB_ADD -- SOLIB_ADD (NULL, 0, ¤t_target, auto_solib_add); --#else -- solib_add (NULL, 0, ¤t_target, auto_solib_add); --#endif -- target_terminal_inferior (); --} -- - /* Prepare WHAT final decision for infrun. */ - - /* Decide what infrun needs to do with this bpstat. */ diff --git a/gdb-dlopen-stap-probe-5of9.patch b/gdb-dlopen-stap-probe-5of9.patch new file mode 100644 index 0000000..aab598f --- /dev/null +++ b/gdb-dlopen-stap-probe-5of9.patch @@ -0,0 +1,91 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00016.html + +### src/gdb/doc/ChangeLog 2013/05/24 04:50:26 1.1463 +### src/gdb/doc/ChangeLog 2013/06/04 13:07:45 1.1464 +## -1,3 +1,12 @@ ++2013-06-04 Gary Benson ++ ++ * gdb.texinfo (General Query Packets/qSupported): Added ++ "qXfer:libraries-svr4:read" and "augmented-libraries-svr4-read". ++ to the table of currently defined stub features. ++ Added a more detailed entry for "augmented-libraries-svr4-read". ++ (General Query Packets/qXfer:libraries-svr4:read): Documented ++ the augmented form of this packet. ++ + 2013-05-23 Joel Brobecker + + * gdb.texinfo (System-wide Configuration Scripts): Renames +--- src/gdb/doc/gdb.texinfo 2013/05/24 04:50:26 1.1093 ++++ src/gdb/doc/gdb.texinfo 2013/06/04 13:07:45 1.1094 +@@ -38594,6 +38594,16 @@ + @tab @samp{-} + @tab Yes + ++@item @samp{qXfer:libraries-svr4:read} ++@tab No ++@tab @samp{-} ++@tab Yes ++ ++@item @samp{augmented-libraries-svr4-read} ++@tab No ++@tab @samp{-} ++@tab No ++ + @item @samp{qXfer:memory-map:read} + @tab No + @tab @samp{-} +@@ -38770,6 +38780,11 @@ + The remote stub understands the @samp{qXfer:libraries-svr4:read} packet + (@pxref{qXfer svr4 library list read}). + ++@item augmented-libraries-svr4-read ++The remote stub understands the augmented form of the ++@samp{qXfer:libraries-svr4:read} packet ++(@pxref{qXfer svr4 library list read}). ++ + @item qXfer:memory-map:read + The remote stub understands the @samp{qXfer:memory-map:read} packet + (@pxref{qXfer memory map read}). +@@ -39065,7 +39080,10 @@ + @anchor{qXfer svr4 library list read} + Access the target's list of loaded libraries when the target is an SVR4 + platform. @xref{Library List Format for SVR4 Targets}. The annex part +-of the generic @samp{qXfer} packet must be empty (@pxref{qXfer read}). ++of the generic @samp{qXfer} packet must be empty unless the remote ++stub indicated it supports the augmented form of this packet ++by supplying an appropriate @samp{qSupported} response ++(@pxref{qXfer read}, @ref{qSupported}). + + This packet is optional for better performance on SVR4 targets. + @value{GDBN} uses memory read packets to read the SVR4 library list otherwise. +@@ -39073,6 +39091,30 @@ + This packet is not probed by default; the remote stub must request it, + by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}). + ++If the remote stub indicates it supports the augmented form of this ++packet then the annex part of the generic @samp{qXfer} packet may ++contain a semicolon-separated list of @samp{@var{name}=@var{value}} ++arguments. The currently supported arguments are: ++ ++@table @code ++@item start=@var{address} ++A hexadecimal number specifying the address of the @samp{struct ++link_map} to start reading the library list from. If unset or zero ++then the first @samp{struct link_map} in the library list will be ++chosen as the starting point. ++ ++@item prev=@var{address} ++A hexadecimal number specifying the address of the @samp{struct ++link_map} immediately preceding the @samp{struct link_map} ++specified by the @samp{start} argument. If unset or zero then ++the remote stub will expect that no @samp{struct link_map} ++exists prior to the starting point. ++ ++@end table ++ ++Arguments that are not understood by the remote stub will be silently ++ignored. ++ + @item qXfer:memory-map:read::@var{offset},@var{length} + @anchor{qXfer memory map read} + Access the target's @dfn{memory-map}. @xref{Memory Map Format}. The diff --git a/gdb-dlopen-stap-probe-6of7.patch b/gdb-dlopen-stap-probe-6of7.patch deleted file mode 100644 index 500ab34..0000000 --- a/gdb-dlopen-stap-probe-6of7.patch +++ /dev/null @@ -1,470 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2013-05/msg00631.html -Subject: [RFA 6/7] Linker-debugger interface tests by Jan - - ---IYV9cRr2u6rjcP4B -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline - -This patch updates the testsuite to cope with some changes resulting -from the probes-based interface, and adds a new test. This patch is -principally the work of Jan Kratochvil. - ---IYV9cRr2u6rjcP4B -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="rtld-probes-6-tests-jk.patch" - -2013-05-16 Jan Kratochvil - Gary Benson - - * lib/gdb.exp (build_executable_from_specs): Use gdb_compile_pthread, - gdb_compile_shlib or gdb_compile_shlib_pthreads where appropriate. - * lib/prelink-support.exp (build_executable_own_libs): Allow INTERP - to be set to "no" to indicate that no ld.so copy should be made. - * gdb.base/break-interp.exp (solib_bp): New constant. - (reach_1): Use the above instead of "_dl_debug_state". - (test_attach): Likewise. - (test_ld): Likewise. - * gdb.threads/dlopen-libpthread.exp: New file. - * gdb.threads/dlopen-libpthread.c: Likewise. - * gdb.threads/dlopen-libpthread-lib.c: Likewise. - * gdb.base/solib-corrupted.exp: Disable test if GDB is using probes. - -Index: gdb-7.6/gdb/testsuite/lib/gdb.exp -=================================================================== ---- gdb-7.6.orig/gdb/testsuite/lib/gdb.exp 2013-05-19 16:05:37.881840646 +0200 -+++ gdb-7.6/gdb/testsuite/lib/gdb.exp 2013-05-19 16:06:10.436822964 +0200 -@@ -4011,22 +4011,6 @@ proc build_executable_from_specs {testna - - set binfile [standard_output_file $executable] - -- set objects {} -- set i 0 -- foreach {s local_options} $args { -- if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } { -- untested $testname -- return -1 -- } -- lappend objects "${binfile}${i}.o" -- incr i -- } -- -- if { [gdb_compile $objects "${binfile}" executable $options] != "" } { -- untested $testname -- return -1 -- } -- - set info_options "" - if { [lsearch -exact $options "c++"] >= 0 } { - set info_options "c++" -@@ -4034,6 +4018,42 @@ proc build_executable_from_specs {testna - if [get_compiler_info ${info_options}] { - return -1 - } -+ -+ set binfile [standard_output_file $executable] -+ -+ set func gdb_compile -+ set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads)$}] -+ if {$func_index != -1} { -+ set func "${func}_[lindex $options $func_index]" -+ } -+ -+ # gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd -+ # parameter. They also requires $sources while gdb_compile and -+ # gdb_compile_pthreads require $objects. Moreover they ignore any options. -+ if [string match gdb_compile_shlib* $func] { -+ set sources_path {} -+ foreach {s local_options} $args { -+ lappend sources_path "${srcdir}/${subdir}/${s}" -+ } -+ set ret [$func $sources_path "${binfile}" $options] -+ } else { -+ set objects {} -+ set i 0 -+ foreach {s local_options} $args { -+ if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } { -+ untested $testname -+ return -1 -+ } -+ lappend objects "${binfile}${i}.o" -+ incr i -+ } -+ set ret [$func $objects "${binfile}" executable $options] -+ } -+ if { $ret != "" } { -+ untested $testname -+ return -1 -+ } -+ - return 0 - } - -Index: gdb-7.6/gdb/testsuite/lib/prelink-support.exp -=================================================================== ---- gdb-7.6.orig/gdb/testsuite/lib/prelink-support.exp 2013-05-19 16:05:37.881840646 +0200 -+++ gdb-7.6/gdb/testsuite/lib/prelink-support.exp 2013-05-19 16:05:39.100839980 +0200 -@@ -95,8 +95,9 @@ proc file_copy {src dest} { - # Wrap function build_executable so that the resulting executable is fully - # self-sufficient (without dependencies on system libraries). Parameter - # INTERP may be used to specify a loader (ld.so) to be used that is --# different from the default system one. Libraries on which the executable --# depends are copied into directory DIR. Default DIR value to -+# different from the default system one. INTERP can be set to "no" if no ld.so -+# copy should be made. Libraries on which the executable depends are copied -+# into directory DIR. Default DIR value to - # `${objdir}/${subdir}/${EXECUTABLE}.d'. - # - # In case of success, return a string containing the arguments to be used -@@ -151,8 +152,15 @@ proc build_executable_own_libs {testname - - if {$interp == ""} { - set interp_system [section_get $binfile .interp] -- set interp ${dir}/[file tail $interp_system] -- file_copy $interp_system $interp -+ if {$interp_system == ""} { -+ fail "$test could not find .interp" -+ } else { -+ set interp ${dir}/[file tail $interp_system] -+ file_copy $interp_system $interp -+ } -+ } -+ if {$interp == "no"} { -+ set interp "" - } - - set dests {} -@@ -164,13 +172,19 @@ proc build_executable_own_libs {testname - - # Do not lappend it so that "-rpath $dir" overrides any possible "-rpath"s - # specified by the caller to be able to link it for ldd" above. -- set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp,-rpath,$dir"] -+ set options [linsert $options 0 "ldflags=-Wl,-rpath,$dir"] -+ if {$interp != ""} { -+ set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp"] -+ } - - if {[build_executable $testname $executable $sources $options] == -1} { - return "" - } - -- set prelink_args "--dynamic-linker=$interp --ld-library-path=$dir $binfile $interp [concat $dests]" -+ set prelink_args "--ld-library-path=$dir $binfile [concat $dests]" -+ if {$interp != ""} { -+ set prelink_args "--dynamic-linker=$interp $prelink_args $interp" -+ } - return $prelink_args - } - -Index: gdb-7.6/gdb/testsuite/gdb.base/break-interp.exp -=================================================================== ---- gdb-7.6.orig/gdb/testsuite/gdb.base/break-interp.exp 2013-05-19 16:05:37.882840646 +0200 -+++ gdb-7.6/gdb/testsuite/gdb.base/break-interp.exp 2013-05-19 16:05:39.101839979 +0200 -@@ -109,12 +109,19 @@ proc strip_debug {dest} { - } - } - -+# The marker function for the standard runtime linker interface is -+# _dl_debug_state. The probes-based interface has no specific marker -+# function; the probe we will stop on (init_start) is in dl_main so we -+# check for that. -+ -+set solib_bp {(_dl_debug_state|dl_main)} -+ - # Implementation of reach. - - proc reach_1 {func command displacement} { -- global gdb_prompt expect_out -+ global gdb_prompt expect_out solib_bp - -- if {$func == "_dl_debug_state"} { -+ if {$func == $solib_bp} { - # Breakpoint on _dl_debug_state can have problems due to its overlap - # with the existing internal breakpoint from GDB. - gdb_test_no_output "set stop-on-solib-events 1" -@@ -142,21 +149,21 @@ proc reach_1 {func command displacement} - exp_continue - } - -re "Breakpoint \[0-9\]+, \\.?(__GI_)?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { -- if {$func == "_dl_debug_state"} { -+ if {$func == $solib_bp} { - fail $test - } else { - pass $test - } - } - -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?(__GI_)?$func \\(\\).*\r\n$gdb_prompt $" { -- if {$func == "_dl_debug_state"} { -+ if {$func == $solib_bp} { - fail $test - } else { - pass $test - } - } - -re "Stopped due to (spurious )?shared library event.*\r\n$gdb_prompt $" { -- if {$func == "_dl_debug_state"} { -+ if {$func == $solib_bp} { - if {$debug_state_count == 0} { - # First stop does not yet relocate the _start function - # descriptor on ppc64. -@@ -175,7 +182,7 @@ proc reach_1 {func command displacement} - fail $test_displacement - } - -- if {$func == "_dl_debug_state"} { -+ if {$func == $solib_bp} { - gdb_test_no_output "set stop-on-solib-events 0" - } - } -@@ -357,7 +364,7 @@ proc test_attach {file displacement {rel - } - - proc test_ld {file ifmain trynosym displacement} { -- global srcdir subdir gdb_prompt expect_out inferior_exited_re -+ global srcdir subdir gdb_prompt expect_out inferior_exited_re solib_bp - - # First test normal `file'-command loaded $FILE with symbols. - -@@ -385,9 +392,9 @@ proc test_ld {file ifmain trynosym displ - gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test" - } - -- reach "_dl_debug_state" "run" $displacement -+ reach $solib_bp "run" $displacement - -- gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?_dl_debug_state\\M.*" "dl bt" -+ gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt" - - if $ifmain { - reach "main" continue "NONE" -@@ -399,7 +406,7 @@ proc test_ld {file ifmain trynosym displ - - # Try re-run if the new PIE displacement takes effect. - gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y" -- reach "_dl_debug_state" "run" $displacement -+ reach $solib_bp "run" $displacement - - if $ifmain { - test_core $file $displacement -@@ -431,7 +438,7 @@ proc test_ld {file ifmain trynosym displ - gdb_test "exec-file $file" "exec-file $escapedfile" "load" - - if $ifmain { -- reach "_dl_debug_state" run $displacement -+ reach $solib_bp run $displacement - - # Use two separate gdb_test_multiple statements to avoid timeouts due - # to slow processing of wildcard capturing long output -Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.exp -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2013-05-19 16:05:39.101839979 +0200 -@@ -0,0 +1,74 @@ -+# Copyright 2011 Free Software Foundation, Inc. -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+if {![istarget *-linux*] || [skip_shlib_tests]} { -+ return 0 -+} -+ -+load_lib prelink-support.exp -+ -+set testfile "dlopen-libpthread" -+set srcmainfile ${testfile}.c -+set srclibfile ${testfile}-lib.c -+set executable ${testfile} -+set binfile_lib ${objdir}/${subdir}/${executable}.so -+set binfile ${objdir}/${subdir}/${executable} -+set lib_dlopen [shlib_target_file ${executable}.so] -+ -+# Use build_executable_own_libs as prelinked libpthread.so can produce false -+# PASS - it is OK if GDB processes it still before relocation. -+ -+set relink_args [build_executable_own_libs ${testfile}.exp ${executable}.so $srclibfile {debug shlib_pthreads} no] -+if {$relink_args == "" || ![prelink_no $relink_args] -+ || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug shlib_load}] } { -+ return -1 -+} -+gdb_load_shlibs $binfile_lib -+ -+if { ![runto_main] } { -+ return -1 -+} -+ -+set test "info probes all rtld rtld_map_complete" -+gdb_test_multiple $test $test { -+ -re "\[ \t\]rtld_map_complete\[ \t\]+0x\[0-9a-f\]+.*\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "No probes matched\\.\r\n$gdb_prompt $" { -+ xfail $test -+ untested ${testfile}.exp -+ return -+ } -+} -+ -+set test "libpthread.so not found" -+gdb_test_multiple "info sharedlibrary" $test { -+ -re "/libpthread\\.so.*\r\n$gdb_prompt $" { -+ fail $test -+ } -+ -re "/libc\\.so.*\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+gdb_test "set variable filename=\"$lib_dlopen\"" -+ -+gdb_breakpoint "notify" -+ -+# The error was: -+# Cannot find new threads: generic error -+gdb_continue_to_breakpoint "notify" ".* notify-here .*" -+ -+gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found" -Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2013-05-19 16:05:39.101839979 +0200 -@@ -0,0 +1,46 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2011 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+#include -+#include -+ -+static const char *volatile filename; -+ -+static void -+notify (void) -+{ -+ filename = NULL; /* notify-here */ -+} -+ -+int -+main (void) -+{ -+ void *h; -+ void (*fp) (void (*) (void)); -+ -+ assert (filename != NULL); -+ h = dlopen (filename, RTLD_LAZY); -+ assert (h != NULL); -+ -+ fp = dlsym (h, "f"); -+ assert (fp != NULL); -+ -+ fp (notify); -+ -+ return 0; -+} -Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2013-05-19 16:05:39.101839979 +0200 -@@ -0,0 +1,40 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2011 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+#include -+ -+static void * -+tfunc (void *arg) -+{ -+ void (*notifyp) (void) = arg; -+ -+ notifyp (); -+} -+ -+void -+f (void (*notifyp) (void)) -+{ -+ pthread_t t; -+ int i; -+ -+ i = pthread_create (&t, NULL, tfunc, notifyp); -+ assert (i == 0); -+ -+ i = pthread_join (t, NULL); -+ assert (i == 0); -+} -Index: gdb-7.6/gdb/testsuite/gdb.base/solib-corrupted.exp -=================================================================== ---- gdb-7.6.orig/gdb/testsuite/gdb.base/solib-corrupted.exp 2013-05-19 16:05:37.883840645 +0200 -+++ gdb-7.6/gdb/testsuite/gdb.base/solib-corrupted.exp 2013-05-19 16:05:39.102839978 +0200 -@@ -36,6 +36,33 @@ if ![runto_main] { - return - } - -+# With probes interface GDB no longer scans the inferior library list so its -+# corruption cannot be tested. There is no way to disable the probes -+# interface. -+ -+set probes { init_start init_complete map_start reloc_complete unmap_start -+ unmap_complete } -+set test "info probes" -+gdb_test_multiple $test $test { -+ -re "^rtld\[ \t\]+(?:rtld_)?(\[a-z_\]+)\[ \t\]" { -+ set idx [lsearch -exact $probes $expect_out(1,string)] -+ if { $idx >= 0 } { -+ set probes [lreplace $probes $idx $idx] -+ } -+ exp_continue -+ } -+ -re "^\[^\r\n\]*\r\n" { -+ exp_continue -+ } -+ -re "^$gdb_prompt $" { -+ } -+} -+if { [llength $probes] == 0 } { -+ xfail $test -+ untested "GDB is using probes" -+ return -+} -+ - gdb_test "info sharedlibrary" "From * To .*" "normal list" - - # GDB checks there for matching L_PREV. diff --git a/gdb-dlopen-stap-probe-6of9.patch b/gdb-dlopen-stap-probe-6of9.patch new file mode 100644 index 0000000..1a1c338 --- /dev/null +++ b/gdb-dlopen-stap-probe-6of9.patch @@ -0,0 +1,132 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00017.html + +### src/gdb/ChangeLog 2013/06/04 13:02:15 1.15683 +### src/gdb/ChangeLog 2013/06/04 13:10:53 1.15684 +## -1,5 +1,21 @@ + 2013-06-04 Gary Benson + ++ * target.h (target_ops): New field ++ "to_augmented_libraries_svr4_read". ++ (target_augmented_libraries_svr4_read): New macro. ++ * target.c (update_current_target): Handle ++ to_augmented_libraries_svr4_read. ++ * remote.c (remote_state): New field ++ "augmented_libraries_svr4_read". ++ (remote_augmented_libraries_svr4_read_feature): New function. ++ (remote_protocol_features): Add entry for ++ "augmented-libraries-svr4-read". ++ (remote_augmented_libraries_svr4_read): New function. ++ (init_remote_ops): Initialize ++ remote_ops.to_augmented_libraries_svr4_read. ++ ++2013-06-04 Gary Benson ++ + * NEWS: Update. + + 2013-06-04 Gary Benson +--- src/gdb/remote.c 2013/05/30 09:29:18 1.552 ++++ src/gdb/remote.c 2013/06/04 13:10:53 1.553 +@@ -361,6 +361,10 @@ + /* True if the stub can collect strings using tracenz bytecode. */ + int string_tracing; + ++ /* True if the stub supports qXfer:libraries-svr4:read with a ++ non-empty annex. */ ++ int augmented_libraries_svr4_read; ++ + /* Nonzero if the user has pressed Ctrl-C, but the target hasn't + responded to that. */ + int ctrlc_pending_p; +@@ -3949,6 +3953,16 @@ + rs->string_tracing = (support == PACKET_ENABLE); + } + ++static void ++remote_augmented_libraries_svr4_read_feature ++ (const struct protocol_feature *feature, ++ enum packet_support support, const char *value) ++{ ++ struct remote_state *rs = get_remote_state (); ++ ++ rs->augmented_libraries_svr4_read = (support == PACKET_ENABLE); ++} ++ + static struct protocol_feature remote_protocol_features[] = { + { "PacketSize", PACKET_DISABLE, remote_packet_size, -1 }, + { "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet, +@@ -3959,6 +3973,8 @@ + PACKET_qXfer_libraries }, + { "qXfer:libraries-svr4:read", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_libraries_svr4 }, ++ { "augmented-libraries-svr4-read", PACKET_DISABLE, ++ remote_augmented_libraries_svr4_read_feature, -1 }, + { "qXfer:memory-map:read", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_memory_map }, + { "qXfer:spu:read", PACKET_DISABLE, remote_supported_packet, +@@ -11439,6 +11455,14 @@ + return btrace; + } + ++static int ++remote_augmented_libraries_svr4_read (void) ++{ ++ struct remote_state *rs = get_remote_state (); ++ ++ return rs->augmented_libraries_svr4_read; ++} ++ + static void + init_remote_ops (void) + { +@@ -11561,6 +11585,8 @@ + remote_ops.to_disable_btrace = remote_disable_btrace; + remote_ops.to_teardown_btrace = remote_teardown_btrace; + remote_ops.to_read_btrace = remote_read_btrace; ++ remote_ops.to_augmented_libraries_svr4_read = ++ remote_augmented_libraries_svr4_read; + } + + /* Set up the extended remote vector by making a copy of the standard +--- src/gdb/target.c 2013/05/14 20:33:36 1.335 ++++ src/gdb/target.c 2013/06/04 13:10:53 1.336 +@@ -731,6 +731,7 @@ + INHERIT (to_traceframe_info, t); + INHERIT (to_use_agent, t); + INHERIT (to_can_use_agent, t); ++ INHERIT (to_augmented_libraries_svr4_read, t); + INHERIT (to_magic, t); + INHERIT (to_supports_evaluation_of_breakpoint_conditions, t); + INHERIT (to_can_run_breakpoint_commands, t); +@@ -975,6 +976,9 @@ + de_fault (to_can_use_agent, + (int (*) (void)) + return_zero); ++ de_fault (to_augmented_libraries_svr4_read, ++ (int (*) (void)) ++ return_zero); + de_fault (to_execution_direction, default_execution_direction); + + #undef de_fault +--- src/gdb/target.h 2013/05/14 20:33:36 1.262 ++++ src/gdb/target.h 2013/06/04 13:10:53 1.263 +@@ -941,6 +941,10 @@ + (inclusive) to function END (exclusive). */ + void (*to_call_history_range) (ULONGEST begin, ULONGEST end, int flags); + ++ /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a ++ non-empty annex. */ ++ int (*to_augmented_libraries_svr4_read) (void); ++ + int to_magic; + /* Need sub-structure for target machine related rather than comm related? + */ +@@ -1809,6 +1813,9 @@ + #define target_can_use_agent() \ + (*current_target.to_can_use_agent) () + ++#define target_augmented_libraries_svr4_read() \ ++ (*current_target.to_augmented_libraries_svr4_read) () ++ + /* Command logging facility. */ + + #define target_log_command(p) \ diff --git a/gdb-dlopen-stap-probe-7of7.patch b/gdb-dlopen-stap-probe-7of7.patch deleted file mode 100644 index 30357e9..0000000 --- a/gdb-dlopen-stap-probe-7of7.patch +++ /dev/null @@ -1,435 +0,0 @@ -http://sourceware.org/ml/gdb-patches/2013-05/msg00630.html -Subject: [RFA 7/7] Linker-debugger interface tests - - ---DCA/C9WSnDtl50zu -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline - -This patch adds some testcases for the linker-debugger interface. - ---DCA/C9WSnDtl50zu -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="rtld-probes-7-tests-gb.patch" - -2013-05-16 Gary Benson - - * gdb.base/break-probes.exp: New file. - * gdb.base/break-probes.c: Likewise. - * gdb.base/break-probes-solib.c: Likewise. - * gdb.base/info-shared.exp: New file. - * gdb.base/info-shared.c: Likewise. - * gdb.base/info-shared-solib1.c: Likewise. - * gdb.base/info-shared-solib2.c: Likewise. - -diff --git a/gdb/testsuite/gdb.base/break-probes.exp b/gdb/testsuite/gdb.base/break-probes.exp -new file mode 100644 -index 0000000..8372636 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/break-probes.exp -@@ -0,0 +1,77 @@ -+# Copyright 2013 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+if { [skip_shlib_tests] } { -+ return 0 -+} -+ -+standard_testfile -+ -+set libname $testfile-solib -+set srcfile_lib $srcdir/$subdir/$libname.c -+set binfile_lib [standard_output_file $libname.so] -+ -+set normal_bp "_dl_debug_state" -+set probes_bp "dl_main" -+ -+if { [gdb_compile_shlib $srcfile_lib $binfile_lib \ -+ [list additional_flags=-fPIC]] != "" } { -+ untested "Could not compile $binfile_lib." -+ return -1 -+} -+ -+if { [prepare_for_testing $testfile.exp $testfile $srcfile \ -+ [list additional_flags=-DSHLIB_NAME\=\"$binfile_lib\" libs=-ldl]] } { -+ return -1 -+} -+ -+# Enable stop-on-solib-events -+gdb_test_no_output "set stop-on-solib-events 1" -+ -+# Start the inferior and run to the first stop -+gdb_run_cmd -+gdb_test "" ".*Stopped due to shared library event.*" -+ -+# XFAIL if we are not using probes -+set test "ensure using probes" -+set using_probes 0 -+gdb_test_multiple "bt" $test { -+ -re "#0 +\[^\r\n\]*\\m(__GI_)?$normal_bp\\M.*$gdb_prompt $" { -+ xfail $test -+ } -+ -re "#0 +\[^\r\n\]*\\m(__GI_)?$probes_bp\\M.*$gdb_prompt $" { -+ pass $test -+ set using_probes 1 -+ } -+} -+ -+if { $using_probes } { -+ # Run til it loads our library -+ set test "run til our library loads" -+ set loaded_library 0 -+ while { !$loaded_library } { -+ gdb_test_multiple "c" $test { -+ -re "Inferior loaded $binfile_lib\\M.*$gdb_prompt $" { -+ pass $test -+ set loaded_library 1 -+ } -+ -re "Stopped due to shared library event\\M.*$gdb_prompt $" { -+ } -+ } -+ } -+ -+ # Call something to ensure that relocation occurred -+ gdb_test "call foo(23)" "\\\$.* = 31.*\\\M.*" -+} -diff --git a/gdb/testsuite/gdb.base/break-probes.c b/gdb/testsuite/gdb.base/break-probes.c -new file mode 100644 -index 0000000..a778099 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/break-probes.c -@@ -0,0 +1,26 @@ -+/* Copyright 2013 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+int -+main () -+{ -+ void *handle = dlopen (SHLIB_NAME, RTLD_LAZY); -+ -+ dlclose (handle); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/break-probes-solib.c b/gdb/testsuite/gdb.base/break-probes-solib.c -new file mode 100644 -index 0000000..bdde2db ---- /dev/null -+++ b/gdb/testsuite/gdb.base/break-probes-solib.c -@@ -0,0 +1,22 @@ -+/* Copyright 2013 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+int -+foo (int n) -+{ -+ return n * n / 17; -+} -diff --git a/gdb/testsuite/gdb.base/info-shared.exp b/gdb/testsuite/gdb.base/info-shared.exp -new file mode 100644 -index 0000000..1dabb9f ---- /dev/null -+++ b/gdb/testsuite/gdb.base/info-shared.exp -@@ -0,0 +1,145 @@ -+# Copyright 2013 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+if { [skip_shlib_tests] } { -+ return 0 -+} -+ -+standard_testfile -+ -+set lib1name $testfile-solib1 -+set srcfile_lib1 $srcdir/$subdir/$lib1name.c -+set binfile_lib1 [standard_output_file $lib1name.so] -+set define1 -DSHLIB1_NAME\=\"$binfile_lib1\" -+ -+set lib2name $testfile-solib2 -+set srcfile_lib2 $srcdir/$subdir/$lib2name.c -+set binfile_lib2 [standard_output_file $lib2name.so] -+set define2 -DSHLIB2_NAME\=\"$binfile_lib2\" -+ -+if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \ -+ [list additional_flags=-fPIC]] != "" } { -+ untested "Could not compile $binfile_lib1." -+ return -1 -+} -+ -+if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \ -+ [list additional_flags=-fPIC]] != "" } { -+ untested "Could not compile $binfile_lib2." -+ return -1 -+} -+ -+set cflags "$define1 $define2" -+if { [prepare_for_testing $testfile.exp $testfile $srcfile \ -+ [list additional_flags=$cflags libs=-ldl]] } { -+ return -1 -+} -+ -+# Run "info sharedlibrary" and check for the presence or absence of -+# our libraries. -+proc check_info_shared { test expect1 expect2 } { -+ global lib1name -+ global lib2name -+ global gdb_prompt -+ -+ set actual1 0 -+ set actual2 0 -+ -+ gdb_test_multiple "info sharedlibrary" $test { -+ -re $lib1name { -+ set actual1 1 -+ exp_continue -+ } -+ -re $lib2name { -+ set actual2 1 -+ exp_continue -+ } -+ -re "\r\n$gdb_prompt $" { -+ if { $actual1 == $expect1 && $actual2 == $expect2 } { -+ pass $test -+ } else { -+ fail $test -+ } -+ } -+ } -+} -+ -+# Start the inferior, and check neither of the libraries are loaded at -+# the start. -+runto_main -+check_info_shared "info sharedlibrary #1" 0 0 -+ -+# Set up breakpoints. -+gdb_test "break stop" {Breakpoint [0-9]+ at .*} -+gdb_test_no_output "set breakpoint pending on" -+gdb_test "break foo" {Breakpoint [0-9]+ \(foo\) pending\.} -+gdb_test "break bar" {Breakpoint [0-9]+ \(bar\) pending\.} -+ -+# Run to the first stop and check that only the first library is loaded. -+gdb_test "c" {Breakpoint [0-9]+, .* in stop \(\)} -+check_info_shared "info sharedlibrary #2" 1 0 -+ -+# Run to the second stop and check that both libraries are loaded. -+gdb_test "c" {Breakpoint [0-9]+, .* in stop \(\)} -+check_info_shared "info sharedlibrary #3" 1 1 -+ -+# Check that the next stop is in foo. -+gdb_test "c" {Breakpoint [0-9]+, .* in foo \(\) from .*} -+ -+# Check that the next stop is in bar. -+gdb_test "c" {Breakpoint [0-9]+, .* in bar \(\) from .*} -+ -+# Restart the inferior and make sure there are no breakpoint reset -+# errors. These can happen with the probes-based runtime linker -+# interface if the cache is not cleared correctly. -+set test "restart" -+gdb_run_cmd -+gdb_test_multiple "" $test { -+ -re {Start it from the beginning\? \(y or n\) } { -+ send_gdb "y\n" -+ exp_continue -+ } -+ -re {Error in re-setting breakpoint} { -+ fail $test -+ } -+ -re "\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+# Check that neither library is loaded. -+check_info_shared "info sharedlibrary #4" 0 0 -+ -+# Run to the first stop and check that only the first library is loaded. -+gdb_test "c" {Breakpoint [0-9]+, .* in stop \(\)} -+check_info_shared "info sharedlibrary #5" 1 0 -+ -+# Run to the second stop and check that both libraries are loaded. -+gdb_test "c" {Breakpoint [0-9]+, .* in stop \(\)} -+check_info_shared "info sharedlibrary #6" 1 1 -+ -+# Check that the next stop is in foo. -+gdb_test "c" {Breakpoint [0-9]+, .* in foo \(\) from .*} -+ -+# Check that the next stop is in bar. -+gdb_test "c" {Breakpoint [0-9]+, .* in bar \(\) from .*} -+ -+# Run to the next stop and check that the first library has been unloaded. -+gdb_test "c" {Breakpoint [0-9]+, .* in stop \(\)} -+check_info_shared "info sharedlibrary #7" 0 1 -+ -+# Run to the last stop and check that both libraries are gone. -+gdb_test "c" {Breakpoint [0-9]+, .* in stop \(\)} -+check_info_shared "info sharedlibrary #8" 0 0 -diff --git a/gdb/testsuite/gdb.base/info-shared.c b/gdb/testsuite/gdb.base/info-shared.c -new file mode 100644 -index 0000000..d699a11 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/info-shared.c -@@ -0,0 +1,48 @@ -+/* Copyright 2013 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+void -+stop () -+{ -+} -+ -+int -+main () -+{ -+ void *handle1, *handle2; -+ void (*func)(int); -+ -+ handle1 = dlopen (SHLIB1_NAME, RTLD_LAZY); -+ stop (); -+ -+ handle2 = dlopen (SHLIB2_NAME, RTLD_LAZY); -+ stop (); -+ -+ func = (void (*)(int)) dlsym (handle1, "foo"); -+ func (1); -+ -+ func = (void (*)(int)) dlsym (handle2, "bar"); -+ func (2); -+ -+ dlclose (handle1); -+ stop (); -+ -+ dlclose (handle2); -+ stop (); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/info-shared-solib1.c b/gdb/testsuite/gdb.base/info-shared-solib1.c -new file mode 100644 -index 0000000..9979ee7 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/info-shared-solib1.c -@@ -0,0 +1,24 @@ -+/* Copyright 2013 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+int -+foo (int n) -+{ -+ printf ("foo %d\n", n); -+ -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/info-shared-solib2.c b/gdb/testsuite/gdb.base/info-shared-solib2.c -new file mode 100644 -index 0000000..d4ed1e6 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/info-shared-solib2.c -@@ -0,0 +1,24 @@ -+/* Copyright 2013 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+int -+bar (int n) -+{ -+ printf ("bar %d\n", n); -+ -+ return 0; -+} - ---DCA/C9WSnDtl50zu-- - diff --git a/gdb-dlopen-stap-probe-7of9.patch b/gdb-dlopen-stap-probe-7of9.patch new file mode 100644 index 0000000..9cd5f56 --- /dev/null +++ b/gdb-dlopen-stap-probe-7of9.patch @@ -0,0 +1,1107 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00018.html + +### src/gdb/ChangeLog 2013/06/04 13:10:53 1.15684 +### src/gdb/ChangeLog 2013/06/04 13:17:05 1.15685 +## -1,5 +1,58 @@ + 2013-06-04 Gary Benson + ++ * breakpoint.h (handle_solib_event): Moved function declaration ++ to solib.h. ++ * breakpoint.c (handle_solib_event): Moved function to solib.c. ++ (bpstat_stop_status): Pass new argument to handle_solib_event. ++ * solib.h (update_solib_breakpoints): New function declaration. ++ (handle_solib_event): Moved function declaration from ++ breakpoint.h. ++ * solib.c (update_solib_breakpoints): New function. ++ (handle_solib_event): Moved function from breakpoint.c. ++ Updated to call solib_ops->handle_event if not NULL. ++ * solist.h (target_so_ops): New fields "update_breakpoints" and ++ "handle_event". ++ * infrun.c (set_stop_on_solib_events): New function. ++ (_initialize_infrun): Use the above for "set ++ stop-on-solib-events". ++ (handle_inferior_event): Pass new argument to handle_solib_event. ++ * solib-svr4.c (probe.h): New include. ++ (svr4_free_library_list): New forward declaration. ++ (probe_action): New enum. ++ (probe_info): New struct. ++ (probe_info): New static variable. ++ (NUM_PROBES): New definition. ++ (svr4_info): New fields "using_xfer", "probes_table" and ++ "solib_list". ++ (free_probes_table): New function. ++ (free_solib_list): New function. ++ (svr4_pspace_data_cleanup): Free probes table and solib list. ++ (svr4_copy_library_list): New function. ++ (svr4_current_sos_via_xfer_libraries): New parameter "annex". ++ (svr4_read_so_list): New parameter "prev_lm". ++ (svr4_current_sos_direct): Renamed from "svr4_current_sos". ++ (svr4_current_sos): New function. ++ (probe_and_action): New struct. ++ (hash_probe_and_action): New function. ++ (equal_probe_and_action): Likewise. ++ (register_solib_event_probe): Likewise. ++ (solib_event_probe_at): Likewise. ++ (solib_event_probe_action): Likewise. ++ (solist_update_full): Likewise. ++ (solist_update_incremental): Likewise. ++ (disable_probes_interface_cleanup): Likewise. ++ (svr4_handle_solib_event): Likewise. ++ (svr4_update_solib_event_breakpoint): Likewise. ++ (svr4_update_solib_event_breakpoints): Likewise. ++ (svr4_create_solib_event_breakpoints): Likewise. ++ (enable_break): Free probes table before creating breakpoints. ++ Use svr4_create_solib_event_breakpoints to create breakpoints. ++ (svr4_solib_create_inferior_hook): Free the solib list. ++ (_initialize_svr4_solib): Initialise ++ svr4_so_ops.handle_solib_event and svr4_so_ops.update_breakpoints. ++ ++2013-06-04 Gary Benson ++ + * target.h (target_ops): New field + "to_augmented_libraries_svr4_read". + (target_augmented_libraries_svr4_read): New macro. +Index: gdb-7.6/gdb/breakpoint.h +=================================================================== +--- gdb-7.6.orig/gdb/breakpoint.h 2013-06-10 14:44:37.455812656 +0200 ++++ gdb-7.6/gdb/breakpoint.h 2013-06-10 14:44:37.709812579 +0200 +@@ -1552,8 +1552,6 @@ extern int user_breakpoint_p (struct bre + /* Attempt to determine architecture of location identified by SAL. */ + extern struct gdbarch *get_sal_arch (struct symtab_and_line sal); + +-extern void handle_solib_event (void); +- + extern void breakpoint_free_objfile (struct objfile *objfile); + + extern void breakpoints_relocate (struct objfile *objfile, +Index: gdb-7.6/gdb/infrun.c +=================================================================== +--- gdb-7.6.orig/gdb/infrun.c 2013-06-10 14:44:37.427812664 +0200 ++++ gdb-7.6/gdb/infrun.c 2013-06-10 14:44:37.711812579 +0200 +@@ -370,6 +370,16 @@ static struct symbol *step_start_functio + /* Nonzero if we want to give control to the user when we're notified + of shared library events by the dynamic linker. */ + int stop_on_solib_events; ++ ++/* Enable or disable optional shared library event breakpoints ++ as appropriate when the above flag is changed. */ ++ ++static void ++set_stop_on_solib_events (char *args, int from_tty, struct cmd_list_element *c) ++{ ++ update_solib_breakpoints (); ++} ++ + static void + show_stop_on_solib_events (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +@@ -7335,7 +7345,7 @@ Show stopping for shared library events. + If nonzero, gdb will give control to the user when the dynamic linker\n\ + notifies gdb of shared library events. The most common event of interest\n\ + to the user would be loading/unloading of a new library."), +- NULL, ++ set_stop_on_solib_events, + show_stop_on_solib_events, + &setlist, &showlist); + +Index: gdb-7.6/gdb/solib-svr4.c +=================================================================== +--- gdb-7.6.orig/gdb/solib-svr4.c 2013-06-10 14:44:37.392812675 +0200 ++++ gdb-7.6/gdb/solib-svr4.c 2013-06-10 14:44:37.712812578 +0200 +@@ -46,10 +46,12 @@ + #include "auxv.h" + #include "exceptions.h" + #include "gdb_bfd.h" ++#include "probe.h" + + static struct link_map_offsets *svr4_fetch_link_map_offsets (void); + static int svr4_have_link_map_offsets (void); + static void svr4_relocate_main_executable (void); ++static void svr4_free_library_list (void *p_list); + + /* Link map info to include in an allocated so_list entry. */ + +@@ -106,6 +108,55 @@ static const char * const main_name_lis + NULL + }; + ++/* What to do when a probe stop occurs. */ ++ ++enum probe_action ++{ ++ /* Something went seriously wrong. Stop using probes and ++ revert to using the older interface. */ ++ PROBES_INTERFACE_FAILED, ++ ++ /* No action is required. The shared object list is still ++ valid. */ ++ DO_NOTHING, ++ ++ /* The shared object list should be reloaded entirely. */ ++ FULL_RELOAD, ++ ++ /* Attempt to incrementally update the shared object list. If ++ the update fails or is not possible, fall back to reloading ++ the list in full. */ ++ UPDATE_OR_RELOAD, ++}; ++ ++/* A probe's name and its associated action. */ ++ ++struct probe_info ++{ ++ /* The name of the probe. */ ++ const char *name; ++ ++ /* What to do when a probe stop occurs. */ ++ enum probe_action action; ++}; ++ ++/* A list of named probes and their associated actions. If all ++ probes are present in the dynamic linker then the probes-based ++ interface will be used. */ ++ ++static const struct probe_info probe_info[] = ++{ ++ { "init_start", DO_NOTHING }, ++ { "init_complete", FULL_RELOAD }, ++ { "map_start", DO_NOTHING }, ++ { "map_failed", DO_NOTHING }, ++ { "reloc_complete", UPDATE_OR_RELOAD }, ++ { "unmap_start", DO_NOTHING }, ++ { "unmap_complete", FULL_RELOAD }, ++}; ++ ++#define NUM_PROBES ARRAY_SIZE (probe_info) ++ + /* Return non-zero if GDB_SO_NAME and INFERIOR_SO_NAME represent + the same shared library. */ + +@@ -313,17 +364,58 @@ struct svr4_info + CORE_ADDR interp_text_sect_high; + CORE_ADDR interp_plt_sect_low; + CORE_ADDR interp_plt_sect_high; ++ ++ /* Nonzero if the list of objects was last obtained from the target ++ via qXfer:libraries-svr4:read. */ ++ int using_xfer; ++ ++ /* Table of struct probe_and_action instances, used by the ++ probes-based interface to map breakpoint addresses to probes ++ and their associated actions. Lookup is performed using ++ probe_and_action->probe->address. */ ++ htab_t probes_table; ++ ++ /* List of objects loaded into the inferior, used by the probes- ++ based interface. */ ++ struct so_list *solib_list; + }; + + /* Per-program-space data key. */ + static const struct program_space_data *solib_svr4_pspace_data; + ++/* Free the probes table. */ ++ ++static void ++free_probes_table (struct svr4_info *info) ++{ ++ if (info->probes_table == NULL) ++ return; ++ ++ htab_delete (info->probes_table); ++ info->probes_table = NULL; ++} ++ ++/* Free the solib list. */ ++ ++static void ++free_solib_list (struct svr4_info *info) ++{ ++ svr4_free_library_list (&info->solib_list); ++ info->solib_list = NULL; ++} ++ + static void + svr4_pspace_data_cleanup (struct program_space *pspace, void *arg) + { + struct svr4_info *info; + + info = program_space_data (pspace, solib_svr4_pspace_data); ++ if (info == NULL) ++ return; ++ ++ free_probes_table (info); ++ free_solib_list (info); ++ + xfree (info); + } + +@@ -982,6 +1074,34 @@ svr4_free_library_list (void *p_list) + } + } + ++/* Copy library list. */ ++ ++static struct so_list * ++svr4_copy_library_list (struct so_list *src) ++{ ++ struct so_list *dst = NULL; ++ struct so_list **link = &dst; ++ ++ while (src != NULL) ++ { ++ struct so_list *new; ++ ++ new = xmalloc (sizeof (struct so_list)); ++ memcpy (new, src, sizeof (struct so_list)); ++ ++ new->lm_info = xmalloc (sizeof (struct lm_info)); ++ memcpy (new->lm_info, src->lm_info, sizeof (struct lm_info)); ++ ++ new->next = NULL; ++ *link = new; ++ link = &new->next; ++ ++ src = src->next; ++ } ++ ++ return dst; ++} ++ + #ifdef HAVE_LIBEXPAT + + #include "xml-support.h" +@@ -1097,23 +1217,30 @@ svr4_parse_libraries (const char *docume + return 0; + } + +-/* Attempt to get so_list from target via qXfer:libraries:read packet. ++/* Attempt to get so_list from target via qXfer:libraries-svr4:read packet. + + Return 0 if packet not supported, *SO_LIST_RETURN is not modified in such + case. Return 1 if *SO_LIST_RETURN contains the library list, it may be +- empty, caller is responsible for freeing all its entries. */ ++ empty, caller is responsible for freeing all its entries. ++ ++ Note that ANNEX must be NULL if the remote does not explicitly allow ++ qXfer:libraries-svr4:read packets with non-empty annexes. Support for ++ this can be checked using target_augmented_libraries_svr4_read (). */ + + static int +-svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list) ++svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list, ++ const char *annex) + { + char *svr4_library_document; + int result; + struct cleanup *back_to; + ++ gdb_assert (annex == NULL || target_augmented_libraries_svr4_read ()); ++ + /* Fetch the list of shared libraries. */ + svr4_library_document = target_read_stralloc (¤t_target, + TARGET_OBJECT_LIBRARIES_SVR4, +- NULL); ++ annex); + if (svr4_library_document == NULL) + return 0; + +@@ -1127,7 +1254,8 @@ svr4_current_sos_via_xfer_libraries (str + #else + + static int +-svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list) ++svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list, ++ const char *annex) + { + return 0; + } +@@ -1161,15 +1289,19 @@ svr4_default_sos (void) + return new; + } + +-/* Read the whole inferior libraries chain starting at address LM. Add the +- entries to the tail referenced by LINK_PTR_PTR. Ignore the first entry if +- IGNORE_FIRST and set global MAIN_LM_ADDR according to it. */ ++/* Read the whole inferior libraries chain starting at address LM. ++ Expect the first entry in the chain's previous entry to be PREV_LM. ++ Add the entries to the tail referenced by LINK_PTR_PTR. Ignore the ++ first entry if IGNORE_FIRST and set global MAIN_LM_ADDR according ++ to it. Returns nonzero upon success. If zero is returned the ++ entries stored to LINK_PTR_PTR are still valid although they may ++ represent only part of the inferior library list. */ + +-static void +-svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr, +- int ignore_first) ++static int ++svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm, ++ struct so_list ***link_ptr_ptr, int ignore_first) + { +- CORE_ADDR prev_lm = 0, next_lm; ++ CORE_ADDR next_lm; + + for (; lm != 0; prev_lm = lm, lm = next_lm) + { +@@ -1185,7 +1317,7 @@ svr4_read_so_list (CORE_ADDR lm, struct + if (new->lm_info == NULL) + { + do_cleanups (old_chain); +- break; ++ return 0; + } + + next_lm = new->lm_info->l_next; +@@ -1196,7 +1328,7 @@ svr4_read_so_list (CORE_ADDR lm, struct + paddress (target_gdbarch (), prev_lm), + paddress (target_gdbarch (), new->lm_info->l_prev)); + do_cleanups (old_chain); +- break; ++ return 0; + } + + /* For SVR4 versions, the first entry in the link map is for the +@@ -1291,17 +1423,21 @@ svr4_read_so_list (CORE_ADDR lm, struct + **link_ptr_ptr = new; + *link_ptr_ptr = &new->next; + } ++ ++ return 1; + } + +-/* Implement the "current_sos" target_so_ops method. */ ++/* Read the full list of currently loaded shared objects directly ++ from the inferior, without referring to any libraries read and ++ stored by the probes interface. Handle special cases relating ++ to the first elements of the list. */ + + static struct so_list * +-svr4_current_sos (void) ++svr4_current_sos_direct (struct svr4_info *info) + { + CORE_ADDR lm; + struct so_list *head = NULL; + struct so_list **link_ptr = &head; +- struct svr4_info *info; + struct cleanup *back_to; + int ignore_first; + struct svr4_library_list library_list; +@@ -1314,19 +1450,16 @@ svr4_current_sos (void) + Unfortunately statically linked inferiors will also fall back through this + suboptimal code path. */ + +- if (svr4_current_sos_via_xfer_libraries (&library_list)) ++ info->using_xfer = svr4_current_sos_via_xfer_libraries (&library_list, ++ NULL); ++ if (info->using_xfer) + { + if (library_list.main_lm) +- { +- info = get_svr4_info (); +- info->main_lm_addr = library_list.main_lm; +- } ++ info->main_lm_addr = library_list.main_lm; + + return library_list.head ? library_list.head : svr4_default_sos (); + } + +- info = get_svr4_info (); +- + /* Always locate the debug struct, in case it has moved. */ + info->debug_base = 0; + locate_base (info); +@@ -1349,7 +1482,7 @@ svr4_current_sos (void) + `struct so_list' nodes. */ + lm = solib_svr4_r_map (info); + if (lm) +- svr4_read_so_list (lm, &link_ptr, ignore_first); ++ svr4_read_so_list (lm, 0, &link_ptr, ignore_first); + + /* On Solaris, the dynamic linker is not in the normal list of + shared objects, so make sure we pick it up too. Having +@@ -1357,7 +1490,7 @@ svr4_current_sos (void) + for skipping dynamic linker resolver code. */ + lm = solib_svr4_r_ldsomap (info); + if (lm) +- svr4_read_so_list (lm, &link_ptr, 0); ++ svr4_read_so_list (lm, 0, &link_ptr, 0); + + discard_cleanups (back_to); + +@@ -1367,6 +1500,22 @@ svr4_current_sos (void) + return head; + } + ++/* Implement the "current_sos" target_so_ops method. */ ++ ++static struct so_list * ++svr4_current_sos (void) ++{ ++ struct svr4_info *info = get_svr4_info (); ++ ++ /* If the solib list has been read and stored by the probes ++ interface then we return a copy of the stored list. */ ++ if (info->solib_list != NULL) ++ return svr4_copy_library_list (info->solib_list); ++ ++ /* Otherwise obtain the solib list directly from the inferior. */ ++ return svr4_current_sos_direct (info); ++} ++ + /* Get the address of the link_map for a given OBJFILE. */ + + CORE_ADDR +@@ -1449,6 +1598,476 @@ exec_entry_point (struct bfd *abfd, stru + return gdbarch_addr_bits_remove (target_gdbarch (), addr); + } + ++/* A probe and its associated action. */ ++ ++struct probe_and_action ++{ ++ /* The probe. */ ++ struct probe *probe; ++ ++ /* The action. */ ++ enum probe_action action; ++}; ++ ++/* Returns a hash code for the probe_and_action referenced by p. */ ++ ++static hashval_t ++hash_probe_and_action (const void *p) ++{ ++ const struct probe_and_action *pa = p; ++ ++ return (hashval_t) pa->probe->address; ++} ++ ++/* Returns non-zero if the probe_and_actions referenced by p1 and p2 ++ are equal. */ ++ ++static int ++equal_probe_and_action (const void *p1, const void *p2) ++{ ++ const struct probe_and_action *pa1 = p1; ++ const struct probe_and_action *pa2 = p2; ++ ++ return pa1->probe->address == pa2->probe->address; ++} ++ ++/* Register a solib event probe and its associated action in the ++ probes table. */ ++ ++static void ++register_solib_event_probe (struct probe *probe, enum probe_action action) ++{ ++ struct svr4_info *info = get_svr4_info (); ++ struct probe_and_action lookup, *pa; ++ void **slot; ++ ++ /* Create the probes table, if necessary. */ ++ if (info->probes_table == NULL) ++ info->probes_table = htab_create_alloc (1, hash_probe_and_action, ++ equal_probe_and_action, ++ xfree, xcalloc, xfree); ++ ++ lookup.probe = probe; ++ slot = htab_find_slot (info->probes_table, &lookup, INSERT); ++ gdb_assert (*slot == HTAB_EMPTY_ENTRY); ++ ++ pa = XCNEW (struct probe_and_action); ++ pa->probe = probe; ++ pa->action = action; ++ ++ *slot = pa; ++} ++ ++/* Get the solib event probe at the specified location, and the ++ action associated with it. Returns NULL if no solib event probe ++ was found. */ ++ ++static struct probe_and_action * ++solib_event_probe_at (struct svr4_info *info, CORE_ADDR address) ++{ ++ struct probe lookup_probe; ++ struct probe_and_action lookup; ++ void **slot; ++ ++ lookup_probe.address = address; ++ lookup.probe = &lookup_probe; ++ slot = htab_find_slot (info->probes_table, &lookup, NO_INSERT); ++ ++ if (slot == NULL) ++ return NULL; ++ ++ return (struct probe_and_action *) *slot; ++} ++ ++/* Decide what action to take when the specified solib event probe is ++ hit. */ ++ ++static enum probe_action ++solib_event_probe_action (struct probe_and_action *pa) ++{ ++ enum probe_action action; ++ unsigned probe_argc; ++ ++ action = pa->action; ++ if (action == DO_NOTHING || action == PROBES_INTERFACE_FAILED) ++ return action; ++ ++ gdb_assert (action == FULL_RELOAD || action == UPDATE_OR_RELOAD); ++ ++ /* Check that an appropriate number of arguments has been supplied. ++ We expect: ++ arg0: Lmid_t lmid (mandatory) ++ arg1: struct r_debug *debug_base (mandatory) ++ arg2: struct link_map *new (optional, for incremental updates) */ ++ probe_argc = get_probe_argument_count (pa->probe); ++ if (probe_argc == 2) ++ action = FULL_RELOAD; ++ else if (probe_argc < 2) ++ action = PROBES_INTERFACE_FAILED; ++ ++ return action; ++} ++ ++/* Populate the shared object list by reading the entire list of ++ shared objects from the inferior. Handle special cases relating ++ to the first elements of the list. Returns nonzero on success. */ ++ ++static int ++solist_update_full (struct svr4_info *info) ++{ ++ free_solib_list (info); ++ info->solib_list = svr4_current_sos_direct (info); ++ ++ return 1; ++} ++ ++/* Update the shared object list starting from the link-map entry ++ passed by the linker in the probe's third argument. Returns ++ nonzero if the list was successfully updated, or zero to indicate ++ failure. */ ++ ++static int ++solist_update_incremental (struct svr4_info *info, CORE_ADDR lm) ++{ ++ struct so_list *tail; ++ CORE_ADDR prev_lm; ++ ++ /* svr4_current_sos_direct contains logic to handle a number of ++ special cases relating to the first elements of the list. To ++ avoid duplicating this logic we defer to solist_update_full ++ if the list is empty. */ ++ if (info->solib_list == NULL) ++ return 0; ++ ++ /* Fall back to a full update if we are using a remote target ++ that does not support incremental transfers. */ ++ if (info->using_xfer && !target_augmented_libraries_svr4_read ()) ++ return 0; ++ ++ /* Walk to the end of the list. */ ++ for (tail = info->solib_list; tail->next != NULL; tail = tail->next) ++ /* Nothing. */; ++ prev_lm = tail->lm_info->lm_addr; ++ ++ /* Read the new objects. */ ++ if (info->using_xfer) ++ { ++ struct svr4_library_list library_list; ++ char annex[64]; ++ ++ xsnprintf (annex, sizeof (annex), "start=%s;prev=%s", ++ phex_nz (lm, sizeof (lm)), ++ phex_nz (prev_lm, sizeof (prev_lm))); ++ if (!svr4_current_sos_via_xfer_libraries (&library_list, annex)) ++ return 0; ++ ++ tail->next = library_list.head; ++ } ++ else ++ { ++ struct so_list **link = &tail->next; ++ ++ /* IGNORE_FIRST may safely be set to zero here because the ++ above check and deferral to solist_update_full ensures ++ that this call to svr4_read_so_list will never see the ++ first element. */ ++ if (!svr4_read_so_list (lm, prev_lm, &link, 0)) ++ return 0; ++ } ++ ++ return 1; ++} ++ ++/* Disable the probes-based linker interface and revert to the ++ original interface. We don't reset the breakpoints as the ++ ones set up for the probes-based interface are adequate. */ ++ ++static void ++disable_probes_interface_cleanup (void *arg) ++{ ++ struct svr4_info *info = get_svr4_info (); ++ ++ warning (_("Probes-based dynamic linker interface failed.\n" ++ "Reverting to original interface.\n")); ++ ++ free_probes_table (info); ++ free_solib_list (info); ++} ++ ++/* Update the solib list as appropriate when using the ++ probes-based linker interface. Do nothing if using the ++ standard interface. */ ++ ++static void ++svr4_handle_solib_event (void) ++{ ++ struct svr4_info *info = get_svr4_info (); ++ struct probe_and_action *pa; ++ enum probe_action action; ++ struct cleanup *old_chain, *usm_chain; ++ struct value *val; ++ CORE_ADDR pc, debug_base, lm = 0; ++ int is_initial_ns; ++ ++ /* Do nothing if not using the probes interface. */ ++ if (info->probes_table == NULL) ++ return; ++ ++ /* If anything goes wrong we revert to the original linker ++ interface. */ ++ old_chain = make_cleanup (disable_probes_interface_cleanup, NULL); ++ ++ pc = regcache_read_pc (get_current_regcache ()); ++ pa = solib_event_probe_at (info, pc); ++ if (pa == NULL) ++ { ++ do_cleanups (old_chain); ++ return; ++ } ++ ++ action = solib_event_probe_action (pa); ++ if (action == PROBES_INTERFACE_FAILED) ++ { ++ do_cleanups (old_chain); ++ return; ++ } ++ ++ if (action == DO_NOTHING) ++ { ++ discard_cleanups (old_chain); ++ return; ++ } ++ ++ /* evaluate_probe_argument looks up symbols in the dynamic linker ++ using find_pc_section. find_pc_section is accelerated by a cache ++ called the section map. The section map is invalidated every ++ time a shared library is loaded or unloaded, and if the inferior ++ is generating a lot of shared library events then the section map ++ will be updated every time svr4_handle_solib_event is called. ++ We called find_pc_section in svr4_create_solib_event_breakpoints, ++ so we can guarantee that the dynamic linker's sections are in the ++ section map. We can therefore inhibit section map updates across ++ these calls to evaluate_probe_argument and save a lot of time. */ ++ inhibit_section_map_updates (current_program_space); ++ usm_chain = make_cleanup (resume_section_map_updates_cleanup, ++ current_program_space); ++ ++ val = evaluate_probe_argument (pa->probe, 1); ++ if (val == NULL) ++ { ++ do_cleanups (old_chain); ++ return; ++ } ++ ++ debug_base = value_as_address (val); ++ if (debug_base == 0) ++ { ++ do_cleanups (old_chain); ++ return; ++ } ++ ++ /* Always locate the debug struct, in case it moved. */ ++ info->debug_base = 0; ++ if (locate_base (info) == 0) ++ { ++ do_cleanups (old_chain); ++ return; ++ } ++ ++ /* GDB does not currently support libraries loaded via dlmopen ++ into namespaces other than the initial one. We must ignore ++ any namespace other than the initial namespace here until ++ support for this is added to GDB. */ ++ if (debug_base != info->debug_base) ++ action = DO_NOTHING; ++ ++ if (action == UPDATE_OR_RELOAD) ++ { ++ val = evaluate_probe_argument (pa->probe, 2); ++ if (val != NULL) ++ lm = value_as_address (val); ++ ++ if (lm == 0) ++ action = FULL_RELOAD; ++ } ++ ++ /* Resume section map updates. */ ++ do_cleanups (usm_chain); ++ ++ if (action == UPDATE_OR_RELOAD) ++ { ++ if (!solist_update_incremental (info, lm)) ++ action = FULL_RELOAD; ++ } ++ ++ if (action == FULL_RELOAD) ++ { ++ if (!solist_update_full (info)) ++ { ++ do_cleanups (old_chain); ++ return; ++ } ++ } ++ ++ discard_cleanups (old_chain); ++} ++ ++/* Helper function for svr4_update_solib_event_breakpoints. */ ++ ++static int ++svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg) ++{ ++ struct bp_location *loc; ++ ++ if (b->type != bp_shlib_event) ++ { ++ /* Continue iterating. */ ++ return 0; ++ } ++ ++ for (loc = b->loc; loc != NULL; loc = loc->next) ++ { ++ struct svr4_info *info; ++ struct probe_and_action *pa; ++ ++ info = program_space_data (loc->pspace, solib_svr4_pspace_data); ++ if (info == NULL || info->probes_table == NULL) ++ continue; ++ ++ pa = solib_event_probe_at (info, loc->address); ++ if (pa == NULL) ++ continue; ++ ++ if (pa->action == DO_NOTHING) ++ { ++ if (b->enable_state == bp_disabled && stop_on_solib_events) ++ enable_breakpoint (b); ++ else if (b->enable_state == bp_enabled && !stop_on_solib_events) ++ disable_breakpoint (b); ++ } ++ ++ break; ++ } ++ ++ /* Continue iterating. */ ++ return 0; ++} ++ ++/* Enable or disable optional solib event breakpoints as appropriate. ++ Called whenever stop_on_solib_events is changed. */ ++ ++static void ++svr4_update_solib_event_breakpoints (void) ++{ ++ iterate_over_breakpoints (svr4_update_solib_event_breakpoint, NULL); ++} ++ ++/* Create and register solib event breakpoints. PROBES is an array ++ of NUM_PROBES elements, each of which is vector of probes. A ++ solib event breakpoint will be created and registered for each ++ probe. */ ++ ++static void ++svr4_create_probe_breakpoints (struct gdbarch *gdbarch, ++ VEC (probe_p) **probes) ++{ ++ int i; ++ ++ for (i = 0; i < NUM_PROBES; i++) ++ { ++ enum probe_action action = probe_info[i].action; ++ struct probe *probe; ++ int ix; ++ ++ for (ix = 0; ++ VEC_iterate (probe_p, probes[i], ix, probe); ++ ++ix) ++ { ++ create_solib_event_breakpoint (gdbarch, probe->address); ++ register_solib_event_probe (probe, action); ++ } ++ } ++ ++ svr4_update_solib_event_breakpoints (); ++} ++ ++/* Both the SunOS and the SVR4 dynamic linkers call a marker function ++ before and after mapping and unmapping shared libraries. The sole ++ purpose of this method is to allow debuggers to set a breakpoint so ++ they can track these changes. ++ ++ Some versions of the glibc dynamic linker contain named probes ++ to allow more fine grained stopping. Given the address of the ++ original marker function, this function attempts to find these ++ probes, and if found, sets breakpoints on those instead. If the ++ probes aren't found, a single breakpoint is set on the original ++ marker function. */ ++ ++static void ++svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch, ++ CORE_ADDR address) ++{ ++ struct obj_section *os; ++ ++ os = find_pc_section (address); ++ if (os != NULL) ++ { ++ int with_prefix; ++ ++ for (with_prefix = 0; with_prefix <= 1; with_prefix++) ++ { ++ VEC (probe_p) *probes[NUM_PROBES]; ++ int all_probes_found = 1; ++ int i; ++ ++ memset (probes, 0, sizeof (probes)); ++ for (i = 0; i < NUM_PROBES; i++) ++ { ++ const char *name = probe_info[i].name; ++ char buf[32]; ++ ++ /* Fedora 17 and Red Hat Enterprise Linux 6.2-6.4 ++ shipped with an early version of the probes code in ++ which the probes' names were prefixed with "rtld_" ++ and the "map_failed" probe did not exist. The ++ locations of the probes are otherwise the same, so ++ we check for probes with prefixed names if probes ++ with unprefixed names are not present. */ ++ if (with_prefix) ++ { ++ xsnprintf (buf, sizeof (buf), "rtld_%s", name); ++ name = buf; ++ } ++ ++ probes[i] = find_probes_in_objfile (os->objfile, "rtld", name); ++ ++ /* The "map_failed" probe did not exist in early ++ versions of the probes code in which the probes' ++ names were prefixed with "rtld_". */ ++ if (strcmp (name, "rtld_map_failed") == 0) ++ continue; ++ ++ if (VEC_empty (probe_p, probes[i])) ++ { ++ all_probes_found = 0; ++ break; ++ } ++ } ++ ++ if (all_probes_found) ++ svr4_create_probe_breakpoints (gdbarch, probes); ++ ++ for (i = 0; i < NUM_PROBES; i++) ++ VEC_free (probe_p, probes[i]); ++ ++ if (all_probes_found) ++ return; ++ } ++ } ++ ++ create_solib_event_breakpoint (gdbarch, address); ++} ++ + /* Helper function for gdb_bfd_lookup_symbol. */ + + static int +@@ -1532,7 +2151,7 @@ enable_break (struct svr4_info *info, in + That knowledge is encoded in the address, if it's Thumb the low bit + is 1. However, we've stripped that info above and it's not clear + what all the consequences are of passing a non-addr_bits_remove'd +- address to create_solib_event_breakpoint. The call to ++ address to svr4_create_solib_event_breakpoints. The call to + find_pc_section verifies we know about the address and have some + hope of computing the right kind of breakpoint to use (via + symbol info). It does mean that GDB needs to be pointed at a +@@ -1570,7 +2189,7 @@ enable_break (struct svr4_info *info, in + + bfd_section_size (tmp_bfd, interp_sect); + } + +- create_solib_event_breakpoint (target_gdbarch (), sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr); + return 1; + } + } +@@ -1728,7 +2347,8 @@ enable_break (struct svr4_info *info, in + + if (sym_addr != 0) + { +- create_solib_event_breakpoint (target_gdbarch (), load_addr + sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch (), ++ load_addr + sym_addr); + xfree (interp_name); + return 1; + } +@@ -1754,7 +2374,7 @@ enable_break (struct svr4_info *info, in + sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), + sym_addr, + ¤t_target); +- create_solib_event_breakpoint (target_gdbarch (), sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr); + return 1; + } + } +@@ -1770,7 +2390,7 @@ enable_break (struct svr4_info *info, in + sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), + sym_addr, + ¤t_target); +- create_solib_event_breakpoint (target_gdbarch (), sym_addr); ++ svr4_create_solib_event_breakpoints (target_gdbarch (), sym_addr); + return 1; + } + } +@@ -2266,6 +2886,10 @@ svr4_solib_create_inferior_hook (int fro + + info = get_svr4_info (); + ++ /* Clear the probes-based interface's state. */ ++ free_probes_table (info); ++ free_solib_list (info); ++ + /* Relocate the main executable if necessary. */ + svr4_relocate_main_executable (); + +@@ -2507,4 +3131,6 @@ _initialize_svr4_solib (void) + svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol; + svr4_so_ops.same = svr4_same; + svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core; ++ svr4_so_ops.update_breakpoints = svr4_update_solib_event_breakpoints; ++ svr4_so_ops.handle_event = svr4_handle_solib_event; + } +Index: gdb-7.6/gdb/solib.c +=================================================================== +--- gdb-7.6.orig/gdb/solib.c 2013-06-10 14:44:37.392812675 +0200 ++++ gdb-7.6/gdb/solib.c 2013-06-10 14:44:37.713812578 +0200 +@@ -1221,6 +1221,37 @@ no_shared_libraries (char *ignored, int + objfile_purge_solibs (); + } + ++/* See solib.h. */ ++ ++void ++update_solib_breakpoints (void) ++{ ++ const struct target_so_ops *ops = solib_ops (target_gdbarch ()); ++ ++ if (ops->update_breakpoints != NULL) ++ ops->update_breakpoints (); ++} ++ ++/* See solib.h. */ ++ ++void ++handle_solib_event (void) ++{ ++ const struct target_so_ops *ops = solib_ops (target_gdbarch ()); ++ ++ if (ops->handle_event != NULL) ++ ops->handle_event (); ++ ++ clear_program_space_solib_cache (current_inferior ()->pspace); ++ ++ /* Check for any newly added shared libraries if we're supposed to ++ be adding them automatically. Switch terminal for any messages ++ produced by breakpoint_re_set. */ ++ target_terminal_ours_for_output (); ++ solib_add (NULL, 0, ¤t_target, auto_solib_add); ++ target_terminal_inferior (); ++} ++ + /* Reload shared libraries, but avoid reloading the same symbol file + we already have loaded. */ + +Index: gdb-7.6/gdb/solib.h +=================================================================== +--- gdb-7.6.orig/gdb/solib.h 2013-01-01 07:32:51.000000000 +0100 ++++ gdb-7.6/gdb/solib.h 2013-06-10 14:44:37.713812578 +0200 +@@ -90,4 +90,12 @@ extern CORE_ADDR gdb_bfd_lookup_symbol_f + void *), + void *data); + ++/* Enable or disable optional solib event breakpoints as appropriate. */ ++ ++extern void update_solib_breakpoints (void); ++ ++/* Handle an solib event by calling solib_add. */ ++ ++extern void handle_solib_event (void); ++ + #endif /* SOLIB_H */ +Index: gdb-7.6/gdb/solist.h +=================================================================== +--- gdb-7.6.orig/gdb/solist.h 2013-01-01 07:32:51.000000000 +0100 ++++ gdb-7.6/gdb/solist.h 2013-06-10 14:44:37.713812578 +0200 +@@ -148,6 +148,19 @@ struct target_so_ops + core file (in particular, for readonly sections). */ + int (*keep_data_in_core) (CORE_ADDR vaddr, + unsigned long size); ++ ++ /* Enable or disable optional solib event breakpoints as ++ appropriate. This should be called whenever ++ stop_on_solib_events is changed. This pointer can be ++ NULL, in which case no enabling or disabling is necessary ++ for this target. */ ++ void (*update_breakpoints) (void); ++ ++ /* Target-specific processing of solib events that will be ++ performed before solib_add is called. This pointer can be ++ NULL, in which case no specific preprocessing is necessary ++ for this target. */ ++ void (*handle_event) (void); + }; + + /* Free the memory associated with a (so_list *). */ +Index: gdb-7.6/gdb/breakpoint.c +=================================================================== +--- gdb-7.6.orig/gdb/breakpoint.c 2013-06-10 14:44:37.500812642 +0200 ++++ gdb-7.6/gdb/breakpoint.c 2013-06-10 14:44:57.301806708 +0200 +@@ -5348,25 +5348,6 @@ handle_jit_event (void) + target_terminal_inferior (); + } + +-/* Handle an solib event by calling solib_add. */ +- +-void +-handle_solib_event (void) +-{ +- clear_program_space_solib_cache (current_inferior ()->pspace); +- +- /* Check for any newly added shared libraries if we're supposed to +- be adding them automatically. Switch terminal for any messages +- produced by breakpoint_re_set. */ +- target_terminal_ours_for_output (); +-#ifdef SOLIB_ADD +- SOLIB_ADD (NULL, 0, ¤t_target, auto_solib_add); +-#else +- solib_add (NULL, 0, ¤t_target, auto_solib_add); +-#endif +- target_terminal_inferior (); +-} +- + /* Prepare WHAT final decision for infrun. */ + + /* Decide what infrun needs to do with this bpstat. */ diff --git a/gdb-dlopen-stap-probe-8of9.patch b/gdb-dlopen-stap-probe-8of9.patch new file mode 100644 index 0000000..3b6638a --- /dev/null +++ b/gdb-dlopen-stap-probe-8of9.patch @@ -0,0 +1,462 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00019.html + +### src/gdb/testsuite/ChangeLog 2013/05/30 00:25:16 1.3682 +### src/gdb/testsuite/ChangeLog 2013/06/04 13:23:31 1.3683 +## -1,3 +1,19 @@ ++2013-06-04 Jan Kratochvil ++ Gary Benson ++ ++ * lib/gdb.exp (build_executable_from_specs): Use gdb_compile_pthread, ++ gdb_compile_shlib or gdb_compile_shlib_pthreads where appropriate. ++ * lib/prelink-support.exp (build_executable_own_libs): Allow INTERP ++ to be set to "no" to indicate that no ld.so copy should be made. ++ * gdb.base/break-interp.exp (solib_bp): New constant. ++ (reach_1): Use the above instead of "_dl_debug_state". ++ (test_attach): Likewise. ++ (test_ld): Likewise. ++ * gdb.threads/dlopen-libpthread.exp: New file. ++ * gdb.threads/dlopen-libpthread.c: Likewise. ++ * gdb.threads/dlopen-libpthread-lib.c: Likewise. ++ * gdb.base/solib-corrupted.exp: Disable test if GDB is using probes. ++ + 2013-05-30 Yao Qi + + * gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed): +Index: gdb-7.6/gdb/testsuite/gdb.base/break-interp.exp +=================================================================== +--- gdb-7.6.orig/gdb/testsuite/gdb.base/break-interp.exp 2013-06-10 14:29:24.815123941 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.base/break-interp.exp 2013-06-10 14:30:18.086102375 +0200 +@@ -109,12 +109,19 @@ proc strip_debug {dest} { + } + } + ++# The marker function for the standard runtime linker interface is ++# _dl_debug_state. The probes-based interface has no specific marker ++# function; the probe we will stop on (init_start) is in dl_main so we ++# check for that. ++ ++set solib_bp {(_dl_debug_state|dl_main)} ++ + # Implementation of reach. + + proc reach_1 {func command displacement} { +- global gdb_prompt expect_out ++ global gdb_prompt expect_out solib_bp + +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + # Breakpoint on _dl_debug_state can have problems due to its overlap + # with the existing internal breakpoint from GDB. + gdb_test_no_output "set stop-on-solib-events 1" +@@ -142,21 +149,21 @@ proc reach_1 {func command displacement} + exp_continue + } + -re "Breakpoint \[0-9\]+, \\.?(__GI_)?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" { +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + fail $test + } else { + pass $test + } + } + -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?(__GI_)?$func \\(\\).*\r\n$gdb_prompt $" { +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + fail $test + } else { + pass $test + } + } + -re "Stopped due to (spurious )?shared library event.*\r\n$gdb_prompt $" { +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + if {$debug_state_count == 0} { + # First stop does not yet relocate the _start function + # descriptor on ppc64. +@@ -175,7 +182,7 @@ proc reach_1 {func command displacement} + fail $test_displacement + } + +- if {$func == "_dl_debug_state"} { ++ if {$func == $solib_bp} { + gdb_test_no_output "set stop-on-solib-events 0" + } + } +@@ -357,7 +364,7 @@ proc test_attach {file displacement {rel + } + + proc test_ld {file ifmain trynosym displacement} { +- global srcdir subdir gdb_prompt expect_out inferior_exited_re ++ global srcdir subdir gdb_prompt expect_out inferior_exited_re solib_bp + + # First test normal `file'-command loaded $FILE with symbols. + +@@ -385,9 +392,9 @@ proc test_ld {file ifmain trynosym displ + gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test" + } + +- reach "_dl_debug_state" "run" $displacement ++ reach $solib_bp "run" $displacement + +- gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?_dl_debug_state\\M.*" "dl bt" ++ gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt" + + if $ifmain { + reach "main" continue "NONE" +@@ -399,7 +406,7 @@ proc test_ld {file ifmain trynosym displ + + # Try re-run if the new PIE displacement takes effect. + gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y" +- reach "_dl_debug_state" "run" $displacement ++ reach $solib_bp "run" $displacement + + if $ifmain { + test_core $file $displacement +@@ -431,7 +438,7 @@ proc test_ld {file ifmain trynosym displ + gdb_test "exec-file $file" "exec-file $escapedfile" "load" + + if $ifmain { +- reach "_dl_debug_state" run $displacement ++ reach $solib_bp run $displacement + + # Use two separate gdb_test_multiple statements to avoid timeouts due + # to slow processing of wildcard capturing long output +Index: gdb-7.6/gdb/testsuite/gdb.base/solib-corrupted.exp +=================================================================== +--- gdb-7.6.orig/gdb/testsuite/gdb.base/solib-corrupted.exp 2013-06-10 14:29:24.816123941 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.base/solib-corrupted.exp 2013-06-10 14:30:18.086102375 +0200 +@@ -36,6 +36,33 @@ if ![runto_main] { + return + } + ++# With probes interface GDB no longer scans the inferior library list so its ++# corruption cannot be tested. There is no way to disable the probes ++# interface. ++ ++set probes { init_start init_complete map_start reloc_complete unmap_start ++ unmap_complete } ++set test "info probes" ++gdb_test_multiple $test $test { ++ -re "^rtld\[ \t\]+(?:rtld_)?(\[a-z_\]+)\[ \t\]" { ++ set idx [lsearch -exact $probes $expect_out(1,string)] ++ if { $idx >= 0 } { ++ set probes [lreplace $probes $idx $idx] ++ } ++ exp_continue ++ } ++ -re "^\[^\r\n\]*\r\n" { ++ exp_continue ++ } ++ -re "^$gdb_prompt $" { ++ } ++} ++if { [llength $probes] == 0 } { ++ xfail $test ++ untested "GDB is using probes" ++ return ++} ++ + gdb_test "info sharedlibrary" "From * To .*" "normal list" + + # GDB checks there for matching L_PREV. +Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2013-06-10 14:30:18.086102375 +0200 +@@ -0,0 +1,40 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011-2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++#include ++ ++static void * ++tfunc (void *arg) ++{ ++ void (*notifyp) (void) = arg; ++ ++ notifyp (); ++} ++ ++void ++f (void (*notifyp) (void)) ++{ ++ pthread_t t; ++ int i; ++ ++ i = pthread_create (&t, NULL, tfunc, notifyp); ++ assert (i == 0); ++ ++ i = pthread_join (t, NULL); ++ assert (i == 0); ++} +Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2013-06-10 14:30:18.087102375 +0200 +@@ -0,0 +1,46 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2011-2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++#include ++#include ++ ++static const char *volatile filename; ++ ++static void ++notify (void) ++{ ++ filename = NULL; /* notify-here */ ++} ++ ++int ++main (void) ++{ ++ void *h; ++ void (*fp) (void (*) (void)); ++ ++ assert (filename != NULL); ++ h = dlopen (filename, RTLD_LAZY); ++ assert (h != NULL); ++ ++ fp = dlsym (h, "f"); ++ assert (fp != NULL); ++ ++ fp (notify); ++ ++ return 0; ++} +Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2013-06-10 14:30:18.087102375 +0200 +@@ -0,0 +1,74 @@ ++# Copyright 2011-2013 Free Software Foundation, Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if {![istarget *-linux*] || [skip_shlib_tests]} { ++ return 0 ++} ++ ++load_lib prelink-support.exp ++ ++set testfile "dlopen-libpthread" ++set srcmainfile ${testfile}.c ++set srclibfile ${testfile}-lib.c ++set executable ${testfile} ++set binfile_lib ${objdir}/${subdir}/${executable}.so ++set binfile ${objdir}/${subdir}/${executable} ++set lib_dlopen [shlib_target_file ${executable}.so] ++ ++# Use build_executable_own_libs as prelinked libpthread.so can produce false ++# PASS - it is OK if GDB processes it still before relocation. ++ ++set relink_args [build_executable_own_libs ${testfile}.exp ${executable}.so $srclibfile {debug shlib_pthreads} no] ++if {$relink_args == "" || ![prelink_no $relink_args] ++ || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug shlib_load}] } { ++ return -1 ++} ++gdb_load_shlibs $binfile_lib ++ ++if { ![runto_main] } { ++ return -1 ++} ++ ++set test "info probes all rtld rtld_map_complete" ++gdb_test_multiple $test $test { ++ -re "\[ \t\]rtld_map_complete\[ \t\]+0x\[0-9a-f\]+.*\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "No probes matched\\.\r\n$gdb_prompt $" { ++ xfail $test ++ untested ${testfile}.exp ++ return ++ } ++} ++ ++set test "libpthread.so not found" ++gdb_test_multiple "info sharedlibrary" $test { ++ -re "/libpthread\\.so.*\r\n$gdb_prompt $" { ++ fail $test ++ } ++ -re "/libc\\.so.*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++gdb_test "set variable filename=\"$lib_dlopen\"" ++ ++gdb_breakpoint "notify" ++ ++# The error was: ++# Cannot find new threads: generic error ++gdb_continue_to_breakpoint "notify" ".* notify-here .*" ++ ++gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found" +Index: gdb-7.6/gdb/testsuite/lib/gdb.exp +=================================================================== +--- gdb-7.6.orig/gdb/testsuite/lib/gdb.exp 2013-06-10 14:29:24.819123940 +0200 ++++ gdb-7.6/gdb/testsuite/lib/gdb.exp 2013-06-10 14:30:44.654092140 +0200 +@@ -4011,22 +4011,6 @@ proc build_executable_from_specs {testna + + set binfile [standard_output_file $executable] + +- set objects {} +- set i 0 +- foreach {s local_options} $args { +- if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } { +- untested $testname +- return -1 +- } +- lappend objects "${binfile}${i}.o" +- incr i +- } +- +- if { [gdb_compile $objects "${binfile}" executable $options] != "" } { +- untested $testname +- return -1 +- } +- + set info_options "" + if { [lsearch -exact $options "c++"] >= 0 } { + set info_options "c++" +@@ -4034,6 +4018,42 @@ proc build_executable_from_specs {testna + if [get_compiler_info ${info_options}] { + return -1 + } ++ ++ set binfile [standard_output_file $executable] ++ ++ set func gdb_compile ++ set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads)$}] ++ if {$func_index != -1} { ++ set func "${func}_[lindex $options $func_index]" ++ } ++ ++ # gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd ++ # parameter. They also requires $sources while gdb_compile and ++ # gdb_compile_pthreads require $objects. Moreover they ignore any options. ++ if [string match gdb_compile_shlib* $func] { ++ set sources_path {} ++ foreach {s local_options} $args { ++ lappend sources_path "${srcdir}/${subdir}/${s}" ++ } ++ set ret [$func $sources_path "${binfile}" $options] ++ } else { ++ set objects {} ++ set i 0 ++ foreach {s local_options} $args { ++ if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } { ++ untested $testname ++ return -1 ++ } ++ lappend objects "${binfile}${i}.o" ++ incr i ++ } ++ set ret [$func $objects "${binfile}" executable $options] ++ } ++ if { $ret != "" } { ++ untested $testname ++ return -1 ++ } ++ + return 0 + } + +Index: gdb-7.6/gdb/testsuite/lib/prelink-support.exp +=================================================================== +--- gdb-7.6.orig/gdb/testsuite/lib/prelink-support.exp 2013-06-10 14:29:24.819123940 +0200 ++++ gdb-7.6/gdb/testsuite/lib/prelink-support.exp 2013-06-10 14:30:18.089102374 +0200 +@@ -95,8 +95,9 @@ proc file_copy {src dest} { + # Wrap function build_executable so that the resulting executable is fully + # self-sufficient (without dependencies on system libraries). Parameter + # INTERP may be used to specify a loader (ld.so) to be used that is +-# different from the default system one. Libraries on which the executable +-# depends are copied into directory DIR. Default DIR value to ++# different from the default system one. INTERP can be set to "no" if no ld.so ++# copy should be made. Libraries on which the executable depends are copied ++# into directory DIR. Default DIR value to + # `${objdir}/${subdir}/${EXECUTABLE}.d'. + # + # In case of success, return a string containing the arguments to be used +@@ -151,8 +152,15 @@ proc build_executable_own_libs {testname + + if {$interp == ""} { + set interp_system [section_get $binfile .interp] +- set interp ${dir}/[file tail $interp_system] +- file_copy $interp_system $interp ++ if {$interp_system == ""} { ++ fail "$test could not find .interp" ++ } else { ++ set interp ${dir}/[file tail $interp_system] ++ file_copy $interp_system $interp ++ } ++ } ++ if {$interp == "no"} { ++ set interp "" + } + + set dests {} +@@ -164,13 +172,19 @@ proc build_executable_own_libs {testname + + # Do not lappend it so that "-rpath $dir" overrides any possible "-rpath"s + # specified by the caller to be able to link it for ldd" above. +- set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp,-rpath,$dir"] ++ set options [linsert $options 0 "ldflags=-Wl,-rpath,$dir"] ++ if {$interp != ""} { ++ set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp"] ++ } + + if {[build_executable $testname $executable $sources $options] == -1} { + return "" + } + +- set prelink_args "--dynamic-linker=$interp --ld-library-path=$dir $binfile $interp [concat $dests]" ++ set prelink_args "--ld-library-path=$dir $binfile [concat $dests]" ++ if {$interp != ""} { ++ set prelink_args "--dynamic-linker=$interp $prelink_args $interp" ++ } + return $prelink_args + } + diff --git a/gdb-dlopen-stap-probe-9of9.patch b/gdb-dlopen-stap-probe-9of9.patch new file mode 100644 index 0000000..c2bb897 --- /dev/null +++ b/gdb-dlopen-stap-probe-9of9.patch @@ -0,0 +1,415 @@ +http://sourceware.org/ml/gdb-cvs/2013-06/msg00020.html + +### src/gdb/testsuite/ChangeLog 2013/06/04 13:23:31 1.3683 +### src/gdb/testsuite/ChangeLog 2013/06/04 13:31:00 1.3684 +## -1,3 +1,13 @@ ++2013-06-04 Gary Benson ++ ++ * gdb.base/break-probes.exp: New file. ++ * gdb.base/break-probes.c: Likewise. ++ * gdb.base/break-probes-solib.c: Likewise. ++ * gdb.base/info-shared.exp: New file. ++ * gdb.base/info-shared.c: Likewise. ++ * gdb.base/info-shared-solib1.c: Likewise. ++ * gdb.base/info-shared-solib2.c: Likewise. ++ + 2013-06-04 Jan Kratochvil + Gary Benson + +--- src/gdb/testsuite/gdb.base/break-probes-solib.c ++++ src/gdb/testsuite/gdb.base/break-probes-solib.c 2013-06-10 12:15:11.548935413 +0000 +@@ -0,0 +1,22 @@ ++/* Copyright 2012-2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++ ++int ++foo (int n) ++{ ++ return n * n / 17; ++} +--- src/gdb/testsuite/gdb.base/break-probes.c ++++ src/gdb/testsuite/gdb.base/break-probes.c 2013-06-10 12:15:12.047717383 +0000 +@@ -0,0 +1,30 @@ ++/* Copyright 2012-2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++#include ++#include ++ ++int ++main (void) ++{ ++ void *handle = dlopen (SHLIB_NAME, RTLD_LAZY); ++ ++ assert (handle != NULL); ++ ++ dlclose (handle); ++ ++ return 0; ++} +--- src/gdb/testsuite/gdb.base/break-probes.exp ++++ src/gdb/testsuite/gdb.base/break-probes.exp 2013-06-10 12:15:12.620368040 +0000 +@@ -0,0 +1,78 @@ ++# Copyright 2012-2013 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { [skip_shlib_tests] } { ++ return 0 ++} ++ ++standard_testfile ++ ++set libname $testfile-solib ++set srcfile_lib $srcdir/$subdir/$libname.c ++set binfile_lib [standard_output_file $libname.so] ++ ++set normal_bp "_dl_debug_state" ++set probes_bp "dl_main" ++ ++if { [gdb_compile_shlib $srcfile_lib $binfile_lib \ ++ [list additional_flags=-fPIC]] != "" } { ++ untested "Could not compile $binfile_lib." ++ return -1 ++} ++ ++if { [prepare_for_testing $testfile.exp $testfile $srcfile \ ++ [list additional_flags=-DSHLIB_NAME=\"$binfile_lib\" libs=-ldl]] } { ++ return -1 ++} ++ ++# Enable stop-on-solib-events ++gdb_test_no_output "set stop-on-solib-events 1" ++ ++# Start the inferior and run to the first stop ++gdb_run_cmd ++gdb_test "" ".*Stopped due to shared library event.*" ++ ++# XFAIL if we are not using probes ++set test "ensure using probes" ++set using_probes 0 ++gdb_test_multiple "bt" $test { ++ -re "#0 +\[^\r\n\]*\\m(__GI_)?$normal_bp\\M.*$gdb_prompt $" { ++ untested "probes not present on this system" ++ } ++ -re "#0 +\[^\r\n\]*\\m(__GI_)?$probes_bp\\M.*$gdb_prompt $" { ++ pass $test ++ set using_probes 1 ++ } ++} ++ ++if { $using_probes } { ++ # Run til it loads our library ++ set test "run til our library loads" ++ set not_loaded_library 1 ++ while { $not_loaded_library } { ++ set not_loaded_library 0 ++ gdb_test_multiple "c" $test { ++ -re "Inferior loaded $binfile_lib\\M.*$gdb_prompt $" { ++ pass $test ++ } ++ -re "Stopped due to shared library event\\M.*$gdb_prompt $" { ++ set not_loaded_library 1 ++ } ++ } ++ } ++ ++ # Call something to ensure that relocation occurred ++ gdb_test "call foo(23)" "\\\$.* = 31.*\\\M.*" ++} +--- src/gdb/testsuite/gdb.base/info-shared-solib1.c ++++ src/gdb/testsuite/gdb.base/info-shared-solib1.c 2013-06-10 12:15:14.399129288 +0000 +@@ -0,0 +1,24 @@ ++/* Copyright 2012-2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++ ++int ++foo (int n) ++{ ++ printf ("foo %d\n", n); ++ ++ return 0; ++} +--- src/gdb/testsuite/gdb.base/info-shared-solib2.c ++++ src/gdb/testsuite/gdb.base/info-shared-solib2.c 2013-06-10 12:15:14.930135742 +0000 +@@ -0,0 +1,24 @@ ++/* Copyright 2012-2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++ ++int ++bar (int n) ++{ ++ printf ("bar %d\n", n); ++ ++ return 0; ++} +--- src/gdb/testsuite/gdb.base/info-shared.c ++++ src/gdb/testsuite/gdb.base/info-shared.c 2013-06-10 12:15:15.395474819 +0000 +@@ -0,0 +1,52 @@ ++/* Copyright 2012-2013 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include ++#include ++#include ++ ++void ++stop (void) ++{ ++} ++ ++int ++main (void) ++{ ++ void *handle1, *handle2; ++ void (*func)(int); ++ ++ handle1 = dlopen (SHLIB1_NAME, RTLD_LAZY); ++ assert (handle1 != NULL); ++ stop (); ++ ++ handle2 = dlopen (SHLIB2_NAME, RTLD_LAZY); ++ assert (handle2 != NULL); ++ stop (); ++ ++ func = (void (*)(int)) dlsym (handle1, "foo"); ++ func (1); ++ ++ func = (void (*)(int)) dlsym (handle2, "bar"); ++ func (2); ++ ++ dlclose (handle1); ++ stop (); ++ ++ dlclose (handle2); ++ stop (); ++ ++ return 0; ++} +--- src/gdb/testsuite/gdb.base/info-shared.exp ++++ src/gdb/testsuite/gdb.base/info-shared.exp 2013-06-10 12:15:15.891450285 +0000 +@@ -0,0 +1,146 @@ ++# Copyright 2012-2013 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if { [skip_shlib_tests] } { ++ return 0 ++} ++ ++standard_testfile ++ ++set lib1name $testfile-solib1 ++set srcfile_lib1 $srcdir/$subdir/$lib1name.c ++set binfile_lib1 [standard_output_file $lib1name.so] ++set define1 -DSHLIB1_NAME=\"$binfile_lib1\" ++ ++set lib2name $testfile-solib2 ++set srcfile_lib2 $srcdir/$subdir/$lib2name.c ++set binfile_lib2 [standard_output_file $lib2name.so] ++set define2 -DSHLIB2_NAME=\"$binfile_lib2\" ++ ++if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \ ++ [list additional_flags=-fPIC]] != "" } { ++ untested "Could not compile $binfile_lib1." ++ return -1 ++} ++ ++if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \ ++ [list additional_flags=-fPIC]] != "" } { ++ untested "Could not compile $binfile_lib2." ++ return -1 ++} ++ ++set cflags "$define1 $define2" ++if { [prepare_for_testing $testfile.exp $testfile $srcfile \ ++ [list additional_flags=$cflags libs=-ldl]] } { ++ return -1 ++} ++ ++# Run "info sharedlibrary" and check for the presence or absence of ++# our libraries. ++proc check_info_shared { test expect1 expect2 } { ++ global lib1name ++ global lib2name ++ global gdb_prompt ++ ++ set actual1 0 ++ set actual2 0 ++ ++ gdb_test_multiple "info sharedlibrary" $test { ++ -re $lib1name { ++ set actual1 1 ++ exp_continue ++ } ++ -re $lib2name { ++ set actual2 1 ++ exp_continue ++ } ++ -re "\r\n$gdb_prompt $" { ++ if { $actual1 == $expect1 && $actual2 == $expect2 } { ++ pass $test ++ } else { ++ fail $test ++ } ++ } ++ } ++} ++ ++# Start the inferior, and check neither of the libraries are loaded at ++# the start. ++if ![runto_main] { ++ return 0 ++} ++check_info_shared "info sharedlibrary #1" 0 0 ++ ++# Set up breakpoints. ++gdb_breakpoint "stop" ++gdb_breakpoint "foo" allow-pending ++gdb_breakpoint "bar" allow-pending ++ ++# Run to the first stop and check that only the first library is loaded. ++gdb_continue_to_breakpoint "library load #1" "stop .*" ++check_info_shared "info sharedlibrary #2" 1 0 ++ ++# Run to the second stop and check that both libraries are loaded. ++gdb_continue_to_breakpoint "library load #2" "stop .*" ++check_info_shared "info sharedlibrary #3" 1 1 ++ ++# Check that the next stop is in foo. ++gdb_continue_to_breakpoint "library function #1" "foo .*" ++ ++# Check that the next stop is in bar. ++gdb_continue_to_breakpoint "library function #2" "bar .*" ++ ++# Restart the inferior and make sure there are no breakpoint reset ++# errors. These can happen with the probes-based runtime linker ++# interface if the cache is not cleared correctly. ++set test "restart" ++gdb_run_cmd ++gdb_test_multiple "" $test { ++ -re {Start it from the beginning\? \(y or n\) $} { ++ send_gdb "y\n" ++ exp_continue ++ } ++ -re {Error in re-setting breakpoint} { ++ fail $test ++ } ++ -re "\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++# Check that neither library is loaded. ++check_info_shared "info sharedlibrary #4" 0 0 ++ ++# Run to the first stop and check that only the first library is loaded. ++gdb_continue_to_breakpoint "library load #3" "stop .*" ++check_info_shared "info sharedlibrary #5" 1 0 ++ ++# Run to the second stop and check that both libraries are loaded. ++gdb_continue_to_breakpoint "library load #4" "stop .*" ++check_info_shared "info sharedlibrary #6" 1 1 ++ ++# Check that the next stop is in foo. ++gdb_continue_to_breakpoint "library function #3" "foo .*" ++ ++# Check that the next stop is in bar. ++gdb_continue_to_breakpoint "library function #4" "bar .*" ++ ++# Run to the next stop and check that the first library has been unloaded. ++gdb_continue_to_breakpoint "library unload #1" "stop .*" ++check_info_shared "info sharedlibrary #7" 0 1 ++ ++# Run to the last stop and check that both libraries are gone. ++gdb_continue_to_breakpoint "library unload #2" "stop .*" ++check_info_shared "info sharedlibrary #8" 0 0 diff --git a/gdb-dlopen-stap-probe-fixup.patch b/gdb-dlopen-stap-probe-fixup.patch deleted file mode 100644 index 30e18c1..0000000 --- a/gdb-dlopen-stap-probe-fixup.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- gdb-7.6-x/gdb/solib-svr4.c 2013-05-19 16:04:36.838874595 +0200 -+++ gdb-7.6/gdb/solib-svr4.c 2013-05-19 16:12:35.112514978 +0200 -@@ -1078,7 +1078,6 @@ svr4_free_library_list (void *p_list) - static struct so_list * - svr4_copy_library_list (struct so_list *src) - { -- struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); - struct so_list *dst = NULL; - struct so_list **link = &dst; - -@@ -1090,8 +1089,8 @@ svr4_copy_library_list (struct so_list * - - memcpy (new, src, sizeof (struct so_list)); - -- new->lm_info = xmalloc (lmo->link_map_size); -- memcpy (new->lm_info, src->lm_info, lmo->link_map_size); -+ new->lm_info = xmalloc (sizeof (*new->lm_info)); -+ memcpy (new->lm_info, src->lm_info, sizeof (*new->lm_info)); - - new->next = NULL; - *link = new; -@@ -1747,7 +1746,7 @@ solist_update_incremental (struct svr4_i - struct svr4_library_list library_list; - char annex[64]; - -- xsnprintf (annex, sizeof (annex), "start=%lx;prev=%lx", lm, prev_lm); -+ xsnprintf (annex, sizeof (annex), "start=%lx;prev=%lx", (unsigned long) lm, (unsigned long) prev_lm); - if (!svr4_current_sos_via_xfer_libraries (&library_list, annex)) - return 0; - -@@ -1813,7 +1812,10 @@ svr4_handle_solib_event (void) - goto error; - - if (action == DO_NOTHING) -+{ -+do_cleanups (old_chain); - return; -+} - - /* EVALUATE_PROBE_ARGUMENT looks up symbols in the dynamic linker - using FIND_PC_SECTION. FIND_PC_SECTION is accelerated by a cache ---- gdb-7.6-x/gdb/testsuite/gdb.base/break-probes.exp 2013-05-19 16:06:19.452818090 +0200 -+++ gdb-7.6/gdb/testsuite/gdb.base/break-probes.exp 2013-05-19 16:07:49.730770135 +0200 -@@ -60,14 +60,15 @@ gdb_test_multiple "bt" $test { - if { $using_probes } { - # Run til it loads our library - set test "run til our library loads" -- set loaded_library 0 -- while { !$loaded_library } { -+ set not_loaded_library 1 -+ while { $not_loaded_library } { -+ set not_loaded_library 0 - gdb_test_multiple "c" $test { - -re "Inferior loaded $binfile_lib\\M.*$gdb_prompt $" { - pass $test -- set loaded_library 1 - } - -re "Stopped due to shared library event\\M.*$gdb_prompt $" { -+ set not_loaded_library 1 - } - } - } diff --git a/gdb-upstream-framefilters-1of2.patch b/gdb-upstream-framefilters-1of2.patch index d0ab188..80a0d43 100644 --- a/gdb-upstream-framefilters-1of2.patch +++ b/gdb-upstream-framefilters-1of2.patch @@ -57,8 +57,8 @@ http://sourceware.org/ml/gdb-cvs/2013-05/msg00084.html * symfile.c (syms_from_objfile_1): Delete args offsets, num_offsets. Index: gdb-7.6/gdb/Makefile.in =================================================================== ---- gdb-7.6.orig/gdb/Makefile.in 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/Makefile.in 2013-05-20 22:25:52.096165773 +0200 +--- gdb-7.6.orig/gdb/Makefile.in 2013-06-10 14:31:02.704084663 +0200 ++++ gdb-7.6/gdb/Makefile.in 2013-06-10 14:31:08.351082443 +0200 @@ -284,6 +284,7 @@ SUBDIR_PYTHON_OBS = \ py-exitedevent.o \ py-finishbreakpoint.o \ @@ -75,7 +75,7 @@ Index: gdb-7.6/gdb/Makefile.in python/py-function.c \ python/py-gdb-readline.c \ python/py-inferior.c \ -@@ -2135,6 +2137,10 @@ py-frame.o: $(srcdir)/python/py-frame.c +@@ -2174,6 +2176,10 @@ py-frame.o: $(srcdir)/python/py-frame.c $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-frame.c $(POSTCOMPILE) @@ -88,8 +88,8 @@ Index: gdb-7.6/gdb/Makefile.in $(POSTCOMPILE) Index: gdb-7.6/gdb/NEWS =================================================================== ---- gdb-7.6.orig/gdb/NEWS 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/NEWS 2013-05-20 22:25:52.097165772 +0200 +--- gdb-7.6.orig/gdb/NEWS 2013-06-10 14:31:08.353082442 +0200 ++++ gdb-7.6/gdb/NEWS 2013-06-10 14:31:21.230077319 +0200 @@ -4,6 +4,10 @@ * Newly installed $prefix/bin/gcore acts as a shell interface for the GDB command gcore. @@ -98,13 +98,13 @@ Index: gdb-7.6/gdb/NEWS + + ** Frame filters and frame decorators have been added. + - *** Changes in GDB 7.6 + * New remote packets - * Target record has been renamed to record-full. + qXfer:libraries-svr4:read's annex Index: gdb-7.6/gdb/stack.c =================================================================== ---- gdb-7.6.orig/gdb/stack.c 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/stack.c 2013-05-20 22:25:52.098165772 +0200 +--- gdb-7.6.orig/gdb/stack.c 2013-06-10 14:31:02.709084661 +0200 ++++ gdb-7.6/gdb/stack.c 2013-06-10 14:31:08.354082441 +0200 @@ -54,6 +54,7 @@ #include "psymtab.h" @@ -329,8 +329,8 @@ Index: gdb-7.6/gdb/stack.c { Index: gdb-7.6/gdb/data-directory/Makefile.in =================================================================== ---- gdb-7.6.orig/gdb/data-directory/Makefile.in 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/data-directory/Makefile.in 2013-05-20 22:25:52.098165772 +0200 +--- gdb-7.6.orig/gdb/data-directory/Makefile.in 2013-06-10 14:31:02.710084660 +0200 ++++ gdb-7.6/gdb/data-directory/Makefile.in 2013-06-10 14:31:08.355082441 +0200 @@ -53,7 +53,11 @@ PYTHON_DIR = python PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR) PYTHON_FILES = \ @@ -345,9 +345,9 @@ Index: gdb-7.6/gdb/data-directory/Makefile.in gdb/command/type_printers.py \ Index: gdb-7.6/gdb/doc/gdb.texinfo =================================================================== ---- gdb-7.6.orig/gdb/doc/gdb.texinfo 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/doc/gdb.texinfo 2013-05-20 22:25:52.110165767 +0200 -@@ -6453,6 +6453,7 @@ currently executing frame and describes +--- gdb-7.6.orig/gdb/doc/gdb.texinfo 2013-06-10 14:31:02.727084654 +0200 ++++ gdb-7.6/gdb/doc/gdb.texinfo 2013-06-10 14:31:08.364082438 +0200 +@@ -6459,6 +6459,7 @@ currently executing frame and describes @menu * Frames:: Stack frames * Backtrace:: Backtraces @@ -355,7 +355,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo * Selection:: Selecting a frame * Frame Info:: Information on a frame -@@ -6540,6 +6541,7 @@ line per frame, for many frames, startin +@@ -6546,6 +6547,7 @@ line per frame, for many frames, startin frame (frame zero), followed by its caller (frame one), and on up the stack. @@ -363,7 +363,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @table @code @kindex backtrace @kindex bt @r{(@code{backtrace})} -@@ -6565,6 +6567,19 @@ Similar, but print only the outermost @v +@@ -6571,6 +6573,19 @@ Similar, but print only the outermost @v @itemx bt full -@var{n} Print the values of the local variables also. @var{n} specifies the number of frames to print, as described above. @@ -383,7 +383,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @end table @kindex where -@@ -6714,6 +6729,149 @@ Display an absolute filename. +@@ -6720,6 +6735,149 @@ Display an absolute filename. Show the current way to display filenames. @end table @@ -533,7 +533,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @node Selection @section Selecting a Frame -@@ -23065,6 +23223,9 @@ situation, a Python @code{KeyboardInterr +@@ -23100,6 +23258,9 @@ situation, a Python @code{KeyboardInterr * Selecting Pretty-Printers:: How GDB chooses a pretty-printer. * Writing a Pretty-Printer:: Writing a Pretty-Printer. * Type Printing API:: Pretty-printing types. @@ -543,7 +543,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo * Inferiors In Python:: Python representation of inferiors (processes) * Events In Python:: Listening for events from @value{GDBN}. * Threads In Python:: Accessing inferior threads from Python. -@@ -24415,6 +24576,636 @@ done then type printers would have to ma +@@ -24450,6 +24611,636 @@ done then type printers would have to ma order to avoid holding information that could become stale as the inferior changed. @@ -1180,7 +1180,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @node Inferiors In Python @subsubsection Inferiors In Python @cindex inferiors in Python -@@ -25245,6 +26036,11 @@ The @code{type_printers} attribute is a +@@ -25280,6 +26071,11 @@ The @code{type_printers} attribute is a @xref{Type Printing API}, for more information. @end defvar @@ -1192,7 +1192,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @node Objfiles In Python @subsubsection Objfiles In Python -@@ -25295,6 +26091,11 @@ The @code{type_printers} attribute is a +@@ -25330,6 +26126,11 @@ The @code{type_printers} attribute is a @xref{Type Printing API}, for more information. @end defvar @@ -1204,7 +1204,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo A @code{gdb.Objfile} object has the following methods: @defun Objfile.is_valid () -@@ -26313,7 +27114,7 @@ No my-foo-pretty-printers.py +@@ -26348,7 +27149,7 @@ No my-foo-pretty-printers.py When reading an auto-loaded file, @value{GDBN} sets the @dfn{current objfile}. This is available via the @code{gdb.current_objfile} function (@pxref{Objfiles In Python}). This can be useful for @@ -1213,7 +1213,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @menu * objfile-gdb.py file:: The @file{@var{objfile}-gdb.py} file -@@ -30184,6 +30985,22 @@ Is this going away???? +@@ -30219,6 +31020,22 @@ Is this going away???? @node GDB/MI Stack Manipulation @section @sc{gdb/mi} Stack Manipulation Commands @@ -1236,7 +1236,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @subheading The @code{-stack-info-frame} Command @findex -stack-info-frame -@@ -30251,13 +31068,14 @@ For a stack with frame levels 0 through +@@ -30286,13 +31103,14 @@ For a stack with frame levels 0 through (gdb) @end smallexample @@ -1252,7 +1252,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo [ @var{low-frame} @var{high-frame} ] @end smallexample -@@ -30274,7 +31092,9 @@ If @var{print-values} is 0 or @code{--no +@@ -30309,7 +31127,9 @@ If @var{print-values} is 0 or @code{--no the variables; if it is 1 or @code{--all-values}, print also their values; and if it is 2 or @code{--simple-values}, print the name, type and value for simple data types, and the name and type for arrays, @@ -1263,7 +1263,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo Use of this command to obtain arguments in a single frame is deprecated in favor of the @samp{-stack-list-variables} command. -@@ -30345,13 +31165,14 @@ args=[@{name="intarg",value="2"@}, +@@ -30380,13 +31200,14 @@ args=[@{name="intarg",value="2"@}, @c @subheading -stack-list-exception-handlers @@ -1279,7 +1279,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @end smallexample List the frames currently on the stack. For each frame it displays the -@@ -30381,7 +31202,9 @@ levels are between the two arguments (in +@@ -30416,7 +31237,9 @@ levels are between the two arguments (in are equal, it shows the single frame at the corresponding level. It is an error if @var{low-frame} is larger than the actual number of frames. On the other hand, @var{high-frame} may be larger than the @@ -1290,7 +1290,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @subsubheading @value{GDBN} Command -@@ -30451,11 +31274,12 @@ Show a single frame: +@@ -30486,11 +31309,12 @@ Show a single frame: @subheading The @code{-stack-list-locals} Command @findex -stack-list-locals @@ -1304,7 +1304,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @end smallexample Display the local variable names for the selected frame. If -@@ -30466,7 +31290,8 @@ type and value for simple data types, an +@@ -30501,7 +31325,8 @@ type and value for simple data types, an structures and unions. In this last case, a frontend can immediately display the value of simple data types and create variable objects for other data types when the user wishes to explore their values in @@ -1314,7 +1314,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo This command is deprecated in favor of the @samp{-stack-list-variables} command. -@@ -30491,13 +31316,14 @@ This command is deprecated in favor of t +@@ -30526,13 +31351,14 @@ This command is deprecated in favor of t (gdb) @end smallexample @@ -1330,7 +1330,7 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo @end smallexample Display the names of local variables and function arguments for the selected frame. If -@@ -30505,7 +31331,8 @@ Display the names of local variables and +@@ -30540,7 +31366,8 @@ Display the names of local variables and the variables; if it is 1 or @code{--all-values}, print also their values; and if it is 2 or @code{--simple-values}, print the name, type and value for simple data types, and the name and type for arrays, @@ -1342,8 +1342,8 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo Index: gdb-7.6/gdb/mi/mi-cmd-stack.c =================================================================== ---- gdb-7.6.orig/gdb/mi/mi-cmd-stack.c 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/mi/mi-cmd-stack.c 2013-05-20 22:25:52.111165767 +0200 +--- gdb-7.6.orig/gdb/mi/mi-cmd-stack.c 2013-06-10 14:31:02.730084652 +0200 ++++ gdb-7.6/gdb/mi/mi-cmd-stack.c 2013-06-10 14:31:08.365082437 +0200 @@ -31,6 +31,10 @@ #include "language.h" #include "valprint.h" @@ -1655,8 +1655,8 @@ Index: gdb-7.6/gdb/mi/mi-cmd-stack.c /* Print single local or argument. ARG must be already read in. For Index: gdb-7.6/gdb/mi/mi-cmds.c =================================================================== ---- gdb-7.6.orig/gdb/mi/mi-cmds.c 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/mi/mi-cmds.c 2013-05-20 22:25:52.111165767 +0200 +--- gdb-7.6.orig/gdb/mi/mi-cmds.c 2013-06-10 14:31:02.730084652 +0200 ++++ gdb-7.6/gdb/mi/mi-cmds.c 2013-06-10 14:31:08.365082437 +0200 @@ -86,6 +86,7 @@ static struct mi_cmd mi_cmds[] = mi_cmd_data_write_register_values), DEF_MI_CMD_MI ("enable-timings", mi_cmd_enable_timings), @@ -1667,8 +1667,8 @@ Index: gdb-7.6/gdb/mi/mi-cmds.c DEF_MI_CMD_MI ("environment-path", mi_cmd_env_path), Index: gdb-7.6/gdb/mi/mi-cmds.h =================================================================== ---- gdb-7.6.orig/gdb/mi/mi-cmds.h 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/mi/mi-cmds.h 2013-05-20 22:25:52.111165767 +0200 +--- gdb-7.6.orig/gdb/mi/mi-cmds.h 2013-06-10 14:31:02.730084652 +0200 ++++ gdb-7.6/gdb/mi/mi-cmds.h 2013-06-10 14:31:08.365082437 +0200 @@ -118,6 +118,7 @@ extern mi_cmd_argv_ftype mi_cmd_var_show extern mi_cmd_argv_ftype mi_cmd_var_show_format; extern mi_cmd_argv_ftype mi_cmd_var_update; @@ -1680,7 +1680,7 @@ Index: gdb-7.6/gdb/mi/mi-cmds.h Index: gdb-7.6/gdb/python/py-framefilter.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/python/py-framefilter.c 2013-05-20 22:26:53.029143068 +0200 ++++ gdb-7.6/gdb/python/py-framefilter.c 2013-06-10 14:31:08.366082437 +0200 @@ -0,0 +1,1528 @@ +/* Python frame filters + @@ -3212,8 +3212,8 @@ Index: gdb-7.6/gdb/python/py-framefilter.c +} Index: gdb-7.6/gdb/python/py-objfile.c =================================================================== ---- gdb-7.6.orig/gdb/python/py-objfile.c 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/python/py-objfile.c 2013-05-20 22:25:52.112165767 +0200 +--- gdb-7.6.orig/gdb/python/py-objfile.c 2013-06-10 14:31:02.731084652 +0200 ++++ gdb-7.6/gdb/python/py-objfile.c 2013-06-10 14:31:08.366082437 +0200 @@ -33,6 +33,8 @@ typedef struct /* The pretty-printer list of functions. */ PyObject *printers; @@ -3318,8 +3318,8 @@ Index: gdb-7.6/gdb/python/py-objfile.c { NULL } Index: gdb-7.6/gdb/python/py-progspace.c =================================================================== ---- gdb-7.6.orig/gdb/python/py-progspace.c 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/python/py-progspace.c 2013-05-20 22:25:52.112165767 +0200 +--- gdb-7.6.orig/gdb/python/py-progspace.c 2013-06-10 14:31:02.731084652 +0200 ++++ gdb-7.6/gdb/python/py-progspace.c 2013-06-10 14:31:08.366082437 +0200 @@ -35,6 +35,8 @@ typedef struct /* The pretty-printer list of functions. */ PyObject *printers; @@ -3424,8 +3424,8 @@ Index: gdb-7.6/gdb/python/py-progspace.c { NULL } Index: gdb-7.6/gdb/python/py-utils.c =================================================================== ---- gdb-7.6.orig/gdb/python/py-utils.c 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/python/py-utils.c 2013-05-20 22:25:52.113165766 +0200 +--- gdb-7.6.orig/gdb/python/py-utils.c 2013-06-10 14:31:02.732084652 +0200 ++++ gdb-7.6/gdb/python/py-utils.c 2013-06-10 14:31:08.366082437 +0200 @@ -48,6 +48,28 @@ make_cleanup_py_decref (PyObject *py) return make_cleanup (py_decref, (void *) py); } @@ -3457,8 +3457,8 @@ Index: gdb-7.6/gdb/python/py-utils.c returns NULL with a python exception set. Index: gdb-7.6/gdb/python/python-internal.h =================================================================== ---- gdb-7.6.orig/gdb/python/python-internal.h 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/python/python-internal.h 2013-05-20 22:25:52.113165766 +0200 +--- gdb-7.6.orig/gdb/python/python-internal.h 2013-06-10 14:31:02.732084652 +0200 ++++ gdb-7.6/gdb/python/python-internal.h 2013-06-10 14:31:08.367082436 +0200 @@ -251,9 +251,11 @@ PyObject *frame_info_to_frame_object (st PyObject *pspace_to_pspace_object (struct program_space *); @@ -3481,8 +3481,8 @@ Index: gdb-7.6/gdb/python/python-internal.h const struct language_defn *language); Index: gdb-7.6/gdb/python/python.c =================================================================== ---- gdb-7.6.orig/gdb/python/python.c 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/python/python.c 2013-05-20 22:25:52.113165766 +0200 +--- gdb-7.6.orig/gdb/python/python.c 2013-06-10 14:31:02.732084652 +0200 ++++ gdb-7.6/gdb/python/python.c 2013-06-10 14:31:08.367082436 +0200 @@ -1442,6 +1442,15 @@ free_type_printers (void *arg) { } @@ -3501,8 +3501,8 @@ Index: gdb-7.6/gdb/python/python.c Index: gdb-7.6/gdb/python/python.h =================================================================== ---- gdb-7.6.orig/gdb/python/python.h 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/python/python.h 2013-05-20 22:25:52.113165766 +0200 +--- gdb-7.6.orig/gdb/python/python.h 2013-06-10 14:31:02.732084652 +0200 ++++ gdb-7.6/gdb/python/python.h 2013-06-10 14:31:08.367082436 +0200 @@ -21,6 +21,7 @@ #define GDB_PYTHON_H @@ -3593,7 +3593,7 @@ Index: gdb-7.6/gdb/python/python.h Index: gdb-7.6/gdb/python/lib/gdb/FrameDecorator.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/python/lib/gdb/FrameDecorator.py 2013-05-20 22:25:52.113165766 +0200 ++++ gdb-7.6/gdb/python/lib/gdb/FrameDecorator.py 2013-06-10 14:31:08.367082436 +0200 @@ -0,0 +1,285 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + @@ -3883,7 +3883,7 @@ Index: gdb-7.6/gdb/python/lib/gdb/FrameDecorator.py Index: gdb-7.6/gdb/python/lib/gdb/FrameIterator.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/python/lib/gdb/FrameIterator.py 2013-05-20 22:25:52.114165766 +0200 ++++ gdb-7.6/gdb/python/lib/gdb/FrameIterator.py 2013-06-10 14:31:08.367082436 +0200 @@ -0,0 +1,45 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + @@ -3933,7 +3933,7 @@ Index: gdb-7.6/gdb/python/lib/gdb/FrameIterator.py Index: gdb-7.6/gdb/python/lib/gdb/frames.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/python/lib/gdb/frames.py 2013-05-20 22:25:52.114165766 +0200 ++++ gdb-7.6/gdb/python/lib/gdb/frames.py 2013-06-10 14:31:08.368082436 +0200 @@ -0,0 +1,229 @@ +# Frame-filter commands. +# Copyright (C) 2013 Free Software Foundation, Inc. @@ -4166,8 +4166,8 @@ Index: gdb-7.6/gdb/python/lib/gdb/frames.py + return sliced Index: gdb-7.6/gdb/python/lib/gdb/__init__.py =================================================================== ---- gdb-7.6.orig/gdb/python/lib/gdb/__init__.py 2013-05-20 22:23:36.748215146 +0200 -+++ gdb-7.6/gdb/python/lib/gdb/__init__.py 2013-05-20 22:25:52.114165766 +0200 +--- gdb-7.6.orig/gdb/python/lib/gdb/__init__.py 2013-06-10 14:31:02.733084651 +0200 ++++ gdb-7.6/gdb/python/lib/gdb/__init__.py 2013-06-10 14:31:08.368082436 +0200 @@ -67,6 +67,8 @@ pretty_printers = [] # Initial type printers. @@ -4180,7 +4180,7 @@ Index: gdb-7.6/gdb/python/lib/gdb/__init__.py Index: gdb-7.6/gdb/python/lib/gdb/command/frame_filters.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/python/lib/gdb/command/frame_filters.py 2013-05-20 22:25:52.114165766 +0200 ++++ gdb-7.6/gdb/python/lib/gdb/command/frame_filters.py 2013-06-10 14:31:08.368082436 +0200 @@ -0,0 +1,461 @@ +# Frame-filter commands. +# Copyright (C) 2013 Free Software Foundation, Inc. @@ -4646,7 +4646,7 @@ Index: gdb-7.6/gdb/python/lib/gdb/command/frame_filters.py Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-gdb.py.in =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-gdb.py.in 2013-05-20 22:25:52.114165766 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-gdb.py.in 2013-06-10 14:31:08.368082436 +0200 @@ -0,0 +1,48 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + @@ -4699,7 +4699,7 @@ Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-gdb.py.in Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.c 2013-05-20 22:25:52.114165766 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.c 2013-06-10 14:31:08.368082436 +0200 @@ -0,0 +1,138 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -4842,7 +4842,7 @@ Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.c Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.exp 2013-05-20 22:25:52.115165766 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.exp 2013-06-10 14:31:08.368082436 +0200 @@ -0,0 +1,179 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + @@ -5026,7 +5026,7 @@ Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter-mi.exp Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.c 2013-05-20 22:25:52.115165766 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.c 2013-06-10 14:31:08.369082436 +0200 @@ -0,0 +1,155 @@ +/* This testcase is part of GDB, the GNU debugger. + @@ -5186,7 +5186,7 @@ Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.c Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.exp 2013-05-20 22:25:52.115165766 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.exp 2013-06-10 14:31:08.369082436 +0200 @@ -0,0 +1,239 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + @@ -5430,7 +5430,7 @@ Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.exp Index: gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.py 2013-05-20 22:25:52.115165766 +0200 ++++ gdb-7.6/gdb/testsuite/gdb.python/py-framefilter.py 2013-06-10 14:31:08.369082436 +0200 @@ -0,0 +1,117 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + diff --git a/gdb.spec b/gdb.spec index 8a1d388..5e27ca2 100644 --- a/gdb.spec +++ b/gdb.spec @@ -36,7 +36,7 @@ Version: 7.6 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 31%{?dist} +Release: 32%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -508,15 +508,16 @@ Patch579: gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch # Fix dlopen of libpthread.so, patched glibc required (Gary Benson, BZ 669432). # Fix crash regression from the dlopen of libpthread.so fix (BZ 911712). # Fix performance regression when inferior opens many libraries (Gary Benson). -#=push -Patch718: gdb-dlopen-stap-probe-1of7.patch -Patch719: gdb-dlopen-stap-probe-2of7.patch -Patch720: gdb-dlopen-stap-probe-3of7.patch -Patch721: gdb-dlopen-stap-probe-4of7.patch -Patch722: gdb-dlopen-stap-probe-5of7.patch -Patch723: gdb-dlopen-stap-probe-6of7.patch -Patch822: gdb-dlopen-stap-probe-7of7.patch -Patch827: gdb-dlopen-stap-probe-fixup.patch +#=drop +Patch718: gdb-dlopen-stap-probe-1of9.patch +Patch719: gdb-dlopen-stap-probe-2of9.patch +Patch720: gdb-dlopen-stap-probe-3of9.patch +Patch721: gdb-dlopen-stap-probe-4of9.patch +Patch722: gdb-dlopen-stap-probe-5of9.patch +Patch723: gdb-dlopen-stap-probe-6of9.patch +Patch822: gdb-dlopen-stap-probe-7of9.patch +Patch827: gdb-dlopen-stap-probe-8of9.patch +Patch619: gdb-dlopen-stap-probe-9of9.patch # Work around PR libc/13097 "linux-vdso.so.1" warning message. #=push @@ -570,11 +571,18 @@ Patch818: gdb-rhbz795424-bitpos-lazyvalue.patch Patch832: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch # Fix gcore for vDSO (on ppc64). +#=drop Patch834: gdb-vdso-gcore.patch # Fix needless expansion of non-gdbindex symtabs (Doug Evans). +#=drop Patch835: gdb-psymtab-expand.patch +# Fix C++ lookups performance regression (Doug Evans, BZ 972677). +#=drop +Patch838: gdb-cxx-performance-1of2.patch +Patch839: gdb-cxx-performance-2of2.patch + %if 0%{!?rhel:1} || 0%{?rhel} > 6 # RL_STATE_FEDORA_GDB would not be found for: # Patch642: gdb-readline62-ask-more-rh.patch @@ -783,8 +791,6 @@ find -name "*.info*"|xargs rm -f %patch232 -p1 %patch828 -p1 %patch829 -p1 -%patch836 -p1 -%patch837 -p1 %patch1 -p1 %patch3 -p1 @@ -881,6 +887,7 @@ find -name "*.info*"|xargs rm -f %patch723 -p1 %patch822 -p1 %patch827 -p1 +%patch619 -p1 %patch627 -p1 %patch634 -p1 %patch653 -p1 @@ -899,7 +906,15 @@ find -name "*.info*"|xargs rm -f %patch832 -p1 %patch834 -p1 %patch835 -p1 +%patch838 -p1 +%patch839 -p1 +%patch836 -p1 +%patch837 -p1 +%if 0%{?scl:1} +%patch836 -p1 -R +%patch837 -p1 -R +%endif %patch393 -p1 %if 0%{!?el5:1} || 0%{?scl:1} %patch393 -p1 -R @@ -1402,6 +1417,11 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Mon Jun 10 2013 Jan Kratochvil - 7.6-32.fc19 +- [scl] Disable Python frame filters on scl. +- Update libraries opening performance fix from upstream. +- Fix C++ lookups performance regression (Doug Evans, BZ 972677). + * Tue May 28 2013 Jan Kratochvil - 7.6-31.fc19 - [ppc] Backport hardware watchpoints fix (Edjunior Machado, BZ 967915).