* [patch v4 2/3] Test adding and removing a symbol file at runtime.
2013-05-29 9:13 [patch v4 0/3] remove-symbol-file Nicolas Blanc
@ 2013-05-29 9:13 ` Nicolas Blanc
2013-05-29 9:48 ` Luis Machado
2013-05-29 9:13 ` [patch v4 1/3] Create remove-symbol-file command Nicolas Blanc
2013-05-29 9:13 ` [patch v4 3/3] Documentation for the " Nicolas Blanc
2 siblings, 1 reply; 11+ messages in thread
From: Nicolas Blanc @ 2013-05-29 9:13 UTC (permalink / raw)
To: gdb-patches, palves, tromey, eliz, yao; +Cc: nicolas.blanc
This test exercises the commands 'add-symbol-file'
and 'remove-symbol-file'.
2013-04-04 Nicolas Blanc <nicolas.blanc@intel.com>
gdb/testsuite
* gdb.base/sym-file-lib.c: New file.
* gdb.base/sym-file-lib.c: New file.
* gdb.base/sym-file.exp: New file.
Signed-off-by: Nicolas Blanc <nicolas.blanc@intel.com>
---
gdb/testsuite/gdb.base/sym-file-lib.c | 21 ++
gdb/testsuite/gdb.base/sym-file-main.c | 377 ++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.base/sym-file.exp | 160 ++++++++++++++
3 files changed, 558 insertions(+), 0 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/sym-file-lib.c
create mode 100644 gdb/testsuite/gdb.base/sym-file-main.c
create mode 100644 gdb/testsuite/gdb.base/sym-file.exp
diff --git a/gdb/testsuite/gdb.base/sym-file-lib.c b/gdb/testsuite/gdb.base/sym-file-lib.c
new file mode 100644
index 0000000..32426b9
--- /dev/null
+++ b/gdb/testsuite/gdb.base/sym-file-lib.c
@@ -0,0 +1,21 @@
+/* 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 <http://www.gnu.org/licenses/>.
+*/
+
+
+extern int bar () { return 1; } /* gdb break at bar */
+
+
+extern int foo (int a) { return a; } /* gdb break at foo */
+
diff --git a/gdb/testsuite/gdb.base/sym-file-main.c b/gdb/testsuite/gdb.base/sym-file-main.c
new file mode 100644
index 0000000..01adf2c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/sym-file-main.c
@@ -0,0 +1,377 @@
+/* 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 <http://www.gnu.org/licenses/>.
+*/
+
+#include <fcntl.h>
+#include </usr/include/elf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#ifdef TARGET_LP64
+typedef Elf64_Phdr Elf_Phdr;
+typedef Elf64_Ehdr Elf_Ehdr;
+typedef Elf64_Shdr Elf_Shdr;
+typedef Elf64_Sym Elf_Sym;
+typedef Elf64_Word Elf_Word;
+
+unsigned char inline elf_st_type (unsigned char st_info)
+{
+ return ELF64_ST_TYPE (st_info);
+}
+#elif defined TARGET_ILP32
+typedef Elf32_Phdr Elf_Phdr;
+typedef Elf32_Ehdr Elf_Ehdr;
+typedef Elf32_Shdr Elf_Shdr;
+typedef Elf32_Sym Elf_Sym;
+typedef Elf32_Word Elf_Word;
+
+unsigned char inline elf_st_type (unsigned char st_info)
+{
+ return ELF32_ST_TYPE (st_info);
+}
+#endif
+
+
+void gdb_add_symbol_file (void* addr, const char* file)
+{
+ return;
+}
+
+
+void gdb_remove_symbol_file (void* addr)
+{
+ return;
+}
+
+
+struct segment
+{
+ char* mapped_addr;
+ Elf_Phdr* phdr;
+ struct segment* next;
+};
+
+
+/* Load a program segment. */
+
+struct segment* load (char * addr, Elf_Phdr* phdr, struct segment* tail_seg)
+{
+ /* For the sake of simplicity all operations are permitted. */
+ unsigned perm = PROT_READ | PROT_WRITE | PROT_EXEC;
+
+ char* mapped_addr = (char*) mmap ((void*) phdr->p_vaddr,
+ phdr->p_memsz, perm,
+ MAP_ANONYMOUS | MAP_PRIVATE,
+ -1, 0);
+
+ void * from = (void*) (addr + phdr->p_offset);
+ void * to = (void*) mapped_addr;
+
+ memcpy (to, from, phdr->p_filesz);
+
+ struct segment* seg = (struct segment*) malloc (sizeof (struct segment));
+
+ if (seg == 0)
+ return 0;
+
+ seg->mapped_addr = mapped_addr;
+ seg->phdr = phdr;
+ seg->next = 0;
+
+ if (tail_seg != 0)
+ tail_seg->next = seg;
+
+ return seg;
+}
+
+/* Load a shared library without calling the standard loader. */
+
+int load_shlib (const char *file, Elf_Ehdr **ehdr_out, struct segment **seg_out)
+{
+ unsigned i = 0;
+
+ /* Map the lib in memory for reading. */
+ int fd = open (file, O_RDONLY);
+ if (fd < 0)
+ {
+ perror ("fopen failed.");
+ return -1;
+ }
+
+ off_t fsize = lseek (fd, 0, SEEK_END);
+
+ if (fsize < 0)
+ {
+ perror ("lseek failed.");
+ return -1;
+ }
+
+ char* addr = (char*) mmap (NULL, fsize, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (addr == (char*) -1)
+ {
+ perror ("mmap failed.");
+ return -1;
+ }
+
+ /* Check if the lib is an ELF file. */
+ Elf_Ehdr* ehdr = (Elf_Ehdr*) addr;
+ if (ehdr->e_ident[EI_MAG0] != ELFMAG0
+ || ehdr->e_ident[EI_MAG1] != ELFMAG1
+ || ehdr->e_ident[EI_MAG2] != ELFMAG2
+ || ehdr->e_ident[EI_MAG3] != ELFMAG3)
+ {
+ printf ("Not an ELF file: %x\n", ehdr->e_ident[EI_MAG0]);
+ return -1;
+ }
+
+ if (ehdr->e_ident[EI_CLASS] == ELFCLASS32)
+ {
+ if (sizeof (int*) != 4)
+ {
+ printf ("Architecture mismatch.");
+ return -1;
+ }
+ }
+ else if (ehdr->e_ident[EI_CLASS] == ELFCLASS64)
+ {
+ if (sizeof (int*) != 8)
+ {
+ printf ("Architecture mismatch.");
+ return -1;
+ }
+ }
+
+
+ /* Load the program segments. For the sake of simplicity
+ assume that no reallocation is needed. */
+ Elf_Phdr* phdr = (Elf_Phdr*) (addr + ehdr->e_phoff);
+ struct segment* head_seg = 0;
+ struct segment* tail_seg = 0;
+ for (i=0; i < ehdr->e_phnum; i++, phdr++)
+ {
+ if (phdr->p_type == PT_LOAD)
+ {
+ struct segment* next_seg = load (addr, phdr, tail_seg);
+ if (next_seg == 0)
+ continue;
+ tail_seg = next_seg;
+ if (head_seg == 0)
+ head_seg = next_seg;
+ }
+ }
+ *ehdr_out = ehdr;
+ *seg_out = head_seg;
+ return 0;
+}
+
+
+/* Return the section-header table. */
+
+Elf_Shdr* find_shdrtab (Elf_Ehdr *ehdr)
+{
+ return (Elf_Shdr*) (((char*) ehdr) + ehdr->e_shoff);
+}
+
+
+/* Return the string table of the section headers. */
+
+const char* find_shstrtab (Elf_Ehdr *ehdr, unsigned *size)
+{
+ const Elf_Shdr *shdr = find_shdrtab (ehdr);
+
+ if (ehdr->e_shnum <= ehdr->e_shstrndx)
+ {
+ printf ("The index of the string table is corrupt.");
+ return NULL;
+ }
+ const Elf_Shdr* shstr = &shdr[ehdr->e_shstrndx];
+ *size = shstr->sh_size;
+ return ((const char*) ehdr) + shstr->sh_offset;
+}
+
+
+/* Return the string table named SECTION. */
+
+const char* find_strtab (Elf_Ehdr *ehdr,
+ const char* shstrtab, unsigned shstrtab_size,
+ const char* section, unsigned *strtab_size)
+{
+ const Elf_Shdr* shdr = find_shdrtab (ehdr);
+ unsigned i = 0;
+ for (i=0; i < ehdr->e_shnum; i++)
+ {
+ Elf_Word name = shdr[i].sh_name;
+ if (shdr[i].sh_type == SHT_STRTAB && name <= shstrtab_size
+ && strcmp ((const char*) &shstrtab[name], section) == 0)
+ {
+ *strtab_size = shdr[i].sh_size;
+ return ((const char*) ehdr) + shdr[i].sh_offset;
+ }
+
+ }
+ return NULL;
+}
+
+
+/* Return the section header named SECTION. */
+
+Elf_Shdr* find_shdr (Elf_Ehdr* ehdr, const char *section,
+ const char *shstrtab, unsigned shstrtab_size)
+{
+ Elf_Shdr *shdr = find_shdrtab (ehdr);
+ unsigned i = 0;
+ for (i=0; i < ehdr->e_shnum; i++)
+ {
+ Elf_Word name = shdr[i].sh_name;
+ if (name <= shstrtab_size)
+ {
+ if (strcmp ((const char*) &shstrtab[name], section) == 0)
+ return &shdr[i];
+ }
+
+ }
+ return NULL;
+}
+
+/* Return the symbol table. */
+
+Elf_Sym* find_symtab (Elf_Ehdr* ehdr, unsigned *symtab_size)
+{
+ unsigned i = 0;
+ const Elf_Shdr *shdr = find_shdrtab (ehdr);
+ for (i=0; i < ehdr->e_shnum; i++)
+ {
+ if (shdr[i].sh_type == SHT_SYMTAB)
+ {
+ *symtab_size = shdr[i].sh_size / sizeof (Elf_Sym);
+ return (Elf_Sym*) (((const char*) ehdr) + shdr[i].sh_offset);
+ }
+ }
+ return NULL;
+}
+
+
+/* Lookup the offset of FUNC. */
+
+int lookup_function (const char *func,
+ Elf_Sym *symtab, unsigned symtab_size,
+ const char *strtab, unsigned strtab_size,
+ unsigned *offset)
+{
+ unsigned i = 0;
+ for (i=0; i < symtab_size; i++)
+ {
+ Elf_Sym* sym = &symtab[i];
+
+ if (elf_st_type (sym->st_info) != STT_FUNC)
+ continue;
+
+ if (sym->st_name < strtab_size)
+ {
+ const char* name = &strtab[sym->st_name];
+ if (strcmp (name, func) == 0)
+ {
+ *offset = (unsigned) sym->st_value;
+ return 0;
+ }
+ }
+ }
+
+ return -1;
+}
+
+
+int main (int argc, const char* argv[])
+{
+ /* Load a shared library without relying on the standard
+ loader to test GDB's commands for adding and removing
+ symbol files at runtime. */
+
+ const char *file = SHLIB_NAME;
+
+ Elf_Ehdr *ehdr = 0;
+ struct segment *head_seg = 0;
+
+ if (load_shlib (file, &ehdr, &head_seg) != 0)
+ return -1;
+
+ /* Get the string table for the section headers. */
+ unsigned shstrtab_size = 0;
+ const char* shstrtab = find_shstrtab (ehdr, &shstrtab_size);
+
+ if (shstrtab == NULL)
+ return -1;
+
+ /* Get the text section. */
+ Elf_Shdr* text = find_shdr (ehdr, ".text", shstrtab, shstrtab_size);
+ if (text == NULL)
+ return -1;
+
+ char* base_addr = head_seg->mapped_addr + text->sh_offset;
+
+ /* Notify GDB to add the symbol file. */
+ gdb_add_symbol_file (base_addr, file);
+
+ /* Get the string table for the symbols. */
+ unsigned strtab_size = 0;
+ const char* strtab = find_strtab (ehdr, shstrtab, shstrtab_size,
+ ".strtab", &strtab_size);
+ if (strtab == NULL)
+ {
+ printf (".strtab not found.");
+ return -1;
+ }
+
+ /* Get the symbol table. */
+ unsigned symtab_size = 0;
+ Elf_Sym* symtab = find_symtab (ehdr, &symtab_size);
+ if (symtab == NULL)
+ {
+ printf ("symtab not found.");
+ return -1;
+ }
+
+ /* Call BAR from SHLIB_NAME. */
+ unsigned bar_offset = 0;
+ if (lookup_function ("bar",
+ symtab, symtab_size,
+ strtab, strtab_size,
+ &bar_offset) != 0)
+ return -1;
+
+ int (*pbar) () = (int (*) ()) (head_seg->mapped_addr + bar_offset);
+
+ int value1 = (*pbar) ();
+
+
+ /* Call FOO from SHLIB_NAME. */
+ unsigned foo_offset = 0;
+ if (lookup_function ("foo",
+ symtab, symtab_size,
+ strtab, strtab_size,
+ &foo_offset) != 0)
+ return -1;
+
+ int (*pfoo) (int) = (int (*) (int)) (head_seg->mapped_addr + foo_offset);
+
+ int value2 = (*pfoo) (2);
+
+ /* Notify GDB to remove the symbol file. */
+ gdb_remove_symbol_file (base_addr);
+
+ return 0;
+}
+
diff --git a/gdb/testsuite/gdb.base/sym-file.exp b/gdb/testsuite/gdb.base/sym-file.exp
new file mode 100644
index 0000000..88392c6
--- /dev/null
+++ b/gdb/testsuite/gdb.base/sym-file.exp
@@ -0,0 +1,160 @@
+# 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 <http://www.gnu.org/licenses/>. */
+
+
+# Test adding and removing a symbol file dynamically:
+# 1) Load the main executable.
+# 2) Run to GDB_ADD_SYMBOl_FILE in $srcfile.
+# 3) Set a pending breakpoint at BAR in $libsrc.
+# 4) Load $shlib_name using 'add-symbol-file'.
+# 5) Continue to BAR in $libsrc.
+# 6) Set a breakpiont at FOO in $librc.
+# 7) Continue to FOO in $libsrc.
+# 8) Set a breakpoint at GDB_REMOVE_SYMBOL_FILE.
+# 9) Continue to GDB_REMOVE_SYMBOL_FILE in $srcfile.
+# 10) Remove $shlib_name using 'remove-symbol-file'.
+# 11) Check that the breakpoints at FOO and BAR are pending.
+# 12) Check that the execution can continue without error.
+
+
+if [skip_shlib_tests] {
+ return 0
+}
+
+
+if [is_remote target] {
+ return 0
+}
+
+set target_size TARGET_UNKNOWN
+if [is_lp64_target] {
+ set target_size TARGET_LP64
+} elseif [is_ilp32_target] {
+ set target_size TARGET_ILP32
+} else {
+ return 0
+}
+
+set testfile sym-file-main
+set libfile sym-file-lib
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+set libsrc "${srcdir}/${subdir}/${libfile}.c"
+set libname "${libfile}.so"
+set shlib_name "${objdir}/${subdir}/${libname}"
+set libobj "${objdir}/${subdir}/${libname}"
+set execsrc "${srcdir}/${subdir}/${srcfile}"
+set exec_opts [list debug "additional_flags=-D$target_size -DSHLIB_NAME\\=\"$shlib_name\""]
+
+remote_exec build "rm -f ${binfile}"
+
+if [get_compiler_info] {
+ return -1
+}
+
+
+if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
+ || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } {
+ untested ${testfile}
+ return
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# 1) Load the main executable.
+set result [gdb_load ${binfile}]
+if { $result != 0 } then {
+ return
+}
+
+# 2) Run to GDB_ADD_SYMBOl_FILE in $srcfile for adding
+# $shlib_name.
+set result [runto gdb_add_symbol_file]
+if { !$result } then {
+ return
+}
+
+# 3) Set a pending breakpoint at BAR in $libsrc.
+set result [gdb_breakpoint bar allow-pending]
+if { !$result } then {
+ return
+}
+
+# 4) Add $shlib_name using 'add-symbol-file'.
+set result [gdb_test "add-symbol-file ${shlib_name} addr" \
+ "Reading symbols from .*${shlib_name}\\.\\.\\.done\\." \
+ "add-symbol-file ${shlib_name}.*" \
+ "add symbol table from file \".*${shlib_name}\"\
+ at.*\\(y or n\\) " \
+ "y"]
+if { $result != 0 } then {
+ return
+}
+
+# 5) Continue to BAR in $libsrc to ensure that the breakpoint
+# was bound correctly after adding $shilb_name.
+set lnum_bar [gdb_get_line_number "break at bar" $libsrc]
+gdb_continue_to_breakpoint bar ".*$libfile\\.c:$lnum_bar.*"
+
+# 6) Set a breakpoint at FOO in $libsrc.
+set result [gdb_breakpoint foo]
+if { !$result } then {
+ return
+}
+
+# 7) Continue to FOO in $libsrc to ensure that the breakpoint
+# was bound correctly.
+set lnum_foo [gdb_get_line_number "break at foo" $libsrc]
+gdb_continue_to_breakpoint foo ".*$libfile\\.c:$lnum_foo.*"
+
+
+# 8) Set a breakpint at GDB_REMOVE_SYMBOL_FILE in $srcfile for
+# removing $shlib_name.
+set result [gdb_breakpoint gdb_remove_symbol_file]
+if { !$result } then {
+ return
+}
+
+# 9) Continue to GDB_REMOVE_SYMBOL_FILE in $srcfile.
+gdb_continue_to_breakpoint gdb_remove_symbol_file
+
+# 10) Remove $shlib_name using 'remove-symbol-file'.
+set result [gdb_test "remove-symbol-file addr" \
+ "" \
+ "remove-symbol-file addr" \
+ "Remove symbol table from file \".*${shlib_name}\"\
+ at.*\\(y or n\\) " \
+ "y"]
+if { $result != 0 } then {
+ return
+}
+
+# 11) Check that the breakpoints at FOO and BAR are pending after removing
+# $shlib_name.
+gdb_test "info breakpoints 2" \
+ ".*PENDING.*" \
+ "check if Breakpoint 2 is pending."
+
+gdb_test "info breakpoints 3" \
+ ".*PENDING.*" \
+ "check if Breakpoint 3 is pending."
+
+# 12) Check that the execution can continue without error.
+gdb_continue_to_end
+
+
--
1.7.6.5
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [patch v4 2/3] Test adding and removing a symbol file at runtime.
2013-05-29 9:13 ` [patch v4 2/3] Test adding and removing a symbol file at runtime Nicolas Blanc
@ 2013-05-29 9:48 ` Luis Machado
0 siblings, 0 replies; 11+ messages in thread
From: Luis Machado @ 2013-05-29 9:48 UTC (permalink / raw)
To: Nicolas Blanc; +Cc: gdb-patches, palves, tromey, eliz, yao
Hi,
More nits
On 05/29/2013 11:13 AM, Nicolas Blanc wrote:
> +unsigned char inline elf_st_type (unsigned char st_info)
> +{
> + return ELF32_ST_TYPE (st_info);
> +}
> +#endif
> +
> +
Double empty line here. There are more occurrences of this throughout
the testcase.
> +void gdb_add_symbol_file (void* addr, const char* file)
> +{
> + return;
> +}
> +
> +
Here.
> +void gdb_remove_symbol_file (void* addr)
> +{
> + return;
> +}
> +
> +
Here.
> +struct segment
> +{
> + char* mapped_addr;
> + Elf_Phdr* phdr;
> + struct segment* next;
> +};
> +
> +
Here and so on.
> +# Test adding and removing a symbol file dynamically:
> +# 1) Load the main executable.
> +# 2) Run to GDB_ADD_SYMBOl_FILE in $srcfile.
> +# 3) Set a pending breakpoint at BAR in $libsrc.
> +# 4) Load $shlib_name using 'add-symbol-file'.
> +# 5) Continue to BAR in $libsrc.
> +# 6) Set a breakpiont at FOO in $librc.
> +# 7) Continue to FOO in $libsrc.
> +# 8) Set a breakpoint at GDB_REMOVE_SYMBOL_FILE.
> +# 9) Continue to GDB_REMOVE_SYMBOL_FILE in $srcfile.
> +# 10) Remove $shlib_name using 'remove-symbol-file'.
> +# 11) Check that the breakpoints at FOO and BAR are pending.
> +# 12) Check that the execution can continue without error.
> +
> +
Double empty line again.
> +if [skip_shlib_tests] {
> + return 0
> +}
> +
> +
> +if [is_remote target] {
> + return 0
> +}
> +
> +set target_size TARGET_UNKNOWN
> +if [is_lp64_target] {
> + set target_size TARGET_LP64
> +} elseif [is_ilp32_target] {
> + set target_size TARGET_ILP32
> +} else {
> + return 0
> +}
> +
> +set testfile sym-file-main
> +set libfile sym-file-lib
> +set srcfile ${testfile}.c
> +set binfile ${objdir}/${subdir}/${testfile}
> +
> +set libsrc "${srcdir}/${subdir}/${libfile}.c"
> +set libname "${libfile}.so"
> +set shlib_name "${objdir}/${subdir}/${libname}"
> +set libobj "${objdir}/${subdir}/${libname}"
> +set execsrc "${srcdir}/${subdir}/${srcfile}"
> +set exec_opts [list debug "additional_flags=-D$target_size -DSHLIB_NAME\\=\"$shlib_name\""]
I'm wondering if the newer function "prepare_for_testing" can be used
here to prevent having to deal with all these individual options.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch v4 1/3] Create remove-symbol-file command.
2013-05-29 9:13 [patch v4 0/3] remove-symbol-file Nicolas Blanc
2013-05-29 9:13 ` [patch v4 2/3] Test adding and removing a symbol file at runtime Nicolas Blanc
@ 2013-05-29 9:13 ` Nicolas Blanc
2013-05-29 9:38 ` Luis Machado
2013-05-29 9:13 ` [patch v4 3/3] Documentation for the " Nicolas Blanc
2 siblings, 1 reply; 11+ messages in thread
From: Nicolas Blanc @ 2013-05-29 9:13 UTC (permalink / raw)
To: gdb-patches, palves, tromey, eliz, yao; +Cc: nicolas.blanc
Create remove-symbol-file command for removing
symbol files added via the add-symbol-file command.
2013-18-03 Nicolas Blanc <nicolas.blanc@intel.com>
* breakpoint.c (is_addr_in_objfile): Create static helper function.
(disable_breakpoints_in_freed_objfile): Create function for disabling
breakpoints in objfiles upon free_objfile notifications.
* objfiles.c (free_objfile): Notify free_objfile.
* objfiles.h (struct objfile): Add comment for low_addr.
* printcmd.c (clear_dangling_display_expressions): Act upon free_objfile
events instead of solib_unloaded events.
(_initialize_printcmd): Register observer for free_objfile instead
of solib_unloaded notifications.
* solib.c (remove_user_added_objfile): Create function for removing
dangling references upon notification of free_objfile.
* symfile.c (add_symbol_file_command): Set OBJFILE->LOW_ADDR.
(remove_symbol_file_command): Create command for removing symbol files.
(_initialize_symfile): Add remove-symbol-file.
gdb/doc
* observer.texi: Created free_objfile event.
Signed-off-by: Nicolas Blanc <nicolas.blanc@intel.com>
---
gdb/breakpoint.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++--
gdb/doc/observer.texi | 4 ++
gdb/objfiles.c | 3 ++
gdb/objfiles.h | 4 ++
gdb/printcmd.c | 15 +++++---
gdb/solib.c | 23 ++++++++++++++
gdb/symfile.c | 55 ++++++++++++++++++++++++++++++++-
7 files changed, 176 insertions(+), 10 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index b4d2f27..e42b32d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7417,9 +7417,9 @@ disable_breakpoints_in_shlibs (void)
}
}
-/* Disable any breakpoints and tracepoints that are in an unloaded shared
- library. Only apply to enabled breakpoints, disabled ones can just stay
- disabled. */
+/* Disable any breakpoints and tracepoints that are in SOLIB upon
+ notification of unloaded_shlib. Only apply to enabled breakpoints,
+ disabled ones can just stay disabled. */
static void
disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
@@ -7471,6 +7471,81 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
}
}
+/* Return 1 if ADDR maps in one of the sections of OBJFILE and 0
+ otherwise. OBJFILE must be valid. */
+
+static inline int
+is_addr_in_objfile (CORE_ADDR addr, const struct objfile * objfile)
+{
+ struct obj_section *osect;
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
+ {
+ if (obj_section_addr (osect) <= addr
+ && addr < obj_section_endaddr (osect))
+ return 1;
+ }
+ return 0;
+}
+
+/* Disable any breakpoints and tracepoints in OBJFILE upon
+ notification of free_objfile. Only apply to enabled breakpoints,
+ disabled ones can just stay disabled. */
+
+static void
+disable_breakpoints_in_freed_objfile (struct objfile * objfile)
+{
+ struct breakpoint *b;
+
+ if (objfile == NULL)
+ return;
+
+ /* If the file is a shared library not loaded by the user then
+ solib_unloaded was notified and disable_breakpoints_in_unloaded_shlib
+ was called. In that case there is no need to take action again. */
+ if ((objfile->flags & OBJF_SHARED) && !(objfile->flags & OBJF_USERLOADED))
+ return;
+
+ ALL_BREAKPOINTS (b)
+ {
+ struct bp_location *loc;
+ int bp_modified = 0;
+ int is_no_tracepoint = !is_tracepoint (b);
+
+ if (is_no_tracepoint
+ && b->type != bp_breakpoint
+ && b->type != bp_jit_event
+ && b->type != bp_hardware_breakpoint)
+ continue;
+
+ for (loc = b->loc; loc != NULL; loc = loc->next)
+ {
+ CORE_ADDR loc_addr = loc->address;
+
+ if (is_no_tracepoint
+ && loc->loc_type != bp_loc_hardware_breakpoint
+ && loc->loc_type != bp_loc_software_breakpoint)
+ continue;
+
+ if (loc->shlib_disabled != 0)
+ continue;
+
+ if (objfile->pspace != loc->pspace)
+ continue;
+
+ if (is_addr_in_objfile (loc_addr, objfile))
+ {
+ loc->shlib_disabled = 1;
+ loc->inserted = 0;
+ bp_modified = 1;
+ }
+ }
+
+ if (bp_modified)
+ observer_notify_breakpoint_modified (b);
+ }
+
+}
+
/* FORK & VFORK catchpoints. */
/* An instance of this type is used to represent a fork or vfork
@@ -15875,6 +15950,7 @@ _initialize_breakpoint (void)
initialize_breakpoint_ops ();
observer_attach_solib_unloaded (disable_breakpoints_in_unloaded_shlib);
+ observer_attach_free_objfile (disable_breakpoints_in_freed_objfile);
observer_attach_inferior_exit (clear_syscall_counts);
observer_attach_memory_changed (invalidate_bp_value_on_memory_change);
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index adb7085..f753965 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -138,6 +138,10 @@ Called with @var{objfile} equal to @code{NULL} to indicate
previously loaded symbol table data has now been invalidated.
@end deftypefun
+@deftypefun void free_objfile (struct objfile *@var{objfile})
+The object file specified by @var{objfile} is about to be freed.
+@end deftypefun
+
@deftypefun void new_thread (struct thread_info *@var{t})
The thread specified by @var{t} has been created.
@end deftypefun
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 3e49ea2..c70a5a2 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -530,6 +530,9 @@ free_objfile_separate_debug (struct objfile *objfile)
void
free_objfile (struct objfile *objfile)
{
+ /* First notify observers that this objfile is about to be freed. */
+ observer_notify_free_objfile (objfile);
+
/* Free all separate debug objfiles. */
free_objfile_separate_debug (objfile);
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 93149e2..644e780 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -204,6 +204,10 @@ struct objfile
char *name;
+ /* The base address of the object file, which is often assumed to be
+ the address of the text section. The remove-symbol-file command
+ uses this field to identify the object file to remove. */
+
CORE_ADDR addr_low;
/* Some flag bits for this objfile.
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 2cc33d0..bd4bd42 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1928,21 +1928,24 @@ disable_display_command (char *args, int from_tty)
an item by re-parsing .exp_string field in the new execution context. */
static void
-clear_dangling_display_expressions (struct so_list *solib)
+clear_dangling_display_expressions (struct objfile *objfile)
{
- struct objfile *objfile = solib->objfile;
struct display *d;
+ struct program_space *pspace;
/* With no symbol file we cannot have a block or expression from it. */
if (objfile == NULL)
return;
+ pspace = objfile->pspace;
if (objfile->separate_debug_objfile_backlink)
- objfile = objfile->separate_debug_objfile_backlink;
- gdb_assert (objfile->pspace == solib->pspace);
+ {
+ objfile = objfile->separate_debug_objfile_backlink;
+ gdb_assert (objfile->pspace == pspace);
+ }
for (d = display_chain; d != NULL; d = d->next)
{
- if (d->pspace != solib->pspace)
+ if (d->pspace != pspace)
continue;
if (lookup_objfile_from_block (d->block) == objfile
@@ -2474,7 +2477,7 @@ _initialize_printcmd (void)
current_display_number = -1;
- observer_attach_solib_unloaded (clear_dangling_display_expressions);
+ observer_attach_free_objfile (clear_dangling_display_expressions);
add_info ("address", address_info,
_("Describe where symbol SYM is stored."));
diff --git a/gdb/solib.c b/gdb/solib.c
index a3479c5..a897777 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1446,6 +1446,27 @@ gdb_bfd_lookup_symbol (bfd *abfd,
return symaddr;
}
+/* SO_LIST_HEAD may contain user-loaded object files that can be removed
+ out-of-band by the user. So upon notification of free_objfile remove
+ any reference to any user-loaded file that is about to be freed. */
+
+static void
+remove_user_added_objfile (struct objfile *objfile)
+{
+ struct so_list *so;
+
+ if (!objfile)
+ return;
+
+ if (objfile->flags & OBJF_USERLOADED)
+ {
+ for (so = so_list_head; so != NULL; so = so->next)
+ if (so->objfile == objfile)
+ so->objfile = NULL;
+ }
+}
+
+
extern initialize_file_ftype _initialize_solib; /* -Wmissing-prototypes */
void
@@ -1453,6 +1474,8 @@ _initialize_solib (void)
{
solib_data = gdbarch_data_register_pre_init (solib_init);
+ observer_attach_free_objfile (remove_user_added_objfile);
+
add_com ("sharedlibrary", class_files, sharedlibrary_command,
_("Load shared object library symbols for files matching REGEXP."));
add_info ("sharedlibrary", info_sharedlibrary_command,
diff --git a/gdb/symfile.c b/gdb/symfile.c
index e9609b2..7c5989c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2175,6 +2175,8 @@ add_symbol_file_command (char *args, int from_tty)
int expecting_sec_name = 0;
int expecting_sec_addr = 0;
char **argv;
+ struct objfile *objf;
+ CORE_ADDR addr_low;
struct sect_opt
{
@@ -2307,12 +2309,17 @@ add_symbol_file_command (char *args, int from_tty)
}
section_addrs->num_sections = sec_num;
+ addr_low = section_addrs->other[0].addr;
+
if (from_tty && (!query ("%s", "")))
error (_("Not confirmed."));
- symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
+ objf = symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
section_addrs, flags);
+ /* Set the low address of the object for identification. */
+ objf->addr_low = addr_low;
+
/* Getting new symbols may change our opinion about what is
frameless. */
reinit_frame_cache ();
@@ -2320,6 +2327,46 @@ add_symbol_file_command (char *args, int from_tty)
}
\f
+
+/* This function removes a symbol file that was added via add-symbol-file. */
+
+static void
+remove_symbol_file_command (char *args, int from_tty)
+{
+ CORE_ADDR addr = 0;
+ struct objfile* objf;
+ struct gdbarch *gdbarch = get_current_arch ();
+
+ dont_repeat ();
+
+ if (args == NULL)
+ error (_("USAGE: remove-symbol-file <text_address>"));
+
+ addr = parse_and_eval_address (args);
+
+ ALL_OBJFILES (objf)
+ {
+ if (objf->flags & OBJF_USERLOADED && objf->addr_low == addr)
+ break;
+ }
+
+ if (objf == NULL)
+ error (_("no user-added symbol file for .text_addr = 0x%s"),
+ phex_nz (addr, sizeof (addr)));
+
+ printf_unfiltered (_("Remove symbol table from file \"%s\"\
+ at .text_addr = %s\n"),
+ objf->name, paddress (gdbarch, addr));
+
+ if (from_tty && (!query ("%s", "")))
+ error (_("Not confirmed."));
+
+ free_objfile (objf);
+ clear_symtab_users (0);
+
+}
+
+
typedef struct objfile *objfilep;
DEF_VEC_P (objfilep);
@@ -3734,6 +3781,12 @@ with the text. SECT is a section name to be loaded at SECT_ADDR."),
&cmdlist);
set_cmd_completer (c, filename_completer);
+ c = add_cmd ("remove-symbol-file", class_files,
+ remove_symbol_file_command, _("\
+Remove a symbol file loaded via the add-symbol-file command.\n\
+Usage: remove-symbol-file ADDR.\nADDR is the starting address of the\
+ text section of the file to remove."), &cmdlist);
+
c = add_cmd ("load", class_files, load_command, _("\
Dynamically load FILE into the running program, and record its symbols\n\
for access from GDB.\n\
--
1.7.6.5
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [patch v4 1/3] Create remove-symbol-file command.
2013-05-29 9:13 ` [patch v4 1/3] Create remove-symbol-file command Nicolas Blanc
@ 2013-05-29 9:38 ` Luis Machado
2013-05-29 12:08 ` Blanc, Nicolas
0 siblings, 1 reply; 11+ messages in thread
From: Luis Machado @ 2013-05-29 9:38 UTC (permalink / raw)
To: Nicolas Blanc; +Cc: gdb-patches, palves, tromey, eliz, yao
Hi,
A few nits and a suggestion at the end.
On 05/29/2013 11:13 AM, Nicolas Blanc wrote:
> Create remove-symbol-file command for removing
> symbol files added via the add-symbol-file command.
>
> 2013-18-03 Nicolas Blanc <nicolas.blanc@intel.com>
>
> * breakpoint.c (is_addr_in_objfile): Create static helper function.
Shouldn't this say "New static inline function." instead?
> (disable_breakpoints_in_freed_objfile): Create function for disabling
> breakpoints in objfiles upon free_objfile notifications.
Likewise?
> * solib.c (remove_user_added_objfile): Create function for removing
> dangling references upon notification of free_objfile.
Likewise?
> * symfile.c (add_symbol_file_command): Set OBJFILE->LOW_ADDR.
> (remove_symbol_file_command): Create command for removing symbol files.
Likewise?
> +/* Return 1 if ADDR maps in one of the sections of OBJFILE and 0
> + otherwise. OBJFILE must be valid. */
"maps into one of the sections" maybe?
> +
> +static inline int
> +is_addr_in_objfile (CORE_ADDR addr, const struct objfile * objfile)
> +{
> + struct obj_section *osect;
If OBJFILE must be valid, how about calling gdb_assert() here to ensure
it is indeed valid?
Unless not having a valid OBJFILE is a possibility.
> diff --git a/gdb/objfiles.h b/gdb/objfiles.h
> index 93149e2..644e780 100644
> --- a/gdb/objfiles.h
> +++ b/gdb/objfiles.h
> @@ -204,6 +204,10 @@ struct objfile
>
> char *name;
>
> + /* The base address of the object file, which is often assumed to be
> + the address of the text section. The remove-symbol-file command
> + uses this field to identify the object file to remove. */
> +
> CORE_ADDR addr_low;
>
> /* Some flag bits for this objfile.
No space between the variable and its comment block.
> diff --git a/gdb/symfile.c b/gdb/symfile.c
> index e9609b2..7c5989c 100644
> --- a/gdb/symfile.c
> +++ b/gdb/symfile.c
> @@ -2175,6 +2175,8 @@ add_symbol_file_command (char *args, int from_tty)
> int expecting_sec_name = 0;
> int expecting_sec_addr = 0;
> char **argv;
> + struct objfile *objf;
> + CORE_ADDR addr_low;
>
> struct sect_opt
> {
> @@ -2307,12 +2309,17 @@ add_symbol_file_command (char *args, int from_tty)
> }
> section_addrs->num_sections = sec_num;
>
> + addr_low = section_addrs->other[0].addr;
> +
Looks a little cryptic without a comment stating what this is/will be
used for.
> +
> +/* This function removes a symbol file that was added via add-symbol-file. */
> +
> +static void
> +remove_symbol_file_command (char *args, int from_tty)
> +{
> + CORE_ADDR addr = 0;
> + struct objfile* objf;
> + struct gdbarch *gdbarch = get_current_arch ();
> +
> + dont_repeat ();
> +
> + if (args == NULL)
> + error (_("USAGE: remove-symbol-file <text_address>"));
> +
> + addr = parse_and_eval_address (args);
> +
> + ALL_OBJFILES (objf)
> + {
> + if (objf->flags & OBJF_USERLOADED && objf->addr_low == addr)
> + break;
> + }
> +
> + if (objf == NULL)
> + error (_("no user-added symbol file for .text_addr = 0x%s"),
> + phex_nz (addr, sizeof (addr)));
> +
> + printf_unfiltered (_("Remove symbol table from file \"%s\"\
> + at .text_addr = %s\n"),
> + objf->name, paddress (gdbarch, addr));
> +
> + if (from_tty && (!query ("%s", "")))
> + error (_("Not confirmed."));
> +
> + free_objfile (objf);
> + clear_symtab_users (0);
> +
> +}
Empty line before the end of the function should be gone.
> @@ -3734,6 +3781,12 @@ with the text. SECT is a section name to be loaded at SECT_ADDR."),
> &cmdlist);
> set_cmd_completer (c, filename_completer);
>
> + c = add_cmd ("remove-symbol-file", class_files,
> + remove_symbol_file_command, _("\
> +Remove a symbol file loaded via the add-symbol-file command.\n\
> +Usage: remove-symbol-file ADDR.\nADDR is the starting address of the\
> + text section of the file to remove."), &cmdlist);
> +
> c = add_cmd ("load", class_files, load_command, _("\
> Dynamically load FILE into the running program, and record its symbols\n\
> for access from GDB.\n\
>
I'm thinking, with a command called "remove-symbol-file" i would expect
to provide some kind of filename to this command. Should the user also
be able to state a DSO name here and have it unloaded? Maybe have the
name translated to the base address used to unload the library internally?
Luis
^ permalink raw reply [flat|nested] 11+ messages in thread* RE: [patch v4 1/3] Create remove-symbol-file command.
2013-05-29 9:38 ` Luis Machado
@ 2013-05-29 12:08 ` Blanc, Nicolas
2013-05-29 12:11 ` Luis Machado
0 siblings, 1 reply; 11+ messages in thread
From: Blanc, Nicolas @ 2013-05-29 12:08 UTC (permalink / raw)
To: lgustavo; +Cc: gdb-patches, palves, tromey, eliz, yao
Hi Luis,
Thanks for your feedback. I'll fix the nits.
> I'm thinking, with a command called "remove-symbol-file" i would expect to provide some kind of filename to this command. Should the user also be able to state a DSO name here and have it unloaded?
> Maybe have the name translated to the base address used to unload the library internally?
The first address parameter of the add-symbol-file command is a better way to identify the file to remove than the file name because a file can be loaded multiple times at different addresses -- this case is important for me. The user knows the "start address" very well since he typed it in for adding the file. So I see no real benefit of adding a file-name parameter.
This is what I wrote in the documentation:
remove-symbol-file address
The remove-symbol-file command removes all symbol information about the
file loaded at address. address must be an expression that represents the address
of the text section of a file added by the user via the add-symbol-file
command. In other words, the file to remove is identified by the first address
parameter of the add-symbol-file command:
(gdb) add-symbol-file /home/user/gdb/mylib.so 0x7ffff7ff9480
add symbol table from file "/home/user/gdb/mylib.so" at
.text_addr = 0x7ffff7ff9480
(y or n) y
Reading symbols from /home/user/gdb/mylib.so...done.
(gdb) remove-symbol-file 0x7ffff7ff9480
Remove symbol table from file "/home/user/gdb/mylib.so" at\
.text_addr = 0x7ffff7ff9480
(y or n) y
(gdb)
remove-symbol-file does not repeat if you press RET after using it.
Keeping the current syntax would be ok with you?
Regards,
Nicolas
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch v4 1/3] Create remove-symbol-file command.
2013-05-29 12:08 ` Blanc, Nicolas
@ 2013-05-29 12:11 ` Luis Machado
0 siblings, 0 replies; 11+ messages in thread
From: Luis Machado @ 2013-05-29 12:11 UTC (permalink / raw)
To: Blanc, Nicolas; +Cc: gdb-patches, palves, tromey, eliz, yao
Hi,
On 05/29/2013 02:08 PM, Blanc, Nicolas wrote:
> Hi Luis,
>
> Thanks for your feedback. I'll fix the nits.
>
>> I'm thinking, with a command called "remove-symbol-file" i would expect to provide some kind of filename to this command. Should the user also be able to state a DSO name here and have it unloaded?
>> Maybe have the name translated to the base address used to unload the library internally?
>
> The first address parameter of the add-symbol-file command is a better way to identify the file to remove than the file name because a file can be loaded multiple times at different addresses -- this case is important for me. The user knows the "start address" very well since he typed it in for adding the file. So I see no real benefit of adding a file-name parameter.
I see. That was mostly a suggestion. If it problematic to implement it
that way, then i suppose it is OK to use solely the base address.
>
> Keeping the current syntax would be ok with you?
Sure, that looks good to me.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch v4 3/3] Documentation for the remove-symbol-file command.
2013-05-29 9:13 [patch v4 0/3] remove-symbol-file Nicolas Blanc
2013-05-29 9:13 ` [patch v4 2/3] Test adding and removing a symbol file at runtime Nicolas Blanc
2013-05-29 9:13 ` [patch v4 1/3] Create remove-symbol-file command Nicolas Blanc
@ 2013-05-29 9:13 ` Nicolas Blanc
2013-05-29 15:59 ` Eli Zaretskii
2 siblings, 1 reply; 11+ messages in thread
From: Nicolas Blanc @ 2013-05-29 9:13 UTC (permalink / raw)
To: gdb-patches, palves, tromey, eliz, yao; +Cc: nicolas.blanc
2013-04-05 Nicolas Blanc <nicolas.blanc@intel.com>
* NEWS: Add description of the remove-symbol-file command.
gdb/doc
* gdb.texinfo (Commands to Specify Files): Add description
of the remove-symbol-file command.
Signed-off-by: Nicolas Blanc <nicolas.blanc@intel.com>
---
gdb/NEWS | 5 +++++
gdb/doc/gdb.texinfo | 31 +++++++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index a23e8e3..34b4abf 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -31,6 +31,11 @@ maint set|show per-command time
maint set|show per-command symtab
Enable display of per-command gdb resource usage.
+remove-symbol-file ADDR
+ Remove all symbol information about the file loaded at the specified
+ address. The address must match the beginning of the text section
+ of a file added by the user via the `add-symbol-file' command.
+
* New options
set remote trace-status-packet
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index ead00b4..f347e12 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -16511,8 +16511,10 @@ section name and base address for that section. You can specify any
The symbol table of the file @var{filename} is added to the symbol table
originally read with the @code{symbol-file} command. You can use the
@code{add-symbol-file} command any number of times; the new symbol data
-thus read keeps adding to the old. To discard all old symbol data
-instead, use the @code{symbol-file} command without any arguments.
+thus read keeps adding to the old.
+
+Changes can be reverted using the command @code{remove-symbol-file},
+which takes as parameter the load address of the file to remove.
@cindex relocatable object files, reading symbols from
@cindex object files, relocatable, reading symbols from
@@ -16550,6 +16552,31 @@ way.
@code{add-symbol-file} does not repeat if you press @key{RET} after using it.
+@kindex remove-symbol-file
+@item remove-symbol-file @var{address}
+The @code{remove-symbol-file} command removes all symbol information about
+the file loaded at @var{address}. @var{address} must be an expression that
+represents the address of the text section of a file added by the user via
+the @code{add-symbol-file} command. In other words, the file to remove is
+identified by the first address parameter of the @code{add-symbol-file}
+command:
+
+@smallexample
+(gdb) add-symbol-file /home/user/gdb/mylib.so 0x7ffff7ff9480
+add symbol table from file "/home/user/gdb/mylib.so" at
+ .text_addr = 0x7ffff7ff9480
+(y or n) y
+Reading symbols from /home/user/gdb/mylib.so...done.
+(gdb) remove-symbol-file 0x7ffff7ff9480
+Remove symbol table from file "/home/user/gdb/mylib.so" at\
+ .text_addr = 0x7ffff7ff9480
+(y or n) y
+(gdb)
+@end smallexample
+
+
+@code{remove-symbol-file} does not repeat if you press @key{RET} after using it.
+
@kindex add-symbol-file-from-memory
@cindex @code{syscall DSO}
@cindex load symbols from memory
--
1.7.6.5
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [patch v4 3/3] Documentation for the remove-symbol-file command.
2013-05-29 9:13 ` [patch v4 3/3] Documentation for the " Nicolas Blanc
@ 2013-05-29 15:59 ` Eli Zaretskii
2013-05-29 17:11 ` Blanc, Nicolas
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2013-05-29 15:59 UTC (permalink / raw)
To: Nicolas Blanc; +Cc: gdb-patches, palves, tromey, yao, nicolas.blanc
> From: Nicolas Blanc <nicolas.blanc@intel.com>
> Cc: nicolas.blanc@intel.com
> Date: Wed, 29 May 2013 11:13:25 +0200
>
> 2013-04-05 Nicolas Blanc <nicolas.blanc@intel.com>
>
> * NEWS: Add description of the remove-symbol-file command.
> gdb/doc
> * gdb.texinfo (Commands to Specify Files): Add description
> of the remove-symbol-file command.
Thanks. This is OK, but wouldn't it be even better to mention "info
shared" as the means to get the address of a file?
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [patch v4 3/3] Documentation for the remove-symbol-file command.
2013-05-29 15:59 ` Eli Zaretskii
@ 2013-05-29 17:11 ` Blanc, Nicolas
2013-05-29 17:25 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Blanc, Nicolas @ 2013-05-29 17:11 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, palves, tromey, yao
>> 2013-04-05 Nicolas Blanc <nicolas.blanc@intel.com>
>>
>> * NEWS: Add description of the remove-symbol-file command.
>> gdb/doc
>> * gdb.texinfo (Commands to Specify Files): Add description
>> of the remove-symbol-file command.
> Thanks. This is OK, but wouldn't it be even better to mention "info shared" as the means to get the address of a file?
Files added via the add-symbol-file command are not listed by "info shared". GDB has no command for
listing files that have been added via add-symbol-file, unfortunately.
But note that if the user needs to add a file manually then he certainly has a side channel for getting
the symbol-file information. For instance, in the test I submitted GDB reads the address from the debuggee.
Regards,
Nicolas
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch v4 3/3] Documentation for the remove-symbol-file command.
2013-05-29 17:11 ` Blanc, Nicolas
@ 2013-05-29 17:25 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2013-05-29 17:25 UTC (permalink / raw)
To: Blanc, Nicolas; +Cc: gdb-patches, palves, tromey, yao
> From: "Blanc, Nicolas" <nicolas.blanc@intel.com>
> CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
> "palves@redhat.com" <palves@redhat.com>, "tromey@redhat.com"
> <tromey@redhat.com>, "yao@codesourcery.com" <yao@codesourcery.com>
> Date: Wed, 29 May 2013 17:10:59 +0000
>
> > Thanks. This is OK, but wouldn't it be even better to mention "info shared" as the means to get the address of a file?
>
> Files added via the add-symbol-file command are not listed by "info shared". GDB has no command for
> listing files that have been added via add-symbol-file, unfortunately.
Too bad. I therefore suggest to add such a command ASAP.
^ permalink raw reply [flat|nested] 11+ messages in thread