From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 3A71F3858C1F; Fri, 2 Dec 2022 19:43:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A71F3858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670010227; bh=qtu33TDGJHYD7Dzoh9QI56Tk6AMqgQFUyt5gaD+xLVw=; h=From:To:Subject:Date:From; b=WjD/1Ys5LULssLnUX0BO5eEVSaH4NNdcfkHbZusyzczyaTleA3NbVx/75zMz03gwt GD/p7DUaBXyPMd5NNcLmKUKI4PgOB+h7BSsW/n3MA2w6GP8SgX+rGNBNt6l2UeMGP7 olkq6kV24kbR/kKEjh8Y9bVMhBO4EuDq6uqsAeLQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: merge solib-frv aix-solib debug options into "set/show debug solib" X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: ac57bf55472df186dc9fb63f7787f740d457f473 X-Git-Newrev: e26d0dab1018d9ed6eaf3ab127ce9928cd8ac271 Message-Id: <20221202194347.3A71F3858C1F@sourceware.org> Date: Fri, 2 Dec 2022 19:43:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De26d0dab1018= d9ed6eaf3ab127ce9928cd8ac271 commit e26d0dab1018d9ed6eaf3ab127ce9928cd8ac271 Author: Simon Marchi Date: Mon Nov 28 11:43:13 2022 -0500 gdb: merge solib-frv aix-solib debug options into "set/show debug solib" =20 solib implementations are typically used one at a time. So it will be rare that you will want to enable debug for one solib kind, and absolutely want to keep the others disabled. To make things simpler, instead of adding separate variables / macros / commands for each solib implementation, merge the existing ones (frv and aix) into a unified "set/show debug solib", with the solib_debug_printf macro. =20 Change-Id: I6e18bbc7401724f37ae66681badb079d75ecf7fa Diff: --- gdb/NEWS | 12 +++++++ gdb/doc/gdb.texinfo | 18 +++------- gdb/solib-aix.c | 39 ++++------------------ gdb/solib-frv.c | 95 +++++++++++++------------------------------------= ---- gdb/solib.c | 16 +++++---- gdb/solib.h | 12 +++++++ 6 files changed, 68 insertions(+), 124 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index dddef6525de..c4ccfcc9e32 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -145,6 +145,10 @@ set debug infcall on|off show debug infcall Print additional debug messages about inferior function calls. =20 +set debug solib on|off +show debug solib + Print additional debug messages about shared library handling. + set style tui-current-position [on|off] Whether to style the source and assembly code highlighted by the TUI's current position indicator. The default is off. @@ -166,6 +170,14 @@ maintenance info line-table entry corresponds to an address where a breakpoint should be placed to be at the first instruction past a function's prologue. =20 +* Removed commands + +set debug aix-solib on|off +show debug aix-solib +set debug solib-frv on|off +show debug solib-frv + Removed in favor of "set/show debug solib". + * New targets =20 GNU/Linux/LoongArch (gdbserver) loongarch*-*-linux* diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index bababf3c7ff..5b566669975 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -27556,13 +27556,6 @@ Turns on or off display of gdbarch debugging info.= The default is off @item show debug arch Displays the current state of displaying gdbarch debugging info. =20 -@item set debug aix-solib -@cindex AIX shared library debugging -Control display of debugging messages from the AIX shared library -support module. The default is off. -@item show debug aix-solib -Show the current state of displaying AIX shared library debugging messages. - @item set debug aix-thread @cindex AIX threads Display debugging messages about inner workings of the AIX thread @@ -27796,12 +27789,11 @@ default is off. Displays the current state of displaying @value{GDBN} serial debugging info. =20 -@item set debug solib-frv -@cindex FR-V shared-library debugging -Turn on or off debugging messages for FR-V shared-library code. -@item show debug solib-frv -Display the current state of FR-V shared-library code debugging -messages. +@item set debug solib +Turns on or off display of debugging messages related to shared libraries. +The default is off. +@item show debug solib +Show the current state of solib debugging messages. =20 @item set debug symbol-lookup @cindex symbol lookup diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index f483f54de13..77ddb163d8c 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -17,6 +17,7 @@ =20 #include "defs.h" #include "solib-aix.h" +#include "solib.h" #include "solist.h" #include "inferior.h" #include "gdb_bfd.h" @@ -28,15 +29,6 @@ #include "gdbcmd.h" #include "gdbsupport/scope-exit.h" =20 -/* Variable controlling the output of the debugging traces for - this module. */ -static bool solib_aix_debug; - -/* Print an "aix-solib" debug statement. */ - -#define solib_aix_debug_printf(fmt, ...) \ - debug_prefixed_printf_cond (solib_aix_debug, "aix-solib",fmt, ##__VA_ARG= S__) - /* Our private data in struct so_list. */ =20 struct lm_info_aix : public lm_info_base @@ -257,8 +249,8 @@ solib_aix_get_library_list (struct inferior *inf, const= char *warning_msg) return data->library_list; } =20 - solib_aix_debug_printf ("TARGET_OBJECT_LIBRARIES_AIX =3D %s", - library_document->data ()); + solib_debug_printf ("TARGET_OBJECT_LIBRARIES_AIX =3D %s", + library_document->data ()); =20 data->library_list =3D solib_aix_parse_libraries (library_document->data= ()); if (!data->library_list.has_value () && warning_msg !=3D NULL) @@ -379,7 +371,7 @@ solib_aix_free_so (struct so_list *so) { lm_info_aix *li =3D (lm_info_aix *) so->lm_info; =20 - solib_aix_debug_printf ("%s", so->so_name); + solib_debug_printf ("%s", so->so_name); =20 delete li; } @@ -688,8 +680,8 @@ solib_aix_get_toc_value (CORE_ADDR pc) =20 result =3D data_osect->addr () + xcoff_get_toc_offset (pc_osect->objfile= ); =20 - solib_aix_debug_printf ("pc=3D%s -> %s", core_addr_to_string (pc), - core_addr_to_string (result)); + solib_debug_printf ("pc=3D%s -> %s", core_addr_to_string (pc), + core_addr_to_string (result)); =20 return result; } @@ -708,15 +700,6 @@ solib_aix_normal_stop_observer (struct bpstat *unused_= 1, int unused_2) data->library_list.reset (); } =20 -/* Implements the "show debug aix-solib" command. */ - -static void -show_solib_aix_debug (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) -{ - gdb_printf (file, _("solib-aix debugging is %s.\n"), value); -} - /* The target_so_ops for AIX targets. */ const struct target_so_ops solib_aix_so_ops =3D { @@ -737,14 +720,4 @@ _initialize_solib_aix () { gdb::observers::normal_stop.attach (solib_aix_normal_stop_observer, "solib-aix"); - - /* Debug this file's internals. */ - add_setshow_boolean_cmd ("aix-solib", class_maintenance, - &solib_aix_debug, _("\ -Control the debugging traces for the solib-aix module."), _("\ -Show whether solib-aix debugging traces are enabled."), _("\ -When on, solib-aix debugging traces are enabled."), - NULL, - show_solib_aix_debug, - &setdebuglist, &showdebuglist); } diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 6ca303c3566..5a8e6874398 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -31,9 +31,6 @@ #include "elf/frv.h" #include "gdb_bfd.h" =20 -/* Flag which indicates whether internal debug messages should be printed.= */ -static unsigned int solib_frv_debug; - /* FR-V pointers are four bytes wide. */ enum { FRV_PTR_SIZE =3D 4 }; =20 @@ -290,27 +287,21 @@ lm_base (void) current_program_space->symfile_object_file); if (got_sym.minsym =3D=3D 0) { - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "lm_base: _GLOBAL_OFFSET_TABLE_ not found.\n"); + solib_debug_printf ("_GLOBAL_OFFSET_TABLE_ not found."); return 0; } =20 addr =3D got_sym.value_address () + 8; =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "lm_base: _GLOBAL_OFFSET_TABLE_ + 8 =3D %s\n", - hex_string_custom (addr, 8)); + solib_debug_printf ("_GLOBAL_OFFSET_TABLE_ + 8 =3D %s", + hex_string_custom (addr, 8)); =20 if (target_read_memory (addr, buf, sizeof buf) !=3D 0) return 0; lm_base_cache =3D extract_unsigned_integer (buf, sizeof buf, byte_order); =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "lm_base: lm_base_cache =3D %s\n", - hex_string_custom (lm_base_cache, 8)); + solib_debug_printf ("lm_base_cache =3D %s", + hex_string_custom (lm_base_cache, 8)); =20 return lm_base_cache; } @@ -354,10 +345,8 @@ frv_current_sos (void) struct ext_link_map lm_buf; CORE_ADDR got_addr; =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "current_sos: reading link_map entry at %s\n", - hex_string_custom (lm_addr, 8)); + solib_debug_printf ("reading link_map entry at %s", + hex_string_custom (lm_addr, 8)); =20 if (target_read_memory (lm_addr, (gdb_byte *) &lm_buf, sizeof (lm_buf)) !=3D 0) @@ -405,10 +394,8 @@ frv_current_sos (void) gdb::unique_xmalloc_ptr name_buf =3D target_read_string (addr, SO_NAME_MAX_PATH_SIZE - 1); =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, "current_sos: name =3D %s\n", - name_buf.get ()); - =20 + solib_debug_printf ("name =3D %s", name_buf.get ()); + if (name_buf =3D=3D nullptr) warning (_("Can't read pathname for link map entry.")); else @@ -582,10 +569,8 @@ enable_break2 (void) return 0; } =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: interp_loadmap_addr =3D %s\n", - hex_string_custom (interp_loadmap_addr, 8)); + solib_debug_printf ("interp_loadmap_addr =3D %s", + hex_string_custom (interp_loadmap_addr, 8)); =20 ldm =3D fetch_loadmap (interp_loadmap_addr); if (ldm =3D=3D NULL) @@ -627,19 +612,13 @@ enable_break2 (void) return 0; } =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: _dl_debug_addr " - "(prior to relocation) =3D %s\n", - hex_string_custom (addr, 8)); + solib_debug_printf ("_dl_debug_addr (prior to relocation) =3D %s", + hex_string_custom (addr, 8)); =20 addr +=3D displacement_from_map (ldm, addr); =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: _dl_debug_addr " - "(after relocation) =3D %s\n", - hex_string_custom (addr, 8)); + solib_debug_printf ("_dl_debug_addr (after relocation) =3D %s", + hex_string_custom (addr, 8)); =20 /* Fetch the address of the r_debug struct. */ if (target_read_memory (addr, addr_buf, sizeof addr_buf) !=3D 0) @@ -650,18 +629,14 @@ enable_break2 (void) } addr =3D extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_o= rder); =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: _dl_debug_addr[0..3] =3D %s\n", - hex_string_custom (addr, 8)); + solib_debug_printf ("_dl_debug_addr[0..3] =3D %s", + hex_string_custom (addr, 8)); =20 /* If it's zero, then the ldso hasn't initialized yet, and so there are no shared libs yet loaded. */ if (addr =3D=3D 0) { - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: ldso not yet initialized\n"); + solib_debug_printf ("ldso not yet initialized"); /* Do not warn, but mark to run again. */ return 0; } @@ -719,17 +694,13 @@ enable_break (void) =20 if (current_program_space->symfile_object_file =3D=3D NULL) { - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: No symbol file found.\n"); + solib_debug_printf ("No symbol file found."); return 0; } =20 if (!entry_point_address_query (&entry_point)) { - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: Symbol file has no entry point.\n"); + solib_debug_printf ("Symbol file has no entry point."); return 0; } =20 @@ -741,19 +712,14 @@ enable_break (void) =20 if (interp_sect =3D=3D NULL) { - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: No .interp section found.\n"); + solib_debug_printf ("No .interp section found."); return 0; } =20 create_solib_event_breakpoint (target_gdbarch (), entry_point); =20 - if (solib_frv_debug) - gdb_printf (gdb_stdlog, - "enable_break: solib event breakpoint " - "placed at entry point: %s\n", - hex_string_custom (entry_point, 8)); + solib_debug_printf ("solib event breakpoint placed at entry point: %s", + hex_string_custom (entry_point, 8)); return 1; } =20 @@ -1141,18 +1107,3 @@ const struct target_so_ops frv_so_ops =3D frv_in_dynsym_resolve_code, solib_bfd_open, }; - -void _initialize_frv_solib (); -void -_initialize_frv_solib () -{ - /* Debug this file's internals. */ - add_setshow_zuinteger_cmd ("solib-frv", class_maintenance, - &solib_frv_debug, _("\ -Set internal debugging of shared library code for FR-V."), _("\ -Show internal debugging of shared library code for FR-V."), _("\ -When non-zero, FR-V solib specific internal debugging is enabled."), - NULL, - NULL, /* FIXME: i18n: */ - &setdebuglist, &showdebuglist); -} diff --git a/gdb/solib.c b/gdb/solib.c index 7cfdd81114c..59fd866b652 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -55,13 +55,9 @@ #include "cli/cli-style.h" #include "solib-target.h" =20 -/* Architecture-specific operations. */ - -=0C - -/* external data declarations */ +/* See solib.h. */ =20 -/* Local function prototypes */ +bool debug_solib; =20 /* If non-empty, this is a search path for loading non-absolute shared lib= rary symbol files. This takes precedence over the environment variables PATH @@ -1808,4 +1804,12 @@ PATH and LD_LIBRARY_PATH."), reload_shared_libraries, show_solib_search_path, &setlist, &showlist); + + add_setshow_boolean_cmd ("solib", class_maintenance, + &debug_solib, _("\ +Set solib debugging."), _("\ +Show solib debugging."), _("\ +When true, solib-related debugging output is enabled."), + nullptr, nullptr, + &setdebuglist, &showdebuglist); } diff --git a/gdb/solib.h b/gdb/solib.h index a7e751ed9b3..74066680ef9 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -29,6 +29,18 @@ struct program_space; #include "gdb_bfd.h" #include "symfile-add-flags.h" =20 +/* Value of the 'set debug solib' configuration variable. */ + +extern bool debug_solib; + +/* Print an "solib" debug statement. */ + +#define solib_debug_printf(fmt, ...) \ + debug_prefixed_printf_cond (debug_solib, "solib", fmt, ##__VA_ARGS__) + +#define SOLIB_SCOPED_DEBUG_START_END(fmt, ...) \ + scoped_debug_start_end (debug_solib, "solib", fmt, ##__VA_ARGS__) + /* Called when we free all symtabs, to free the shared library information as well. */