* [PATCH v2 0/1] gdb: Update linkage name lookup function to allow mst_file_data/bss types.
@ 2024-11-12 18:28 Abdul Basit Ijaz
2024-11-12 18:28 ` [PATCH v2 1/1] " Abdul Basit Ijaz
0 siblings, 1 reply; 3+ messages in thread
From: Abdul Basit Ijaz @ 2024-11-12 18:28 UTC (permalink / raw)
To: gdb-patches; +Cc: abdul.b.ijaz, tom
Hi All,
The function "lookup_minimal_symbol_linkage", only matches the non-static data
symbols. So in case jit_debugger is static type then setting up breakpoint in
the JIT code fails. The function is updated to optionally match
mst_file_data and mst_file_bss types as well for JIT code initialization
handling.
V1 patch can be seen here:
https://sourceware.org/pipermail/gdb-patches/2024-August/211153.html
Changes since V1:
* Fixes the feedback on V1 from Tom:
https://sourceware.org/pipermail/gdb-patches/2024-August/211154.html
Tests are executed using gcc64/gcc32/native-gdbserver configurationo and no
regression is seen.
Thanks & Best Regards
Abdul Basit
Ijaz, Abdul B (1):
gdb: Update linkage name lookup function to allow mst_file_data/bss
types.
gdb/dwarf2/read.c | 2 +-
gdb/jit.c | 3 ++-
gdb/minsyms.c | 11 ++++++++---
gdb/minsyms.h | 9 +++++----
gdb/testsuite/gdb.base/jit-elf-so.exp | 6 ++++--
gdb/testsuite/gdb.base/jit-protocol.h | 7 ++++++-
6 files changed, 26 insertions(+), 12 deletions(-)
--
2.34.1
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] gdb: Update linkage name lookup function to allow mst_file_data/bss types.
2024-11-12 18:28 [PATCH v2 0/1] gdb: Update linkage name lookup function to allow mst_file_data/bss types Abdul Basit Ijaz
@ 2024-11-12 18:28 ` Abdul Basit Ijaz
2024-11-15 20:49 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Abdul Basit Ijaz @ 2024-11-12 18:28 UTC (permalink / raw)
To: gdb-patches; +Cc: abdul.b.ijaz, tom
From: "Abdul Basit Ijaz" <abdul.b.ijaz@intel.com>
From the commit 667ed4b14ddaa9af196481f1757c0e517e80b6ed onward, instead
of normal name GDB looks for the "jit_descriptor" linkage name in the JIT
code initialization. Without this change, the function
"lookup_minimal_symbol_linkage", only matches the non-static data. So in
case jit_debugger is static type then setting up breakpoint in the JIT code
fails. Issue is seen for the intel compilers, where jit_debug_descriptor has
static type i.e. "mst_file_data". Hence lookup_minimal_symbol_linkage returns
nullptr for it. So, in this case breakpoint does not hit in the JIT code.
To resolve this, the commit introduces a new boolean argument to the
lookup_minimal_symbol_linkage function. This argument allows the function to
also match mst_file_data and mst_file_bss types when set to true. The
function is called with this new argument set to true only from JIT code
initialization handling, ensuring that the current behavior remains unchanged
for other cases. Because handling of static types of data symbols for all cases
result in regression for "gdb.base/print-file-var.exp" test.
Example of minsym for the JIT code emitted by the intel compilers where
lookup_minimal_symbol_linkage fails without this change because jit_debugger
type is "mst_file_data".
(top-gdb) p *msymbol
$1 = {<general_symbol_info> =
{m_name = 0x7fffcc77dc95 "__jit_debug_descriptor",
m_value = {ivalue = 84325936, block = 0x506b630,
bytes = 0x506b630 <error: Cannot access memory at address 0x506b630>,
address = 0x506b630, unrel_addr = (unknown: 0x506b630),
common_block = 0x506b630, chain = 0x506b630},
language_specific = {obstack = 0x0, demangled_name = 0x0},
m_language = language_unknown, ada_mangled = 0, m_section = 29},
m_size = 24, filename = 0x55555a751b70 "JITLoaderGDB.cpp",
m_type = mst_file_data, created_by_gdb = 0,
m_target_flag_1 = 0, m_target_flag_2 = 0, m_has_size = 1,
name_set = 1, hash_next = 0x55555b86e4f0, demangled_hash_next = 0x0}
Updated the test "jit-elf-so.exp" to test the static type of jit_descriptor
object.
2024-11-12 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
---
gdb/dwarf2/read.c | 2 +-
gdb/jit.c | 3 ++-
gdb/minsyms.c | 11 ++++++++---
gdb/minsyms.h | 9 +++++----
gdb/testsuite/gdb.base/jit-elf-so.exp | 6 ++++--
gdb/testsuite/gdb.base/jit-protocol.h | 7 ++++++-
6 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 665e00bb8e7..ab97b9b89af 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -19235,7 +19235,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
apply. */
bound_minimal_symbol found
= (lookup_minimal_symbol_linkage
- (sym->linkage_name (), objfile));
+ (sym->linkage_name (), objfile, false));
if (found.minsym != nullptr)
sym->maybe_copied = 1;
}
diff --git a/gdb/jit.c b/gdb/jit.c
index ed3b26cd4bd..48be1c880c9 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -892,7 +892,8 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
}
bound_minimal_symbol desc_symbol
- = lookup_minimal_symbol_linkage (jit_descriptor_name, the_objfile);
+ = lookup_minimal_symbol_linkage (jit_descriptor_name,
+ the_objfile, true);
if (desc_symbol.minsym == NULL
|| desc_symbol.value_address () == 0)
{
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 33eb9072e5f..4e1868c9f87 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -561,7 +561,8 @@ iterate_over_minimal_symbols
/* See minsyms.h. */
bound_minimal_symbol
-lookup_minimal_symbol_linkage (const char *name, struct objfile *objf)
+lookup_minimal_symbol_linkage (const char *name, struct objfile *objf,
+ bool match_static_type)
{
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
@@ -573,7 +574,10 @@ lookup_minimal_symbol_linkage (const char *name, struct objfile *objf)
{
if (strcmp (msymbol->linkage_name (), name) == 0
&& (msymbol->type () == mst_data
- || msymbol->type () == mst_bss))
+ || msymbol->type () == mst_bss
+ || (match_static_type
+ && (msymbol->type () == mst_file_data
+ || msymbol->type () == mst_file_bss))))
return {msymbol, objfile};
}
}
@@ -596,7 +600,8 @@ lookup_minimal_symbol_linkage (program_space *pspace, const char *name,
continue;
bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (name,
- objfile);
+ objfile,
+ false);
if (minsym.minsym != nullptr)
return minsym;
}
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index 9659f30dff8..4e6d5db9139 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -227,11 +227,12 @@ bound_minimal_symbol lookup_minimal_symbol_text (program_space *pspace,
objfiles) for a global (not file-local) minsym whose linkage name
is NAME. This is somewhat similar to lookup_minimal_symbol_text,
only data symbols (not text symbols) are considered, and a non-NULL
- objfile is not accepted. Returns a bound minimal symbol that
- matches, or an "empty" bound minimal symbol otherwise. */
+ objfile is not accepted. The boolean argument allows matching the
+ static types of data symbols also. Returns a bound minimal symbol
+ that matches, or an "empty" bound minimal symbol otherwise. */
-extern bound_minimal_symbol lookup_minimal_symbol_linkage (const char *name,
- struct objfile *objf)
+extern bound_minimal_symbol lookup_minimal_symbol_linkage
+ (const char *name, struct objfile *objf, bool match_static_type)
ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2);
/* A variant of lookup_minimal_symbol_linkage that iterates over all
diff --git a/gdb/testsuite/gdb.base/jit-elf-so.exp b/gdb/testsuite/gdb.base/jit-elf-so.exp
index f28c181fa85..2759c641588 100644
--- a/gdb/testsuite/gdb.base/jit-elf-so.exp
+++ b/gdb/testsuite/gdb.base/jit-elf-so.exp
@@ -46,7 +46,8 @@ set jit_solib_srcfile ${srcdir}/${subdir}/${jit_solib_basename}.c
# On failure, return -1.
proc compile_jit_dlmain {options} {
global main_loader_srcfile main_loader_binfile main_loader_basename
- set options [concat $options debug]
+ set options [concat $options debug \
+ additional_flags=-DJIT_DESCRIPTOR_LINKAGE="static"]
if { [gdb_compile ${main_loader_srcfile} ${main_loader_binfile} \
executable $options] != "" } {
@@ -133,7 +134,8 @@ proc one_jit_test {solib_binfiles_target match_str} {
# Compile the main code (which loads the JIT objects) as a shared library.
if { [compile_jit_elf_main_as_so $main_solib_srcfile $main_solib_binfile \
- {additional_flags="-DMAIN=jit_dl_main"}] < 0 } {
+ {additional_flags="-DMAIN=jit_dl_main" \
+ additional_flags="-DJIT_DESCRIPTOR_LINKAGE=static"}] < 0 } {
return
}
diff --git a/gdb/testsuite/gdb.base/jit-protocol.h b/gdb/testsuite/gdb.base/jit-protocol.h
index d143dd6042c..3e85c199c9f 100644
--- a/gdb/testsuite/gdb.base/jit-protocol.h
+++ b/gdb/testsuite/gdb.base/jit-protocol.h
@@ -26,6 +26,10 @@
#include <stdint.h>
+#ifndef JIT_DESCRIPTOR_LINKAGE
+#define JIT_DESCRIPTOR_LINKAGE
+#endif
+
typedef enum
{
JIT_NOACTION = 0,
@@ -51,7 +55,8 @@ struct jit_descriptor
struct jit_code_entry *first_entry;
};
-struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
+JIT_DESCRIPTOR_LINKAGE struct jit_descriptor __jit_debug_descriptor
+ = { 1, 0, 0, 0 };
void __attribute__((noinline)) __jit_debug_register_code()
{
--
2.34.1
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] gdb: Update linkage name lookup function to allow mst_file_data/bss types.
2024-11-12 18:28 ` [PATCH v2 1/1] " Abdul Basit Ijaz
@ 2024-11-15 20:49 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2024-11-15 20:49 UTC (permalink / raw)
To: Abdul Basit Ijaz; +Cc: gdb-patches, tom
>>>>> Abdul Basit Ijaz <abdul.b.ijaz@intel.com> writes:
> Example of minsym for the JIT code emitted by the intel compilers where
> lookup_minimal_symbol_linkage fails without this change because jit_debugger
> type is "mst_file_data".
...
> Updated the test "jit-elf-so.exp" to test the static type of jit_descriptor
> object.
Ok.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-15 20:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12 18:28 [PATCH v2 0/1] gdb: Update linkage name lookup function to allow mst_file_data/bss types Abdul Basit Ijaz
2024-11-12 18:28 ` [PATCH v2 1/1] " Abdul Basit Ijaz
2024-11-15 20:49 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).