Use domain_search_flags in lookup_symbol et al

This changes lookup_symbol and associated APIs to accept
domain_search_flags rather than a domain_enum.

Note that this introduces some new constants to Python and Guile.  I
chose to break out the documentation patch for this, because the
internals here do not change until a later patch, and it seemed
simpler to patch the docs just once, rather than twice.
This commit is contained in:
Tom Tromey
2023-03-30 23:00:26 -06:00
parent 6c01521494
commit ccf41c2487
64 changed files with 342 additions and 312 deletions

View File

@@ -532,7 +532,8 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw)
if (!block)
block = get_frame_block (frame, NULL);
lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL);
lookup_sym = lookup_symbol (var_name.get (), block,
SEARCH_VFT, nullptr);
var = lookup_sym.symbol;
block = lookup_sym.block;
}

View File

@@ -479,8 +479,9 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
domain_search_flags flags = from_scripting_domain (domain);
struct symbol *sym = lookup_global_symbol_from_objfile
(obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
(obj->objfile, GLOBAL_BLOCK, symbol_name, flags).symbol;
if (sym == nullptr)
Py_RETURN_NONE;
@@ -513,8 +514,9 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
domain_search_flags flags = from_scripting_domain (domain);
struct symbol *sym = lookup_global_symbol_from_objfile
(obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol;
(obj->objfile, STATIC_BLOCK, symbol_name, flags).symbol;
if (sym == nullptr)
Py_RETURN_NONE;

View File

@@ -432,8 +432,8 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
symbol = lookup_symbol (name, block, (domain_enum) domain,
&is_a_field_of_this).symbol;
domain_search_flags flags = from_scripting_domain (domain);
symbol = lookup_symbol (name, block, flags, &is_a_field_of_this).symbol;
}
catch (const gdb_exception &except)
{
@@ -481,7 +481,8 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol;
domain_search_flags flags = from_scripting_domain (domain);
symbol = lookup_global_symbol (name, NULL, flags).symbol;
}
catch (const gdb_exception &except)
{
@@ -542,13 +543,14 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
domain_search_flags flags = from_scripting_domain (domain);
if (block != nullptr)
symbol
= lookup_symbol_in_static_block (name, block,
(domain_enum) domain).symbol;
= lookup_symbol_in_static_block (name, block, flags).symbol;
if (symbol == nullptr)
symbol = lookup_static_symbol (name, (domain_enum) domain).symbol;
symbol = lookup_static_symbol (name, flags).symbol;
}
catch (const gdb_exception &except)
{
@@ -592,6 +594,8 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
try
{
domain_search_flags flags = from_scripting_domain (domain);
/* Expand any symtabs that contain potentially matching symbols. */
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
@@ -613,7 +617,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
if (block != nullptr)
{
symbol *symbol = lookup_symbol_in_static_block
(name, block, (domain_enum) domain).symbol;
(name, block, flags).symbol;
if (symbol != nullptr)
{
@@ -675,7 +679,9 @@ gdbpy_initialize_symbols (void)
#define DOMAIN(X) \
if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN", \
X ## _DOMAIN) < 0) \
to_scripting_domain (X ## _DOMAIN)) < 0 \
|| PyModule_AddIntConstant (gdb_module, "SEARCH_" #X "_DOMAIN", \
to_scripting_domain (SEARCH_ ## X ## _DOMAIN)) < 0) \
return -1;
#include "sym-domains.def"
#undef DOMAIN