[14/14] gdb: pass program space to objfile::make

Message ID 20240711195307.1544451-15-simon.marchi@polymtl.ca
State New
Headers
Series Some random program space cleanups |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Simon Marchi July 11, 2024, 7:52 p.m. UTC
  Make the current program space reference bubble up one level.

Change-Id: Iee8b11c853c76e539c991c4785737c69e6a1925c
---
 gdb/jit.c      | 4 ++--
 gdb/objfiles.c | 4 ++--
 gdb/objfiles.h | 5 +++--
 gdb/symfile.c  | 5 +++--
 4 files changed, 10 insertions(+), 8 deletions(-)
  

Comments

Thiago Jung Bauermann July 13, 2024, 4:06 a.m. UTC | #1
Hello Simon,

Simon Marchi <simon.marchi@polymtl.ca> writes:

> diff --git a/gdb/symfile.c b/gdb/symfile.c
> index 50fb9983f3d5..a2ebd0068f84 100644
> --- a/gdb/symfile.c
> +++ b/gdb/symfile.c
> @@ -1026,7 +1026,6 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
>  			    section_addr_info *addrs,
>  			    objfile_flags flags, struct objfile *parent)
>  {
> -  struct objfile *objfile;
>    const int from_tty = add_flags & SYMFILE_VERBOSE;
>    const int mainline = add_flags & SYMFILE_MAINLINE;
>    const int always_confirm = add_flags & SYMFILE_ALWAYS_CONFIRM;
> @@ -1061,7 +1060,9 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
>  
>    if (mainline)
>      flags |= OBJF_MAINLINE;
> -  objfile = objfile::make (abfd, name, flags, parent);
> +
> +  objfile *objfile
> +    = objfile::make (abfd, current_program_space, name, flags, parent);

Does it makes sense to use parent->pspace instead of
current_program_space, if parent != nullptr?
  
Simon Marchi July 15, 2024, 2:37 p.m. UTC | #2
On 7/13/24 12:06 AM, Thiago Jung Bauermann wrote:
> Hello Simon,
> 
> Simon Marchi <simon.marchi@polymtl.ca> writes:
> 
>> diff --git a/gdb/symfile.c b/gdb/symfile.c
>> index 50fb9983f3d5..a2ebd0068f84 100644
>> --- a/gdb/symfile.c
>> +++ b/gdb/symfile.c
>> @@ -1026,7 +1026,6 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
>>  			    section_addr_info *addrs,
>>  			    objfile_flags flags, struct objfile *parent)
>>  {
>> -  struct objfile *objfile;
>>    const int from_tty = add_flags & SYMFILE_VERBOSE;
>>    const int mainline = add_flags & SYMFILE_MAINLINE;
>>    const int always_confirm = add_flags & SYMFILE_ALWAYS_CONFIRM;
>> @@ -1061,7 +1060,9 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
>>  
>>    if (mainline)
>>      flags |= OBJF_MAINLINE;
>> -  objfile = objfile::make (abfd, name, flags, parent);
>> +
>> +  objfile *objfile
>> +    = objfile::make (abfd, current_program_space, name, flags, parent);
> 
> Does it makes sense to use parent->pspace instead of
> current_program_space, if parent != nullptr?

I don't think so, for the same reason as explained in a previous patch.

Simon
  

Patch

diff --git a/gdb/jit.c b/gdb/jit.c
index 797be95a8dac..2744d03f8f8d 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -660,8 +660,8 @@  jit_object_close_impl (struct gdb_symbol_callbacks *cb,
 		     paddress (priv_data->gdbarch,
 			       priv_data->entry.symfile_addr));
 
-  objfile *objfile = objfile::make (nullptr, objfile_name.c_str (),
-				    OBJF_NOT_FILENAME);
+  objfile *objfile = objfile::make (nullptr, current_program_space,
+				    objfile_name.c_str (), OBJF_NOT_FILENAME);
   objfile->per_bfd->gdbarch = priv_data->gdbarch;
 
   for (gdb_symtab &symtab : obj->symtabs)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 0bc603ed3e93..ffdf60fc8658 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -442,8 +442,8 @@  add_separate_debug_objfile (struct objfile *objfile, struct objfile *parent)
 /* See objfiles.h.  */
 
 objfile *
-objfile::make (gdb_bfd_ref_ptr bfd_, const char *name_, objfile_flags flags_,
-	       objfile *parent)
+objfile::make (gdb_bfd_ref_ptr bfd_, program_space *pspace, const char *name_,
+	       objfile_flags flags_, objfile *parent)
 {
   objfile *result
     = new objfile (std::move (bfd_), current_program_space, name_, flags_);
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 1a748939d80a..77af7a4cb5a2 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -437,8 +437,9 @@  struct objfile
   ~objfile ();
 
   /* Create an objfile.  */
-  static objfile *make (gdb_bfd_ref_ptr bfd_, const char *name_,
-			objfile_flags flags_, objfile *parent = nullptr);
+  static objfile *make (gdb_bfd_ref_ptr bfd_, program_space *pspace,
+			const char *name_, objfile_flags flags_,
+			objfile *parent = nullptr);
 
   /* Remove this objfile from its program space's objfile list, and frees
      it.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 50fb9983f3d5..a2ebd0068f84 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1026,7 +1026,6 @@  symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
 			    section_addr_info *addrs,
 			    objfile_flags flags, struct objfile *parent)
 {
-  struct objfile *objfile;
   const int from_tty = add_flags & SYMFILE_VERBOSE;
   const int mainline = add_flags & SYMFILE_MAINLINE;
   const int always_confirm = add_flags & SYMFILE_ALWAYS_CONFIRM;
@@ -1061,7 +1060,9 @@  symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
 
   if (mainline)
     flags |= OBJF_MAINLINE;
-  objfile = objfile::make (abfd, name, flags, parent);
+
+  objfile *objfile
+    = objfile::make (abfd, current_program_space, name, flags, parent);
 
   /* We either created a new mapped symbol table, mapped an existing
      symbol table file which has not had initial symbol reading