Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Allow passing a block to lookup_global_symbol_from_objfile
@ 2019-07-22 19:07 Christian Biesinger via gdb-patches
  2019-07-22 20:59 ` Andrew Burgess
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-22 19:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

gdb/ChangeLog:

2019-07-22  Christian Biesinger  <cbiesinger@google.com>

	* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
	* 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/compile/compile-object-load.c | 1 +
 gdb/solib-spu.c                   | 3 ++-
 gdb/solib-svr4.c                  | 3 ++-
 gdb/symtab.c                      | 7 +++++--
 gdb/symtab.h                      | 2 ++
 5 files changed, 12 insertions(+), 4 deletions(-)

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/solib-spu.c b/gdb/solib-spu.c
index 448e1a64f4..5b97b9bcf6 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 5b8bfc1df7..87a0c8e4da 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2224,15 +2224,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 b91454c85c..34fce7c3dd 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2048,10 +2048,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);
 
-- 
2.22.0.657.g960e92d24f-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Allow passing a block to lookup_global_symbol_from_objfile
  2019-07-22 19:07 [PATCH] Allow passing a block to lookup_global_symbol_from_objfile Christian Biesinger via gdb-patches
@ 2019-07-22 20:59 ` Andrew Burgess
  2019-07-22 21:00   ` Christian Biesinger via gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2019-07-22 20:59 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: gdb-patches

* Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> [2019-07-22 14:07:18 -0500]:

> gdb/ChangeLog:
> 
> 2019-07-22  Christian Biesinger  <cbiesinger@google.com>
> 
> 	* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
> 	* 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/compile/compile-object-load.c | 1 +
>  gdb/solib-spu.c                   | 3 ++-
>  gdb/solib-svr4.c                  | 3 ++-
>  gdb/symtab.c                      | 7 +++++--
>  gdb/symtab.h                      | 2 ++
>  5 files changed, 12 insertions(+), 4 deletions(-)
> 
> 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/solib-spu.c b/gdb/solib-spu.c
> index 448e1a64f4..5b97b9bcf6 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 5b8bfc1df7..87a0c8e4da 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -2224,15 +2224,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 b91454c85c..34fce7c3dd 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -2048,10 +2048,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.  */

The name block_index should be BLOCK_INDEX in this comment.

Thanks,
Andrew


>  
>  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);
>  
> -- 
> 2.22.0.657.g960e92d24f-goog
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Allow passing a block to lookup_global_symbol_from_objfile
  2019-07-22 20:59 ` Andrew Burgess
@ 2019-07-22 21:00   ` Christian Biesinger via gdb-patches
  2019-07-23  0:54     ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-22 21:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

gdb/ChangeLog:

2019-07-22  Christian Biesinger  <cbiesinger@google.com>

	* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
	* 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/compile/compile-object-load.c | 1 +
 gdb/solib-spu.c                   | 3 ++-
 gdb/solib-svr4.c                  | 3 ++-
 gdb/symtab.c                      | 7 +++++--
 gdb/symtab.h                      | 2 ++
 5 files changed, 12 insertions(+), 4 deletions(-)

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/solib-spu.c b/gdb/solib-spu.c
index 448e1a64f4..5b97b9bcf6 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 5b8bfc1df7..87a0c8e4da 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2224,15 +2224,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 b91454c85c..35f3c6be71 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2048,10 +2048,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);
 
-- 
2.22.0.657.g960e92d24f-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Allow passing a block to lookup_global_symbol_from_objfile
  2019-07-22 21:00   ` Christian Biesinger via gdb-patches
@ 2019-07-23  0:54     ` Simon Marchi
  2019-07-23  1:46       ` [PATCH v2] " Christian Biesinger via gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2019-07-23  0:54 UTC (permalink / raw)
  To: Christian Biesinger, gdb-patches

Hi Christian,

Code-wise, this LGTM, but I think it would need a bit of justification.  On its own
it doesn't change the behavior of GDB and does not appear to be a cleanup, so why is
this change useful?  I suppose it will be necessary for a further patch.  If so,
it's common to post it as a preparatory patch, in the same series as that other patch.
Then in the commit message you can say that "a further patch will need to call
lookup_global_symbol_from_objfile with STATIC_BLOCK", for example, that this
preparatory patch is just to isolate that change, and that on its own does not bring
any intended functional changes.

On 2019-07-22 5:00 p.m., Christian Biesinger via gdb-patches wrote:
> gdb/ChangeLog:
> 
> 2019-07-22  Christian Biesinger  <cbiesinger@google.com>
> 
> 	* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
> 	* 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.

The last line should also be

 	* symtab.h (lookup_global_symbol_from_objfile): Add a scope parameter.

or

 	* symtab.c (lookup_global_symbol_from_objfile): Likewise.

> ---
>  gdb/compile/compile-object-load.c | 1 +
>  gdb/solib-spu.c                   | 3 ++-
>  gdb/solib-svr4.c                  | 3 ++-
>  gdb/symtab.c                      | 7 +++++--
>  gdb/symtab.h                      | 2 ++
>  5 files changed, 12 insertions(+), 4 deletions(-)
> 
> 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/solib-spu.c b/gdb/solib-spu.c
> index 448e1a64f4..5b97b9bcf6 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 5b8bfc1df7..87a0c8e4da 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -2224,15 +2224,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 b91454c85c..35f3c6be71 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -2048,10 +2048,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.  */

On top of saying which values it can take, it would be useful to say
(very brefly) how it affects the behavior of the function.

Simon


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] Allow passing a block to lookup_global_symbol_from_objfile
  2019-07-23  0:54     ` Simon Marchi
@ 2019-07-23  1:46       ` Christian Biesinger via gdb-patches
  2019-07-24 13:59         ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-23  1:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Christian Biesinger

This has no behavior change in itself, but allows a future patch
to add a function to the Python API to look up symbols in the
static block.

gdb/ChangeLog:

2019-07-22  Christian Biesinger  <cbiesinger@google.com>

	* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
	* 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 (lookup_global_symbol_from_objfile): Likewise.
---
 gdb/compile/compile-object-load.c | 1 +
 gdb/solib-spu.c                   | 3 ++-
 gdb/solib-svr4.c                  | 3 ++-
 gdb/symtab.c                      | 7 +++++--
 gdb/symtab.h                      | 5 ++++-
 5 files changed, 14 insertions(+), 5 deletions(-)

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/solib-spu.c b/gdb/solib-spu.c
index 448e1a64f4..5b97b9bcf6 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 5b8bfc1df7..87a0c8e4da 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2224,15 +2224,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 b91454c85c..9880ecc4c5 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2045,13 +2045,16 @@ extern bool treg_matches_sym_type_name (const compiled_regex &treg,
 extern const char *main_name ();
 extern enum language main_language (void);
 
-/* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.
+/* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global or static blocks,
+   as specified by BLOCK_INDEX.
    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);
 
-- 
2.22.0.657.g960e92d24f-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Allow passing a block to lookup_global_symbol_from_objfile
  2019-07-23  1:46       ` [PATCH v2] " Christian Biesinger via gdb-patches
@ 2019-07-24 13:59         ` Tom Tromey
  2019-07-25  0:05           ` Christian Biesinger via gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2019-07-24 13:59 UTC (permalink / raw)
  To: Christian Biesinger via gdb-patches; +Cc: Christian Biesinger

>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

Christian> This has no behavior change in itself, but allows a future patch
Christian> to add a function to the Python API to look up symbols in the
Christian> static block.

Thanks.  This looks good to me, and I think you've addressed all the
earlier comments.  So, this is ok.

Tom


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Allow passing a block to lookup_global_symbol_from_objfile
  2019-07-24 13:59         ` Tom Tromey
@ 2019-07-25  0:05           ` Christian Biesinger via gdb-patches
  0 siblings, 0 replies; 7+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-07-25  0:05 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Christian Biesinger via gdb-patches

Thanks, pushed.

Christian

On Wed, Jul 24, 2019 at 6:59 AM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> This has no behavior change in itself, but allows a future patch
> Christian> to add a function to the Python API to look up symbols in the
> Christian> static block.
>
> Thanks.  This looks good to me, and I think you've addressed all the
> earlier comments.  So, this is ok.
>
> Tom


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-07-25  0:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22 19:07 [PATCH] Allow passing a block to lookup_global_symbol_from_objfile Christian Biesinger via gdb-patches
2019-07-22 20:59 ` Andrew Burgess
2019-07-22 21:00   ` Christian Biesinger via gdb-patches
2019-07-23  0:54     ` Simon Marchi
2019-07-23  1:46       ` [PATCH v2] " Christian Biesinger via gdb-patches
2019-07-24 13:59         ` Tom Tromey
2019-07-25  0:05           ` Christian Biesinger via gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox