* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-25 22:09 [PATCH] Add an Objfile.lookup_global_symbol function Christian Biesinger via gdb-patches
@ 2019-06-26 15:37 ` Eli Zaretskii
2019-06-26 21:05 ` Tom Tromey
2019-06-26 15:38 ` Eli Zaretskii
` (4 subsequent siblings)
5 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2019-06-26 15:37 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Tue, 25 Jun 2019 17:08:32 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 2cc82e8656..e52af20748 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -36,6 +36,9 @@
> ** gdb.Type has a new property 'objfile' which returns the objfile the
> type was defined in.
>
> + ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
> + from this objfile only.
> +
> * New commands
This part is OK.
> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
> +Searches for a global symbol by name in this objfile. Optionally, the
^^
Two spaces between sentences (here and elsewhere in the patch),
please.
The documentation part is OK with this nit fixed.
Thanks.
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-26 15:37 ` Eli Zaretskii
@ 2019-06-26 21:05 ` Tom Tromey
2019-06-27 2:36 ` Eli Zaretskii
0 siblings, 1 reply; 25+ messages in thread
From: Tom Tromey @ 2019-06-26 21:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Christian Biesinger, gdb-patches
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
>> +Searches for a global symbol by name in this objfile. Optionally, the
Eli> ^^
Eli> Two spaces between sentences (here and elsewhere in the patch),
Eli> please.
I wonder whether the parameter names ought to be wrapped in @var{}.
Tom
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-26 21:05 ` Tom Tromey
@ 2019-06-27 2:36 ` Eli Zaretskii
0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-06-27 2:36 UTC (permalink / raw)
To: Tom Tromey; +Cc: cbiesinger, gdb-patches
> From: Tom Tromey <tom@tromey.com>
> Cc: Christian Biesinger <cbiesinger@google.com>, gdb-patches@sourceware.org
> Date: Wed, 26 Jun 2019 15:05:34 -0600
>
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> >> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
> >> +Searches for a global symbol by name in this objfile. Optionally, the
> Eli> ^^
> Eli> Two spaces between sentences (here and elsewhere in the patch),
> Eli> please.
>
> I wonder whether the parameter names ought to be wrapped in @var{}.
It should, thanks for catching that.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-25 22:09 [PATCH] Add an Objfile.lookup_global_symbol function Christian Biesinger via gdb-patches
2019-06-26 15:37 ` Eli Zaretskii
@ 2019-06-26 15:38 ` Eli Zaretskii
2019-06-26 21:12 ` Tom Tromey
` (3 subsequent siblings)
5 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-06-26 15:38 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Tue, 25 Jun 2019 17:08:32 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> gdb/doc/ChangeLog:
>
> 2019-06-25 Christian Biesinger <cbiesinger@google.com>
>
> * python.texi: Document new function Objfile.lookup_global_symbol.
Sorry, forgot to mention one more nit: please name in parentheses the
node in which you make this change. See the other entries in
gdb/doc/ChangeLog for examples.
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-25 22:09 [PATCH] Add an Objfile.lookup_global_symbol function Christian Biesinger via gdb-patches
2019-06-26 15:37 ` Eli Zaretskii
2019-06-26 15:38 ` Eli Zaretskii
@ 2019-06-26 21:12 ` Tom Tromey
2019-07-08 21:59 ` Christian Biesinger via gdb-patches
` (2 subsequent siblings)
5 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2019-06-26 21:12 UTC (permalink / raw)
To: Christian Biesinger via gdb-patches; +Cc: Christian Biesinger
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
Christian> +static PyObject *
Christian> +objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
Christian> +{
...
Christian> + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
Christian> + &domain))
Christian> + Py_RETURN_NONE;
Error cases must return NULL.
Christian> + if (!sym) {
gdb style is an explicit check, like sym != nullptr.
Also the brace is misplaced.
Christian> struct block_symbol
Christian> lookup_global_symbol_from_objfile (struct objfile *main_objfile,
Christian> + int block_index,
Christian> const char *name,
Christian> const domain_enum domain)
I suspect the new parameter should probably have type `enum block_enum'.
Christian> + block_index can be GLOBAL_BLOCK, STATIC_BLOCK, etc.
Does the "etc" case really work? If not it should just assert that the
value is one of GLOBAL_BLOCK or STATIC_BLOCK.
Christian> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
Christian> + "global_var" "lookup_global_symbol find a valid symbol"
Christian> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\").name)" \
Christian> + "static_var" "lookup_global_symbol find a valid static symbol"
Perhaps this ought to test a case where it returns None.
Tom
^ permalink raw reply [flat|nested] 25+ messages in thread* [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-25 22:09 [PATCH] Add an Objfile.lookup_global_symbol function Christian Biesinger via gdb-patches
` (2 preceding siblings ...)
2019-06-26 21:12 ` Tom Tromey
@ 2019-07-08 21:59 ` Christian Biesinger via gdb-patches
2019-07-09 15:42 ` Eli Zaretskii
2019-07-09 18:44 ` Christian Biesinger via gdb-patches
2019-07-22 20:51 ` Christian Biesinger via gdb-patches
5 siblings, 1 reply; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-08 21:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
Thanks for the comments and sorry for the late response.
I believe I've made all requested changes except for
using "enum block_enum" as the argument type -- doing that
requires including defs.h from symtab.h which no other header
does, so I wasn't sure if that was OK. Let me know if this
is fine and I'll make the change.
(Why do many other functions use int for block arguments like
this? Even lookup_symbol_in_objfile_symtabs which has the
same gdb_assert for GLOBAL_BLOCK/STATIC_BLOCK)
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new function Objfile.lookup_global_symbol.
* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function
Objfile.lookup_global_symbol.
* solib-spu.c (spu_lookup_lib_symbol): Pass GLOBAL_SCOPE.
* solib-svr4.c (elf_lookup_lib_symbol): Pass GLOBAL_SCOPE.
* symtab.c (lookup_global_symbol_from_objfile): Add a scope parameter.
* symtab.h: Add a scope parameter to lookup_global_symbol_from_objfile.
gdb/doc/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new function
Objfile.lookup_global_symbol.
gdb/testsuite/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new function Objfile.
lookup_global_symbol.
---
gdb/NEWS | 3 ++
gdb/compile/compile-object-load.c | 1 +
gdb/doc/python.texi | 12 +++++++
gdb/python/py-objfile.c | 45 ++++++++++++++++++++++++-
gdb/solib-spu.c | 3 +-
gdb/solib-svr4.c | 3 +-
gdb/symtab.c | 4 ++-
gdb/symtab.h | 2 ++
gdb/testsuite/gdb.python/py-objfile.c | 3 ++
gdb/testsuite/gdb.python/py-objfile.exp | 7 ++++
10 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 34c544c3d5..922010ed39 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -36,6 +36,9 @@
** gdb.Type has a new property 'objfile' which returns the objfile the
type was defined in.
+ ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
+ from this objfile only.
+
* New commands
| [COMMAND] | SHELL_COMMAND
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 4e70205195..3a765a345b 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -639,6 +639,7 @@ compile_object_load (const compile_file_names &file_names,
objfile = objfile_holder.get ();
func_sym = lookup_global_symbol_from_objfile (objfile,
+ GLOBAL_BLOCK,
GCC_FE_WRAPPER_FUNCTION,
VAR_DOMAIN).symbol;
if (func_sym == NULL)
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index f769ad03a2..3e14d9edb4 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4443,6 +4443,18 @@ searches then this function can be used to add a debug info file
from a different place.
@end defun
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Searches for a global symbol named @var{name} in this objfile. Optionally, the
+search scope can be restricted with the @var{domain} argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in the @xref{Symbols In Python} section. This function is
+similar to @code{gdb.lookup_global_symbol}, except that the search is limited
+to this objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 199c567a04..8499551ff4 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -406,7 +406,7 @@ objfpy_is_valid (PyObject *self, PyObject *args)
Py_RETURN_TRUE;
}
-/* Implementation of gdb.Objfile.add_separate_debug_file (self) -> Boolean. */
+/* Implementation of gdb.Objfile.add_separate_debug_file (self, string) -> None. */
static PyObject *
objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
@@ -434,6 +434,44 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+/* Implementation of gdb.Objfile.lookup_global_symbol (self, string [, int]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return NULL;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == NULL) {
+ sym = lookup_global_symbol_from_objfile
+ (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain)
+ .symbol;
+ if (!sym)
+ Py_RETURN_NONE;
+ }
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
@@ -652,6 +690,11 @@ Return true if this object file is valid, false if not." },
"add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
+ { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_global_symbol (name [, domain]).\n\
+Looks up a global symbol in this objfile and returns it." },
+
{ NULL }
};
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index c5dc8639f1..faa4ac3956 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -392,7 +392,8 @@ spu_lookup_lib_symbol (struct objfile *objfile,
const domain_enum domain)
{
if (bfd_get_arch (objfile->obfd) == bfd_arch_spu)
- return lookup_global_symbol_from_objfile (objfile, name, domain);
+ return lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, name,
+ domain);
if (svr4_so_ops.lookup_lib_global_symbol != NULL)
return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain);
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 8cd5b7d8e7..c0c505acaa 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -3226,7 +3226,8 @@ elf_lookup_lib_symbol (struct objfile *objfile,
if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL, NULL) != 1)
return {};
- return lookup_global_symbol_from_objfile (objfile, name, domain);
+ return lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, name,
+ domain);
}
void
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 4920d94a24..958d2b510f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2223,13 +2223,15 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
+ int block_index,
const char *name,
const domain_enum domain)
{
+ gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
for (objfile *objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result
- = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
+ = lookup_symbol_in_objfile (objfile, block_index, name, domain);
if (result.symbol != NULL)
return result;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index e4ee7271a1..a8ae8d359e 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2051,10 +2051,12 @@ extern enum language main_language (void);
/* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.
This searches MAIN_OBJFILE as well as any associated separate debug info
objfiles of MAIN_OBJFILE.
+ block_index can be GLOBAL_BLOCK or STATIC_BLOCK.
Upon success fixes up the symbol's section if necessary. */
extern struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
+ int block_index,
const char *name,
const domain_enum domain);
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491234..6d751bddae 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e760..3009d0711e 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,13 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol find a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\").name)" \
+ "static_var" "lookup_global_symbol find a valid static symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
--
2.22.0.410.gd8fdbe21b5-goog
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-07-08 21:59 ` Christian Biesinger via gdb-patches
@ 2019-07-09 15:42 ` Eli Zaretskii
0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-09 15:42 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches, cbiesinger
> Date: Mon, 8 Jul 2019 16:59:06 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 34c544c3d5..922010ed39 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -36,6 +36,9 @@
> ** gdb.Type has a new property 'objfile' which returns the objfile the
> type was defined in.
>
> + ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
> + from this objfile only.
> +
This part is OK.
> +The @var{domain} argument must be a domain constant defined in the @code{gdb}
> +module and described in the @xref{Symbols In Python} section. This function is
@ref, not @xref. The latter produces a capitalized "See", which is
inappropriate in the middle of a sentence. Also, please remove the
"section" part after the closing brace; it's redundant.
The documentation parts are OK with these nits fixed.
Thanks.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-25 22:09 [PATCH] Add an Objfile.lookup_global_symbol function Christian Biesinger via gdb-patches
` (3 preceding siblings ...)
2019-07-08 21:59 ` Christian Biesinger via gdb-patches
@ 2019-07-09 18:44 ` Christian Biesinger via gdb-patches
2019-07-09 19:16 ` Eli Zaretskii
2019-07-22 20:51 ` Christian Biesinger via gdb-patches
5 siblings, 1 reply; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-09 18:44 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
As discussed on IRC, moved the declaration of the enum before
the gdbarch.h include so that this compiles. Also changed NULL
to nullptr and fixed the documentation issue noted by Eli.
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new function Objfile.lookup_global_symbol.
* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
* defs.h (enum block_enum): Move before the gdbarch.h include so that
symtab.h can use this enum.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function
Objfile.lookup_global_symbol.
* solib-spu.c (spu_lookup_lib_symbol): Pass GLOBAL_SCOPE.
* solib-svr4.c (elf_lookup_lib_symbol): Pass GLOBAL_SCOPE.
* symtab.c (lookup_global_symbol_from_objfile): Add a scope parameter.
* symtab.h: Add a scope parameter to lookup_global_symbol_from_objfile.
gdb/doc/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new function
Objfile.lookup_global_symbol.
gdb/testsuite/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new function Objfile.
lookup_global_symbol.
---
gdb/NEWS | 3 ++
gdb/compile/compile-object-load.c | 1 +
gdb/defs.h | 18 +++++-----
gdb/doc/python.texi | 12 +++++++
gdb/python/py-objfile.c | 45 ++++++++++++++++++++++++-
gdb/solib-spu.c | 3 +-
gdb/solib-svr4.c | 3 +-
gdb/symtab.c | 7 ++--
gdb/symtab.h | 2 ++
gdb/testsuite/gdb.python/py-objfile.c | 3 ++
gdb/testsuite/gdb.python/py-objfile.exp | 7 ++++
11 files changed, 90 insertions(+), 14 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 34c544c3d5..922010ed39 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -36,6 +36,9 @@
** gdb.Type has a new property 'objfile' which returns the objfile the
type was defined in.
+ ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
+ from this objfile only.
+
* New commands
| [COMMAND] | SHELL_COMMAND
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 4e70205195..3a765a345b 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -639,6 +639,7 @@ compile_object_load (const compile_file_names &file_names,
objfile = objfile_holder.get ();
func_sym = lookup_global_symbol_from_objfile (objfile,
+ GLOBAL_BLOCK,
GCC_FE_WRAPPER_FUNCTION,
VAR_DOMAIN).symbol;
if (func_sym == NULL)
diff --git a/gdb/defs.h b/gdb/defs.h
index 81ab74c27f..4702f44afa 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -519,6 +519,15 @@ enum symbol_needs_kind
SYMBOL_NEEDS_FRAME
};
+/* * Special block numbers */
+
+enum block_enum
+{
+ GLOBAL_BLOCK = 0,
+ STATIC_BLOCK = 1,
+ FIRST_LOCAL_BLOCK = 2
+};
+
/* Dynamic target-system-dependent parameters for GDB. */
#include "gdbarch.h"
@@ -628,15 +637,6 @@ extern int (*deprecated_ui_load_progress_hook) (const char *section,
extern void initialize_progspace (void);
extern void initialize_inferiors (void);
-/* * Special block numbers */
-
-enum block_enum
-{
- GLOBAL_BLOCK = 0,
- STATIC_BLOCK = 1,
- FIRST_LOCAL_BLOCK = 2
-};
-
/* User selection used in observable.h and multiple print functions. */
enum user_selected_what_flag
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index f769ad03a2..320f583bbb 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4443,6 +4443,18 @@ searches then this function can be used to add a debug info file
from a different place.
@end defun
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Searches for a global symbol named @var{name} in this objfile. Optionally, the
+search scope can be restricted with the @var{domain} argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in @ref{Symbols In Python}. This function is similar to
+@code{gdb.lookup_global_symbol}, except that the search is limited to this
+objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 199c567a04..a34b68dc49 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -406,7 +406,7 @@ objfpy_is_valid (PyObject *self, PyObject *args)
Py_RETURN_TRUE;
}
-/* Implementation of gdb.Objfile.add_separate_debug_file (self) -> Boolean. */
+/* Implementation of gdb.Objfile.add_separate_debug_file (self, string) -> None. */
static PyObject *
objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
@@ -434,6 +434,44 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+/* Implementation of gdb.Objfile.lookup_global_symbol (self, string [, int]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr) {
+ sym = lookup_global_symbol_from_objfile
+ (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain)
+ .symbol;
+ if (!sym)
+ Py_RETURN_NONE;
+ }
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
@@ -652,6 +690,11 @@ Return true if this object file is valid, false if not." },
"add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
+ { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_global_symbol (name [, domain]).\n\
+Looks up a global symbol in this objfile and returns it." },
+
{ NULL }
};
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index c5dc8639f1..faa4ac3956 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -392,7 +392,8 @@ spu_lookup_lib_symbol (struct objfile *objfile,
const domain_enum domain)
{
if (bfd_get_arch (objfile->obfd) == bfd_arch_spu)
- return lookup_global_symbol_from_objfile (objfile, name, domain);
+ return lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, name,
+ domain);
if (svr4_so_ops.lookup_lib_global_symbol != NULL)
return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain);
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 8cd5b7d8e7..c0c505acaa 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -3226,7 +3226,8 @@ elf_lookup_lib_symbol (struct objfile *objfile,
if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL, NULL) != 1)
return {};
- return lookup_global_symbol_from_objfile (objfile, name, domain);
+ return lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, name,
+ domain);
}
void
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 4920d94a24..4e8c58f272 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2223,15 +2223,18 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
+ enum block_enum block_index,
const char *name,
const domain_enum domain)
{
+ gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
+
for (objfile *objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result
- = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
+ = lookup_symbol_in_objfile (objfile, block_index, name, domain);
- if (result.symbol != NULL)
+ if (result.symbol != nullptr)
return result;
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index e4ee7271a1..0e808a68c2 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2051,10 +2051,12 @@ extern enum language main_language (void);
/* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.
This searches MAIN_OBJFILE as well as any associated separate debug info
objfiles of MAIN_OBJFILE.
+ block_index can be GLOBAL_BLOCK or STATIC_BLOCK.
Upon success fixes up the symbol's section if necessary. */
extern struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
+ enum block_enum block_index,
const char *name,
const domain_enum domain);
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491234..6d751bddae 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e760..3009d0711e 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,13 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol find a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\").name)" \
+ "static_var" "lookup_global_symbol find a valid static symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
--
2.22.0.410.gd8fdbe21b5-goog
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-07-09 18:44 ` Christian Biesinger via gdb-patches
@ 2019-07-09 19:16 ` Eli Zaretskii
0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-09 19:16 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Tue, 9 Jul 2019 13:44:04 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> As discussed on IRC, moved the declaration of the enum before
> the gdbarch.h include so that this compiles. Also changed NULL
> to nullptr and fixed the documentation issue noted by Eli.
Thanks, the documentation parts are OK.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH] Add an Objfile.lookup_global_symbol function
2019-06-25 22:09 [PATCH] Add an Objfile.lookup_global_symbol function Christian Biesinger via gdb-patches
` (4 preceding siblings ...)
2019-07-09 18:44 ` Christian Biesinger via gdb-patches
@ 2019-07-22 20:51 ` Christian Biesinger via gdb-patches
2019-07-23 1:30 ` Simon Marchi
2019-07-23 14:54 ` Eli Zaretskii
5 siblings, 2 replies; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-22 20:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
Per the discussion in the thread about my gdb.lookup_global_symbol
patch, I've changed this patch to only look in GLOBAL_SCOPE.
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new function Objfile.lookup_global_symbol.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function
Objfile.lookup_global_symbol.
gdb/doc/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new function
Objfile.lookup_global_symbol.
gdb/testsuite/ChangeLog:
2019-06-25 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new function Objfile.
lookup_global_symbol.
---
gdb/NEWS | 3 ++
gdb/doc/python.texi | 12 ++++++++
gdb/python/py-objfile.c | 40 ++++++++++++++++++++++++-
gdb/testsuite/gdb.python/py-objfile.c | 3 ++
gdb/testsuite/gdb.python/py-objfile.exp | 7 +++++
5 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index cc1d58520d..c57cb4576e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -36,6 +36,9 @@
** gdb.Type has a new property 'objfile' which returns the objfile the
type was defined in.
+ ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
+ from this objfile only.
+
* New commands
| [COMMAND] | SHELL_COMMAND
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 034623513b..80da607824 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4441,6 +4441,18 @@ searches then this function can be used to add a debug info file
from a different place.
@end defun
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Searches for a global symbol named @var{name} in this objfile. Optionally, the
+search scope can be restricted with the @var{domain} argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in @ref{Symbols In Python}. This function is similar to
+@code{gdb.lookup_global_symbol}, except that the search is limited to this
+objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 199c567a04..a9a6ae6725 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -406,7 +406,7 @@ objfpy_is_valid (PyObject *self, PyObject *args)
Py_RETURN_TRUE;
}
-/* Implementation of gdb.Objfile.add_separate_debug_file (self) -> Boolean. */
+/* Implementation of gdb.Objfile.add_separate_debug_file (self, string) -> None. */
static PyObject *
objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
@@ -434,6 +434,39 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+/* Implementation of gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
@@ -652,6 +685,11 @@ Return true if this object file is valid, false if not." },
"add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
+ { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_global_symbol (name [, domain]).\n\
+Looks up a global symbol in this objfile and returns it." },
+
{ NULL }
};
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491234..6d751bddae 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e760..2e8358bd76 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,13 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol finds a valid symbol"
+gdb_test "python print gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\") is None" \
+ "True" "lookup_global_symbol does not find static symbols"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
--
2.22.0.657.g960e92d24f-goog
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-07-22 20:51 ` Christian Biesinger via gdb-patches
@ 2019-07-23 1:30 ` Simon Marchi
2019-07-23 14:47 ` Eli Zaretskii
2019-07-26 1:38 ` Christian Biesinger via gdb-patches
2019-07-23 14:54 ` Eli Zaretskii
1 sibling, 2 replies; 25+ messages in thread
From: Simon Marchi @ 2019-07-23 1:30 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches, Eli Zaretskii
Hi Christian,
What did you end up deciding, to let Python code search for static symbols?
I just have a few nits on the patch below (and some questions about the doc,
which is why I added Eli in CC).
On 2019-07-22 4:51 p.m., Christian Biesinger via gdb-patches wrote:
> Per the discussion in the thread about my gdb.lookup_global_symbol
> patch, I've changed this patch to only look in GLOBAL_SCOPE.
>
> This is essentially the inverse of Symbol.objfile. This allows
> handling different symbols with the same name (but from different
> objfiles) and can also be faster if the objfile is known.
>
> gdb/ChangeLog:
>
> 2019-06-25 Christian Biesinger <cbiesinger@google.com>
>
> * NEWS: Mention new function Objfile.lookup_global_symbol.
> * python/py-objfile.c (objfpy_lookup_global_symbol): New function
> Objfile.lookup_global_symbol.
>
> gdb/doc/ChangeLog:
>
> 2019-06-25 Christian Biesinger <cbiesinger@google.com>
>
> * python.texi (Objfiles In Python): Document new function
> Objfile.lookup_global_symbol.
>
> gdb/testsuite/ChangeLog:
>
> 2019-06-25 Christian Biesinger <cbiesinger@google.com>
>
> * gdb.python/py-objfile.c: Add global and static vars.
> * gdb.python/py-objfile.exp: Test new function Objfile.
> lookup_global_symbol.
> ---
> gdb/NEWS | 3 ++
> gdb/doc/python.texi | 12 ++++++++
> gdb/python/py-objfile.c | 40 ++++++++++++++++++++++++-
> gdb/testsuite/gdb.python/py-objfile.c | 3 ++
> gdb/testsuite/gdb.python/py-objfile.exp | 7 +++++
> 5 files changed, 64 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index cc1d58520d..c57cb4576e 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -36,6 +36,9 @@
> ** gdb.Type has a new property 'objfile' which returns the objfile the
> type was defined in.
>
> + ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
> + from this objfile only.
> +
> * New commands
>
> | [COMMAND] | SHELL_COMMAND
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index 034623513b..80da607824 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -4441,6 +4441,18 @@ searches then this function can be used to add a debug info file
> from a different place.
> @end defun
>
> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
> +Searches for a global symbol named @var{name} in this objfile. Optionally, the
> +search scope can be restricted with the @var{domain} argument.
> +The @var{domain} argument must be a domain constant defined in the @code{gdb}
> +module and described in @ref{Symbols In Python}. This function is similar to
> +@code{gdb.lookup_global_symbol}, except that the search is limited to this
> +objfile.
> +
> +The result is a @code{gdb.Symbol} object or @code{None} if the symbol
> +is not found.
> +@end defun
> +
> @node Frames In Python
> @subsubsection Accessing inferior stack frames from Python
>
> diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
> index 199c567a04..a9a6ae6725 100644
> --- a/gdb/python/py-objfile.c
> +++ b/gdb/python/py-objfile.c
> @@ -406,7 +406,7 @@ objfpy_is_valid (PyObject *self, PyObject *args)
> Py_RETURN_TRUE;
> }
>
> -/* Implementation of gdb.Objfile.add_separate_debug_file (self) -> Boolean. */
> +/* Implementation of gdb.Objfile.add_separate_debug_file (self, string) -> None. */
This appears to be an unrelated (but valid) change. Can you please make a separate patch
and push it as obvious? Just mind the 80 columns. If the function returns None, I think
we could just omit the return type and say:
/* Implementation of gdb.Objfile.add_separate_debug_file (self, string). */
... and it will fit.
So just push a patch with this (including the ChangeLog entry), and post it to the list
with the "PATCH obvious" prefix, or something like that, to let people know.
> static PyObject *
> objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
> @@ -434,6 +434,39 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
> Py_RETURN_NONE;
> }
>
> +/* Implementation of gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
> +
> +static PyObject *
> +objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
> +{
> + static const char *keywords[] = { "name", "domain", NULL };
> + objfile_object *obj = (objfile_object *) self;
> + const char *symbol_name;
> + int domain = VAR_DOMAIN;
> +
> + OBJFPY_REQUIRE_VALID (obj);
> +
> + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
> + &domain))
> + return nullptr;
> +
> + try
> + {
> + struct symbol *sym = lookup_global_symbol_from_objfile
> + (obj->objfile, symbol_name, (domain_enum) domain).symbol;
> + if (sym == nullptr)
> + Py_RETURN_NONE;
> +
> + return symbol_to_symbol_object (sym);
> + }
> + catch (const gdb_exception &except)
> + {
> + GDB_PY_HANDLE_EXCEPTION (except);
> + }
> +
> + Py_RETURN_NONE;
> +}
> +
> /* Implement repr() for gdb.Objfile. */
>
> static PyObject *
> @@ -652,6 +685,11 @@ Return true if this object file is valid, false if not." },
> "add_separate_debug_file (file_name).\n\
> Add FILE_NAME to the list of files containing debug info for the objfile." },
>
> + { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
> + METH_VARARGS | METH_KEYWORDS,
> + "lookup_global_symbol (name [, domain]).\n\
> +Looks up a global symbol in this objfile and returns it." },
> +
To be consistent with the rest of the Python function help strings, I think it should
be
"Look up a global symbol in this objfile and return it."
i.e. not at the third person of the singular. Eli, could you tell which form is preferred?
The change to python.texi might also need to be changed to that form as well.
> { NULL }
> };
>
> diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
> index ac41491234..6d751bddae 100644
> --- a/gdb/testsuite/gdb.python/py-objfile.c
> +++ b/gdb/testsuite/gdb.python/py-objfile.c
> @@ -15,6 +15,9 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +int global_var = 42;
> +static int static_var = 50;
> +
> int
> main ()
> {
> diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
> index b5e0c5e760..2e8358bd76 100644
> --- a/gdb/testsuite/gdb.python/py-objfile.exp
> +++ b/gdb/testsuite/gdb.python/py-objfile.exp
> @@ -55,6 +55,13 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
> gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
> "Objfile not found\\.\r\n${python_error_text}"
>
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
> + "global_var" "lookup_global_symbol finds a valid symbol"
> +gdb_test "python print gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\") is None" \
> + "True" "lookup_global_symbol does not find static symbols"
Please add parentheses to this print so it works with Python 3.
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
> + "None" "lookup_global_symbol doesn't find symbol in other objfile"
> +
> set binfile_build_id [get_build_id $binfile]
> if [string compare $binfile_build_id ""] {
> verbose -log "binfile_build_id = $binfile_build_id"
>
Simon
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-07-23 1:30 ` Simon Marchi
@ 2019-07-23 14:47 ` Eli Zaretskii
2019-07-26 1:38 ` Christian Biesinger via gdb-patches
1 sibling, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-23 14:47 UTC (permalink / raw)
To: Simon Marchi; +Cc: cbiesinger, gdb-patches
> From: Simon Marchi <simark@simark.ca>
> Date: Mon, 22 Jul 2019 21:30:08 -0400
>
> > + { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
> > + METH_VARARGS | METH_KEYWORDS,
> > + "lookup_global_symbol (name [, domain]).\n\
> > +Looks up a global symbol in this objfile and returns it." },
> > +
>
> To be consistent with the rest of the Python function help strings, I think it should
> be
>
> "Look up a global symbol in this objfile and return it."
>
> i.e. not at the third person of the singular. Eli, could you tell which form is preferred?
Your (Simon's) suggestion is the preferred form.
Thanks.
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-07-23 1:30 ` Simon Marchi
2019-07-23 14:47 ` Eli Zaretskii
@ 2019-07-26 1:38 ` Christian Biesinger via gdb-patches
2019-07-26 1:38 ` [PATCH v2] " Christian Biesinger via gdb-patches
2019-07-26 15:40 ` [PATCH] Add an Objfile.lookup_global_symbol function Simon Marchi
1 sibling, 2 replies; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-26 1:38 UTC (permalink / raw)
To: Simon Marchi; +Cc: Christian Biesinger via gdb-patches, Eli Zaretskii
On Mon, Jul 22, 2019 at 6:30 PM Simon Marchi <simark@simark.ca> wrote:
> What did you end up deciding, to let Python code search for static symbols?
I decided to follow your suggestion and add a lookup_static_symbol
function (to Objfile and gdb). I haven't had time to implement it yet
but hopefully I can do that in the next couple of days. Would you like
me to do Objfile.lookup_static_symbol as part of this patch or
together with gdb.lookup_static_symbol?
> I just have a few nits on the patch below (and some questions about the doc,
> which is why I added Eli in CC).
Will send a new patch momentarily.
> On 2019-07-22 4:51 p.m., Christian Biesinger via gdb-patches wrote:
> > Per the discussion in the thread about my gdb.lookup_global_symbol
> > patch, I've changed this patch to only look in GLOBAL_SCOPE.
> >
> > This is essentially the inverse of Symbol.objfile. This allows
> > handling different symbols with the same name (but from different
> > objfiles) and can also be faster if the objfile is known.
> >
> > gdb/ChangeLog:
> >
> > 2019-06-25 Christian Biesinger <cbiesinger@google.com>
> >
> > * NEWS: Mention new function Objfile.lookup_global_symbol.
> > * python/py-objfile.c (objfpy_lookup_global_symbol): New function
> > Objfile.lookup_global_symbol.
> >
> > gdb/doc/ChangeLog:
> >
> > 2019-06-25 Christian Biesinger <cbiesinger@google.com>
> >
> > * python.texi (Objfiles In Python): Document new function
> > Objfile.lookup_global_symbol.
> >
> > gdb/testsuite/ChangeLog:
> >
> > 2019-06-25 Christian Biesinger <cbiesinger@google.com>
> >
> > * gdb.python/py-objfile.c: Add global and static vars.
> > * gdb.python/py-objfile.exp: Test new function Objfile.
> > lookup_global_symbol.
> > ---
> > gdb/NEWS | 3 ++
> > gdb/doc/python.texi | 12 ++++++++
> > gdb/python/py-objfile.c | 40 ++++++++++++++++++++++++-
> > gdb/testsuite/gdb.python/py-objfile.c | 3 ++
> > gdb/testsuite/gdb.python/py-objfile.exp | 7 +++++
> > 5 files changed, 64 insertions(+), 1 deletion(-)
> >
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index cc1d58520d..c57cb4576e 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -36,6 +36,9 @@
> > ** gdb.Type has a new property 'objfile' which returns the objfile the
> > type was defined in.
> >
> > + ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
> > + from this objfile only.
> > +
> > * New commands
> >
> > | [COMMAND] | SHELL_COMMAND
> > diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> > index 034623513b..80da607824 100644
> > --- a/gdb/doc/python.texi
> > +++ b/gdb/doc/python.texi
> > @@ -4441,6 +4441,18 @@ searches then this function can be used to add a debug info file
> > from a different place.
> > @end defun
> >
> > +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
> > +Searches for a global symbol named @var{name} in this objfile. Optionally, the
> > +search scope can be restricted with the @var{domain} argument.
> > +The @var{domain} argument must be a domain constant defined in the @code{gdb}
> > +module and described in @ref{Symbols In Python}. This function is similar to
> > +@code{gdb.lookup_global_symbol}, except that the search is limited to this
> > +objfile.
> > +
> > +The result is a @code{gdb.Symbol} object or @code{None} if the symbol
> > +is not found.
> > +@end defun
> > +
> > @node Frames In Python
> > @subsubsection Accessing inferior stack frames from Python
> >
> > diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
> > index 199c567a04..a9a6ae6725 100644
> > --- a/gdb/python/py-objfile.c
> > +++ b/gdb/python/py-objfile.c
> > @@ -406,7 +406,7 @@ objfpy_is_valid (PyObject *self, PyObject *args)
> > Py_RETURN_TRUE;
> > }
> >
> > -/* Implementation of gdb.Objfile.add_separate_debug_file (self) -> Boolean. */
> > +/* Implementation of gdb.Objfile.add_separate_debug_file (self, string) -> None. */
>
> This appears to be an unrelated (but valid) change. Can you please make a separate patch
> and push it as obvious? Just mind the 80 columns. If the function returns None, I think
> we could just omit the return type and say:
>
> /* Implementation of gdb.Objfile.add_separate_debug_file (self, string). */
>
> ... and it will fit.
>
> So just push a patch with this (including the ChangeLog entry), and post it to the list
> with the "PATCH obvious" prefix, or something like that, to let people know.
OK, done. (Oops, I see you already answered my question here that I
asked you again on IRC)
> > static PyObject *
> > objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
> > @@ -434,6 +434,39 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
> > Py_RETURN_NONE;
> > }
> >
> > +/* Implementation of gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
>
> > +
> > +static PyObject *
> > +objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
> > +{
> > + static const char *keywords[] = { "name", "domain", NULL };
> > + objfile_object *obj = (objfile_object *) self;
> > + const char *symbol_name;
> > + int domain = VAR_DOMAIN;
> > +
> > + OBJFPY_REQUIRE_VALID (obj);
> > +
> > + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
> > + &domain))
> > + return nullptr;
> > +
> > + try
> > + {
> > + struct symbol *sym = lookup_global_symbol_from_objfile
> > + (obj->objfile, symbol_name, (domain_enum) domain).symbol;
> > + if (sym == nullptr)
> > + Py_RETURN_NONE;
> > +
> > + return symbol_to_symbol_object (sym);
> > + }
> > + catch (const gdb_exception &except)
> > + {
> > + GDB_PY_HANDLE_EXCEPTION (except);
> > + }
> > +
> > + Py_RETURN_NONE;
> > +}
> > +
> > /* Implement repr() for gdb.Objfile. */
> >
> > static PyObject *
> > @@ -652,6 +685,11 @@ Return true if this object file is valid, false if not." },
> > "add_separate_debug_file (file_name).\n\
> > Add FILE_NAME to the list of files containing debug info for the objfile." },
> >
> > + { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
> > + METH_VARARGS | METH_KEYWORDS,
> > + "lookup_global_symbol (name [, domain]).\n\
> > +Looks up a global symbol in this objfile and returns it." },
> > +
>
> To be consistent with the rest of the Python function help strings, I think it should
> be
>
> "Look up a global symbol in this objfile and return it."
>
> i.e. not at the third person of the singular. Eli, could you tell which form is preferred?
> The change to python.texi might also need to be changed to that form as well.
>
> > { NULL }
> > };
> >
> > diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
> > index ac41491234..6d751bddae 100644
> > --- a/gdb/testsuite/gdb.python/py-objfile.c
> > +++ b/gdb/testsuite/gdb.python/py-objfile.c
> > @@ -15,6 +15,9 @@
> > You should have received a copy of the GNU General Public License
> > along with this program. If not, see <http://www.gnu.org/licenses/>. */
> >
> > +int global_var = 42;
> > +static int static_var = 50;
> > +
> > int
> > main ()
> > {
> > diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
> > index b5e0c5e760..2e8358bd76 100644
> > --- a/gdb/testsuite/gdb.python/py-objfile.exp
> > +++ b/gdb/testsuite/gdb.python/py-objfile.exp
> > @@ -55,6 +55,13 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
> > gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
> > "Objfile not found\\.\r\n${python_error_text}"
> >
> > +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
> > + "global_var" "lookup_global_symbol finds a valid symbol"
> > +gdb_test "python print gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\") is None" \
> > + "True" "lookup_global_symbol does not find static symbols"
>
> Please add parentheses to this print so it works with Python 3.
>
> > +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
> > + "None" "lookup_global_symbol doesn't find symbol in other objfile"
> > +
> > set binfile_build_id [get_build_id $binfile]
> > if [string compare $binfile_build_id ""] {
> > verbose -log "binfile_build_id = $binfile_build_id"
> >
>
> Simon
^ permalink raw reply [flat|nested] 25+ messages in thread* [PATCH v2] Add an Objfile.lookup_global_symbol function
2019-07-26 1:38 ` Christian Biesinger via gdb-patches
@ 2019-07-26 1:38 ` Christian Biesinger via gdb-patches
2019-07-26 6:19 ` Eli Zaretskii
2019-07-27 0:31 ` [PATCH v3] Add Objfile.lookup_{global,static}_symbol functions Christian Biesinger via gdb-patches
2019-07-26 15:40 ` [PATCH] Add an Objfile.lookup_global_symbol function Simon Marchi
1 sibling, 2 replies; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-26 1:38 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
Per the discussion in the thread about my gdb.lookup_global_symbol
patch, I've changed this patch to only look in GLOBAL_SCOPE.
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new function Objfile.lookup_global_symbol.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function
Objfile.lookup_global_symbol.
gdb/doc/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new function
Objfile.lookup_global_symbol.
gdb/testsuite/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new function Objfile.
lookup_global_symbol.
---
gdb/NEWS | 3 ++
gdb/doc/python.texi | 12 ++++++++
gdb/python/py-objfile.c | 39 +++++++++++++++++++++++++
gdb/testsuite/gdb.python/py-objfile.c | 3 ++
gdb/testsuite/gdb.python/py-objfile.exp | 7 +++++
5 files changed, 64 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index cc1d58520d..c57cb4576e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -36,6 +36,9 @@
** gdb.Type has a new property 'objfile' which returns the objfile the
type was defined in.
+ ** gdb.Objfile has a new method 'lookup_global_symbol' to lookup a symbol
+ from this objfile only.
+
* New commands
| [COMMAND] | SHELL_COMMAND
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 034623513b..fc7cc45260 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4441,6 +4441,18 @@ searches then this function can be used to add a debug info file
from a different place.
@end defun
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Search for a global symbol named @var{name} in this objfile. Optionally, the
+search scope can be restricted with the @var{domain} argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in @ref{Symbols In Python}. This function is similar to
+@code{gdb.lookup_global_symbol}, except that the search is limited to this
+objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 15735c8501..b27f180d34 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -434,6 +434,40 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+/* Implementation of
+ gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
@@ -652,6 +686,11 @@ Return true if this object file is valid, false if not." },
"add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
+ { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_global_symbol (name [, domain]).\n\
+Look up a global symbol in this objfile and returns it." },
+
{ NULL }
};
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491234..6d751bddae 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e760..5ce8665e8c 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,13 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\")) is None" \
+ "True" "lookup_global_symbol does not find static symbols"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
--
2.22.0.709.g102302147b-goog
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v2] Add an Objfile.lookup_global_symbol function
2019-07-26 1:38 ` [PATCH v2] " Christian Biesinger via gdb-patches
@ 2019-07-26 6:19 ` Eli Zaretskii
2019-07-27 0:31 ` [PATCH v3] Add Objfile.lookup_{global,static}_symbol functions Christian Biesinger via gdb-patches
1 sibling, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-26 6:19 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Thu, 25 Jul 2019 20:38:24 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> Per the discussion in the thread about my gdb.lookup_global_symbol
> patch, I've changed this patch to only look in GLOBAL_SCOPE.
>
> This is essentially the inverse of Symbol.objfile. This allows
> handling different symbols with the same name (but from different
> objfiles) and can also be faster if the objfile is known.
>
> gdb/ChangeLog:
>
> 2019-07-25 Christian Biesinger <cbiesinger@google.com>
>
> * NEWS: Mention new function Objfile.lookup_global_symbol.
> * python/py-objfile.c (objfpy_lookup_global_symbol): New function
> Objfile.lookup_global_symbol.
>
> gdb/doc/ChangeLog:
>
> 2019-07-25 Christian Biesinger <cbiesinger@google.com>
>
> * python.texi (Objfiles In Python): Document new function
> Objfile.lookup_global_symbol.
>
> gdb/testsuite/ChangeLog:
>
> 2019-07-25 Christian Biesinger <cbiesinger@google.com>
>
> * gdb.python/py-objfile.c: Add global and static vars.
> * gdb.python/py-objfile.exp: Test new function Objfile.
> lookup_global_symbol.
Thanks, the documentation parts are OK.
^ permalink raw reply [flat|nested] 25+ messages in thread* [PATCH v3] Add Objfile.lookup_{global,static}_symbol functions
2019-07-26 1:38 ` [PATCH v2] " Christian Biesinger via gdb-patches
2019-07-26 6:19 ` Eli Zaretskii
@ 2019-07-27 0:31 ` Christian Biesinger via gdb-patches
2019-07-27 7:52 ` Eli Zaretskii
1 sibling, 1 reply; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-27 0:31 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
In this version of the patch, I also added lookup_static_symbol,
similar to https://sourceware.org/ml/gdb-patches/2019-07/msg00599.html
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function.
(objfpy_lookup_static_symbol): New function.
(objfile_object_methods): Add new functions.
gdb/doc/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new functions
Objfile.lookup_{global,static}_symbol.
gdb/testsuite/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new functions Objfile.
lookup_global_symbol and lookup_static_symbol.
---
gdb/NEWS | 3 +
gdb/doc/python.texi | 25 ++++++++
gdb/python/py-objfile.c | 78 +++++++++++++++++++++++++
gdb/testsuite/gdb.python/py-objfile.c | 3 +
gdb/testsuite/gdb.python/py-objfile.exp | 14 +++++
5 files changed, 123 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index cc1d58520d..d8fb4cfe7f 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -36,6 +36,9 @@
** gdb.Type has a new property 'objfile' which returns the objfile the
type was defined in.
+ ** gdb.Objfile has new methods 'lookup_global_symbol' and
+ 'lookup_static_symbol' to lookup a symbol from this objfile only.
+
* New commands
| [COMMAND] | SHELL_COMMAND
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 034623513b..0a86ea2431 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4441,6 +4441,31 @@ searches then this function can be used to add a debug info file
from a different place.
@end defun
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Search for a global symbol named @var{name} in this objfile. Optionally, the
+search scope can be restricted with the @var{domain} argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in @ref{Symbols In Python}. This function is similar to
+@code{gdb.lookup_global_symbol}, except that the search is limited to this
+objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Search for a global symbol with static linkage named @var{name} in this
+objfile. Optionally, the search scope can be restricted with the @var{domain}
+argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in @ref{Symbols In Python}. This function is similar to
+@code{gdb.lookup_global_symbol}, except that the search is limited to this
+objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 15735c8501..89e23bf4ff 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -434,6 +434,74 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+/* Implementation of
+ gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* Implementation of
+ gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
@@ -652,6 +720,16 @@ Return true if this object file is valid, false if not." },
"add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
+ { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_global_symbol (name [, domain]).\n\
+Look up a global symbol in this objfile and return it." },
+
+ { "lookup_static_symbol", (PyCFunction) objfpy_lookup_static_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_static_symbol (name [, domain]).\n\
+Look up a static-linkage global symbol in this objfile and return it." },
+
{ NULL }
};
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491234..6d751bddae 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e760..1b8acf47ed 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,20 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\")) is None" \
+ "True" "lookup_global_symbol does not find static symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"static_var\").name)" \
+ "static_var" "lookup_static_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"global_var\")) is None" \
+ "True" "lookup_static_symbol does not find global symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"nonexistant\"))" \
+ "None" "lookup_static_symbol can handle nonexistant symbol"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
--
2.22.0.709.g102302147b-goog
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v3] Add Objfile.lookup_{global,static}_symbol functions
2019-07-27 0:31 ` [PATCH v3] Add Objfile.lookup_{global,static}_symbol functions Christian Biesinger via gdb-patches
@ 2019-07-27 7:52 ` Eli Zaretskii
2019-07-27 18:31 ` [PATCH v4] " Christian Biesinger via gdb-patches
0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-27 7:52 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Fri, 26 Jul 2019 19:30:56 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index cc1d58520d..d8fb4cfe7f 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -36,6 +36,9 @@
> ** gdb.Type has a new property 'objfile' which returns the objfile the
> type was defined in.
>
> + ** gdb.Objfile has new methods 'lookup_global_symbol' and
> + 'lookup_static_symbol' to lookup a symbol from this objfile only.
> +
This part is OK.
> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
> +Search for a global symbol named @var{name} in this objfile. Optionally, the
> +search scope can be restricted with the @var{domain} argument.
> +The @var{domain} argument must be a domain constant defined in the @code{gdb}
> +module and described in @ref{Symbols In Python}. This function is similar to
> +@code{gdb.lookup_global_symbol}, except that the search is limited to this
> +objfile.
> +
> +The result is a @code{gdb.Symbol} object or @code{None} if the symbol
> +is not found.
> +@end defun
> +
> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
I guess you meant lookup_static_symbol here?
> +Search for a global symbol with static linkage named @var{name} in this
> +objfile. Optionally, the search scope can be restricted with the @var{domain}
> +argument.
> +The @var{domain} argument must be a domain constant defined in the @code{gdb}
> +module and described in @ref{Symbols In Python}. This function is similar to
> +@code{gdb.lookup_global_symbol}, except that the search is limited to this
> +objfile.
> +
> +The result is a @code{gdb.Symbol} object or @code{None} if the symbol
> +is not found.
> +@end defun
As the description of both methods is almost identical, I wonder
whether it wouldn't be better to have the second method be described
as "Like @code{lookup_global_symbol}, but ..." and tell the
differences between them.
Thanks.
^ permalink raw reply [flat|nested] 25+ messages in thread* [PATCH v4] Add Objfile.lookup_{global,static}_symbol functions
2019-07-27 7:52 ` Eli Zaretskii
@ 2019-07-27 18:31 ` Christian Biesinger via gdb-patches
2019-07-27 18:38 ` Eli Zaretskii
2019-07-30 1:03 ` Simon Marchi
0 siblings, 2 replies; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-27 18:31 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
Thanks Eli, fixed in this version.
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function.
(objfpy_lookup_static_symbol): New function.
(objfile_object_methods): Add new functions.
gdb/doc/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new functions
Objfile.lookup_{global,static}_symbol.
gdb/testsuite/ChangeLog:
2019-07-25 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new functions Objfile.
lookup_global_symbol and lookup_static_symbol.
---
gdb/NEWS | 3 +
gdb/doc/python.texi | 17 ++++++
gdb/python/py-objfile.c | 78 +++++++++++++++++++++++++
gdb/testsuite/gdb.python/py-objfile.c | 3 +
gdb/testsuite/gdb.python/py-objfile.exp | 14 +++++
5 files changed, 115 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index cc1d58520d..d8fb4cfe7f 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -36,6 +36,9 @@
** gdb.Type has a new property 'objfile' which returns the objfile the
type was defined in.
+ ** gdb.Objfile has new methods 'lookup_global_symbol' and
+ 'lookup_static_symbol' to lookup a symbol from this objfile only.
+
* New commands
| [COMMAND] | SHELL_COMMAND
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 034623513b..bbba519ffc 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4441,6 +4441,23 @@ searches then this function can be used to add a debug info file
from a different place.
@end defun
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Search for a global symbol named @var{name} in this objfile. Optionally, the
+search scope can be restricted with the @var{domain} argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in @ref{Symbols In Python}. This function is similar to
+@code{gdb.lookup_global_symbol}, except that the search is limited to this
+objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
+@defun Objfile.lookup_static_symbol (name @r{[}, domain@r{]})
+Like @code{Objfile.lookup_global_symbol}, but searches for a global
+symbol with static linkage named @var{name} in this objfile.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 15735c8501..2c548450b4 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -434,6 +434,74 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+/* Implementation of
+ gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* Implementation of
+ gdb.Objfile.lookup_static_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
@@ -652,6 +720,16 @@ Return true if this object file is valid, false if not." },
"add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
+ { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_global_symbol (name [, domain]).\n\
+Look up a global symbol in this objfile and return it." },
+
+ { "lookup_static_symbol", (PyCFunction) objfpy_lookup_static_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_static_symbol (name [, domain]).\n\
+Look up a static-linkage global symbol in this objfile and return it." },
+
{ NULL }
};
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491234..6d751bddae 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e760..1b8acf47ed 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,20 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\")) is None" \
+ "True" "lookup_global_symbol does not find static symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"static_var\").name)" \
+ "static_var" "lookup_static_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"global_var\")) is None" \
+ "True" "lookup_static_symbol does not find global symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"nonexistant\"))" \
+ "None" "lookup_static_symbol can handle nonexistant symbol"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
--
2.22.0.709.g102302147b-goog
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4] Add Objfile.lookup_{global,static}_symbol functions
2019-07-27 18:31 ` [PATCH v4] " Christian Biesinger via gdb-patches
@ 2019-07-27 18:38 ` Eli Zaretskii
2019-07-30 1:03 ` Simon Marchi
1 sibling, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-27 18:38 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Sat, 27 Jul 2019 13:30:46 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> Thanks Eli, fixed in this version.
The documentation parts of this version are OK. Thanks.
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4] Add Objfile.lookup_{global,static}_symbol functions
2019-07-27 18:31 ` [PATCH v4] " Christian Biesinger via gdb-patches
2019-07-27 18:38 ` Eli Zaretskii
@ 2019-07-30 1:03 ` Simon Marchi
2019-07-30 1:51 ` [PATCH v5] " Christian Biesinger via gdb-patches
1 sibling, 1 reply; 25+ messages in thread
From: Simon Marchi @ 2019-07-30 1:03 UTC (permalink / raw)
To: Christian Biesinger, gdb-patches
On 2019-07-27 2:30 p.m., Christian Biesinger via gdb-patches wrote:
> Thanks Eli, fixed in this version.
>
> This is essentially the inverse of Symbol.objfile. This allows
> handling different symbols with the same name (but from different
> objfiles) and can also be faster if the objfile is known.
>
> gdb/ChangeLog:
>
> 2019-07-25 Christian Biesinger <cbiesinger@google.com>
>
> * NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
> * python/py-objfile.c (objfpy_lookup_global_symbol): New function.
> (objfpy_lookup_static_symbol): New function.
> (objfile_object_methods): Add new functions.
>
> gdb/doc/ChangeLog:
>
> 2019-07-25 Christian Biesinger <cbiesinger@google.com>
>
> * python.texi (Objfiles In Python): Document new functions
> Objfile.lookup_{global,static}_symbol.
>
> gdb/testsuite/ChangeLog:
>
> 2019-07-25 Christian Biesinger <cbiesinger@google.com>
>
> * gdb.python/py-objfile.c: Add global and static vars.
> * gdb.python/py-objfile.exp: Test new functions Objfile.
> lookup_global_symbol and lookup_static_symbol.
> ---
> gdb/NEWS | 3 +
> gdb/doc/python.texi | 17 ++++++
> gdb/python/py-objfile.c | 78 +++++++++++++++++++++++++
> gdb/testsuite/gdb.python/py-objfile.c | 3 +
> gdb/testsuite/gdb.python/py-objfile.exp | 14 +++++
> 5 files changed, 115 insertions(+)
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index cc1d58520d..d8fb4cfe7f 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -36,6 +36,9 @@
> ** gdb.Type has a new property 'objfile' which returns the objfile the
> type was defined in.
>
> + ** gdb.Objfile has new methods 'lookup_global_symbol' and
> + 'lookup_static_symbol' to lookup a symbol from this objfile only.
> +
> * New commands
>
> | [COMMAND] | SHELL_COMMAND
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index 034623513b..bbba519ffc 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -4441,6 +4441,23 @@ searches then this function can be used to add a debug info file
> from a different place.
> @end defun
>
> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
> +Search for a global symbol named @var{name} in this objfile. Optionally, the
> +search scope can be restricted with the @var{domain} argument.
> +The @var{domain} argument must be a domain constant defined in the @code{gdb}
> +module and described in @ref{Symbols In Python}. This function is similar to
> +@code{gdb.lookup_global_symbol}, except that the search is limited to this
> +objfile.
> +
> +The result is a @code{gdb.Symbol} object or @code{None} if the symbol
> +is not found.
> +@end defun
> +
> +@defun Objfile.lookup_static_symbol (name @r{[}, domain@r{]})
> +Like @code{Objfile.lookup_global_symbol}, but searches for a global
> +symbol with static linkage named @var{name} in this objfile.
> +@end defun
> +
> @node Frames In Python
> @subsubsection Accessing inferior stack frames from Python
>
> diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
> index 15735c8501..2c548450b4 100644
> --- a/gdb/python/py-objfile.c
> +++ b/gdb/python/py-objfile.c
> @@ -434,6 +434,74 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
> Py_RETURN_NONE;
> }
>
> +/* Implementation of
> + gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
> +
> +static PyObject *
> +objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
> +{
> + static const char *keywords[] = { "name", "domain", NULL };
> + objfile_object *obj = (objfile_object *) self;
> + const char *symbol_name;
> + int domain = VAR_DOMAIN;
> +
> + OBJFPY_REQUIRE_VALID (obj);
> +
> + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
> + &domain))
> + return nullptr;
> +
> + try
> + {
> + struct symbol *sym = lookup_global_symbol_from_objfile
> + (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
> + if (sym == nullptr)
> + Py_RETURN_NONE;
> +
> + return symbol_to_symbol_object (sym);
> + }
> + catch (const gdb_exception &except)
> + {
> + GDB_PY_HANDLE_EXCEPTION (except);
> + }
> +
> + Py_RETURN_NONE;
> +}
> +
> +/* Implementation of
> + gdb.Objfile.lookup_static_symbol (self, string [, domain]) -> gdb.Symbol. */
> +
> +static PyObject *
> +objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
> +{
> + static const char *keywords[] = { "name", "domain", NULL };
> + objfile_object *obj = (objfile_object *) self;
> + const char *symbol_name;
> + int domain = VAR_DOMAIN;
> +
> + OBJFPY_REQUIRE_VALID (obj);
> +
> + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
> + &domain))
> + return nullptr;
> +
> + try
> + {
> + struct symbol *sym = lookup_global_symbol_from_objfile
> + (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol;
> + if (sym == nullptr)
> + Py_RETURN_NONE;
> +
> + return symbol_to_symbol_object (sym);
> + }
> + catch (const gdb_exception &except)
> + {
> + GDB_PY_HANDLE_EXCEPTION (except);
> + }
> +
> + Py_RETURN_NONE;
> +}
> +
> /* Implement repr() for gdb.Objfile. */
>
> static PyObject *
> @@ -652,6 +720,16 @@ Return true if this object file is valid, false if not." },
> "add_separate_debug_file (file_name).\n\
> Add FILE_NAME to the list of files containing debug info for the objfile." },
>
> + { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
> + METH_VARARGS | METH_KEYWORDS,
> + "lookup_global_symbol (name [, domain]).\n\
> +Look up a global symbol in this objfile and return it." },
> +
> + { "lookup_static_symbol", (PyCFunction) objfpy_lookup_static_symbol,
> + METH_VARARGS | METH_KEYWORDS,
> + "lookup_static_symbol (name [, domain]).\n\
> +Look up a static-linkage global symbol in this objfile and return it." },
> +
> { NULL }
> };
>
> diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
> index ac41491234..6d751bddae 100644
> --- a/gdb/testsuite/gdb.python/py-objfile.c
> +++ b/gdb/testsuite/gdb.python/py-objfile.c
> @@ -15,6 +15,9 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +int global_var = 42;
> +static int static_var = 50;
> +
> int
> main ()
> {
> diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
> index b5e0c5e760..1b8acf47ed 100644
> --- a/gdb/testsuite/gdb.python/py-objfile.exp
> +++ b/gdb/testsuite/gdb.python/py-objfile.exp
> @@ -55,6 +55,20 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
> gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
> "Objfile not found\\.\r\n${python_error_text}"
>
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
> + "global_var" "lookup_global_symbol finds a valid symbol"
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\")) is None" \
> + "True" "lookup_global_symbol does not find static symbol"
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
> + "None" "lookup_global_symbol doesn't find symbol in other objfile"
> +
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"static_var\").name)" \
> + "static_var" "lookup_static_symbol finds a valid symbol"
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"global_var\")) is None" \
> + "True" "lookup_static_symbol does not find global symbol"
> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"nonexistant\"))" \
> + "None" "lookup_static_symbol can handle nonexistant symbol"
> +
> set binfile_build_id [get_build_id $binfile]
> if [string compare $binfile_build_id ""] {
> verbose -log "binfile_build_id = $binfile_build_id"
>
Hi Christian,
I get:
$ make check TESTS="gdb.python/py-objfile.exp"
...
FAIL: gdb.python/py-objfile.exp: lookup_global_symbol does not find static symbol
FAIL: gdb.python/py-objfile.exp: lookup_static_symbol does not find global symbol
It's just a typo:
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index 1b8acf47ed52..5f0ac49cad4d 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -57,14 +57,14 @@ gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
"global_var" "lookup_global_symbol finds a valid symbol"
-gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\")) is None" \
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\") is None)" \
"True" "lookup_global_symbol does not find static symbol"
gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
"None" "lookup_global_symbol doesn't find symbol in other objfile"
gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"static_var\").name)" \
"static_var" "lookup_static_symbol finds a valid symbol"
-gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"global_var\")) is None" \
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"global_var\") is None)" \
"True" "lookup_static_symbol does not find global symbol"
gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"nonexistant\"))" \
"None" "lookup_static_symbol can handle nonexistant symbol"
---
The patch LGTM, please push with this fixed.
Simon
^ permalink raw reply [flat|nested] 25+ messages in thread* [PATCH v5] Add Objfile.lookup_{global,static}_symbol functions
2019-07-30 1:03 ` Simon Marchi
@ 2019-07-30 1:51 ` Christian Biesinger via gdb-patches
2019-07-30 14:59 ` Eli Zaretskii
0 siblings, 1 reply; 25+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-30 1:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
Thanks Simon; fixed. I pushed the below version.
This is essentially the inverse of Symbol.objfile. This allows
handling different symbols with the same name (but from different
objfiles) and can also be faster if the objfile is known.
gdb/ChangeLog:
2019-07-29 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
* python/py-objfile.c (objfpy_lookup_global_symbol): New function.
(objfpy_lookup_static_symbol): New function.
(objfile_object_methods): Add new functions.
gdb/doc/ChangeLog:
2019-07-29 Christian Biesinger <cbiesinger@google.com>
* python.texi (Objfiles In Python): Document new functions
Objfile.lookup_{global,static}_symbol.
gdb/testsuite/ChangeLog:
2019-07-29 Christian Biesinger <cbiesinger@google.com>
* gdb.python/py-objfile.c: Add global and static vars.
* gdb.python/py-objfile.exp: Test new functions Objfile.
lookup_global_symbol and lookup_static_symbol.
---
gdb/ChangeLog | 7 +++
gdb/NEWS | 3 +
gdb/doc/ChangeLog | 5 ++
gdb/doc/python.texi | 17 ++++++
gdb/python/py-objfile.c | 78 +++++++++++++++++++++++++
gdb/testsuite/ChangeLog | 6 ++
gdb/testsuite/gdb.python/py-objfile.c | 3 +
gdb/testsuite/gdb.python/py-objfile.exp | 14 +++++
8 files changed, 133 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dcc6a91b60..59fb8002e8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-29 Christian Biesinger <cbiesinger@google.com>
+
+ * NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
+ * python/py-objfile.c (objfpy_lookup_global_symbol): New function.
+ (objfpy_lookup_static_symbol): New function.
+ (objfile_object_methods): Add new functions.
+
2019-07-29 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Mention 'set|show print frame-info'. Mention new
diff --git a/gdb/NEWS b/gdb/NEWS
index a08265cae7..4e821eab4c 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -41,6 +41,9 @@
there are no filters, or when the 'backtrace' '-no-filters' option
is given.
+ ** gdb.Objfile has new methods 'lookup_global_symbol' and
+ 'lookup_static_symbol' to lookup a symbol from this objfile only.
+
* New commands
| [COMMAND] | SHELL_COMMAND
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index c409fe867b..9b91b998bd 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-29 Christian Biesinger <cbiesinger@google.com>
+
+ * python.texi (Objfiles In Python): Document new functions
+ Objfile.lookup_{global,static}_symbol.
+
2019-07-29 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Backtrace): Document the new '-frame-info'
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 034623513b..bbba519ffc 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4441,6 +4441,23 @@ searches then this function can be used to add a debug info file
from a different place.
@end defun
+@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
+Search for a global symbol named @var{name} in this objfile. Optionally, the
+search scope can be restricted with the @var{domain} argument.
+The @var{domain} argument must be a domain constant defined in the @code{gdb}
+module and described in @ref{Symbols In Python}. This function is similar to
+@code{gdb.lookup_global_symbol}, except that the search is limited to this
+objfile.
+
+The result is a @code{gdb.Symbol} object or @code{None} if the symbol
+is not found.
+@end defun
+
+@defun Objfile.lookup_static_symbol (name @r{[}, domain@r{]})
+Like @code{Objfile.lookup_global_symbol}, but searches for a global
+symbol with static linkage named @var{name} in this objfile.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 15735c8501..2c548450b4 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -434,6 +434,74 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
+/* Implementation of
+ gdb.Objfile.lookup_global_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* Implementation of
+ gdb.Objfile.lookup_static_symbol (self, string [, domain]) -> gdb.Symbol. */
+
+static PyObject *
+objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
+{
+ static const char *keywords[] = { "name", "domain", NULL };
+ objfile_object *obj = (objfile_object *) self;
+ const char *symbol_name;
+ int domain = VAR_DOMAIN;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
+ &domain))
+ return nullptr;
+
+ try
+ {
+ struct symbol *sym = lookup_global_symbol_from_objfile
+ (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ if (sym == nullptr)
+ Py_RETURN_NONE;
+
+ return symbol_to_symbol_object (sym);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
@@ -652,6 +720,16 @@ Return true if this object file is valid, false if not." },
"add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
+ { "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_global_symbol (name [, domain]).\n\
+Look up a global symbol in this objfile and return it." },
+
+ { "lookup_static_symbol", (PyCFunction) objfpy_lookup_static_symbol,
+ METH_VARARGS | METH_KEYWORDS,
+ "lookup_static_symbol (name [, domain]).\n\
+Look up a static-linkage global symbol in this objfile and return it." },
+
{ NULL }
};
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a0b5862dd8..b2551063fe 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-29 Christian Biesinger <cbiesinger@google.com>
+
+ * gdb.python/py-objfile.c: Add global and static vars.
+ * gdb.python/py-objfile.exp: Test new functions Objfile.
+ lookup_global_symbol and lookup_static_symbol.
+
2019-07-29 Tom Tromey <tom@tromey.com>
* lib/tuiterm.exp (Term::_csi_@): New proc.
diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c
index ac41491234..6d751bddae 100644
--- a/gdb/testsuite/gdb.python/py-objfile.c
+++ b/gdb/testsuite/gdb.python/py-objfile.c
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+int global_var = 42;
+static int static_var = 50;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index b5e0c5e760..261f605445 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -55,6 +55,20 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
"Objfile not found\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
+ "global_var" "lookup_global_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\") is None)" \
+ "True" "lookup_global_symbol does not find static symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"stdout\"))" \
+ "None" "lookup_global_symbol doesn't find symbol in other objfile"
+
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"static_var\").name)" \
+ "static_var" "lookup_static_symbol finds a valid symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"global_var\") is None)" \
+ "True" "lookup_static_symbol does not find global symbol"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbol (\"nonexistant\"))" \
+ "None" "lookup_static_symbol can handle nonexistant symbol"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
--
2.22.0.709.g102302147b-goog
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v5] Add Objfile.lookup_{global,static}_symbol functions
2019-07-30 1:51 ` [PATCH v5] " Christian Biesinger via gdb-patches
@ 2019-07-30 14:59 ` Eli Zaretskii
0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-30 14:59 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Mon, 29 Jul 2019 20:51:21 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> Thanks Simon; fixed. I pushed the below version.
>
> This is essentially the inverse of Symbol.objfile. This allows
> handling different symbols with the same name (but from different
> objfiles) and can also be faster if the objfile is known.
>
> gdb/ChangeLog:
>
> 2019-07-29 Christian Biesinger <cbiesinger@google.com>
>
> * NEWS: Mention new functions Objfile.lookup_{global,static}_symbol.
> * python/py-objfile.c (objfpy_lookup_global_symbol): New function.
> (objfpy_lookup_static_symbol): New function.
> (objfile_object_methods): Add new functions.
>
> gdb/doc/ChangeLog:
>
> 2019-07-29 Christian Biesinger <cbiesinger@google.com>
>
> * python.texi (Objfiles In Python): Document new functions
> Objfile.lookup_{global,static}_symbol.
>
> gdb/testsuite/ChangeLog:
>
> 2019-07-29 Christian Biesinger <cbiesinger@google.com>
>
> * gdb.python/py-objfile.c: Add global and static vars.
> * gdb.python/py-objfile.exp: Test new functions Objfile.
> lookup_global_symbol and lookup_static_symbol.
Thanks, the documentation parts are OK.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-07-26 1:38 ` Christian Biesinger via gdb-patches
2019-07-26 1:38 ` [PATCH v2] " Christian Biesinger via gdb-patches
@ 2019-07-26 15:40 ` Simon Marchi
1 sibling, 0 replies; 25+ messages in thread
From: Simon Marchi @ 2019-07-26 15:40 UTC (permalink / raw)
To: Christian Biesinger; +Cc: Christian Biesinger via gdb-patches, Eli Zaretskii
On 2019-07-25 9:37 p.m., Christian Biesinger wrote:
> I decided to follow your suggestion and add a lookup_static_symbol
> function (to Objfile and gdb). I haven't had time to implement it yet
> but hopefully I can do that in the next couple of days. Would you like
> me to do Objfile.lookup_static_symbol as part of this patch or
> together with gdb.lookup_static_symbol?
I would say a separate patch for each would be good, if it doesn't incur
more work. They can be in the same series though.
Simon
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Add an Objfile.lookup_global_symbol function
2019-07-22 20:51 ` Christian Biesinger via gdb-patches
2019-07-23 1:30 ` Simon Marchi
@ 2019-07-23 14:54 ` Eli Zaretskii
1 sibling, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2019-07-23 14:54 UTC (permalink / raw)
To: Christian Biesinger; +Cc: gdb-patches
> Date: Mon, 22 Jul 2019 15:51:21 -0500
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
>
> +@defun Objfile.lookup_global_symbol (name @r{[}, domain@r{]})
> +Searches for a global symbol named @var{name} in this objfile. Optionally, the
As mentioned elsewhere, our convention is to say "Search for a global
symbol named ...".
Otherwise, the documentation parts are OK.
^ permalink raw reply [flat|nested] 25+ messages in thread