From 9ad8c5832d0092e1c02069b1189ec0ff59089957 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 30 May 2024 14:53:53 -0400 Subject: gdb: make progspace::exec_filename private, add getter / setter Just like the title says... I think this makes things a bit clearer, for instance where the exec filename is set. It also makes the read call sites a bit nicer, avoiding the `.get ()`. Change-Id: If8b58ae8f6270c8a34b868f6ca06128c6671ea3c Approved-By: Tom Tromey --- gdb/progspace.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'gdb/progspace.h') diff --git a/gdb/progspace.h b/gdb/progspace.h index bc24ef9..82c0a74 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -292,6 +292,15 @@ struct program_space intrusive_list &solibs () { return so_list; } + /* Similar to `bfd_get_filename (exec_bfd ())` but in original form given + by user, without symbolic links and pathname resolved. It is not nullptr + iff `exec_bfd ()` is not nullptr. */ + const char *exec_filename () const + { return m_exec_filename.get (); } + + void set_exec_filename (gdb::unique_xmalloc_ptr filename) + { m_exec_filename = std::move (filename); } + /* Close and clear exec_bfd. If we end up with no target sections to read memory from, this unpushes the exec_ops target. */ void exec_close (); @@ -352,10 +361,6 @@ struct program_space gdb_bfd_ref_ptr ebfd; /* The last-modified time, from when the exec was brought in. */ long ebfd_mtime = 0; - /* Similar to bfd_get_filename (exec_bfd) but in original form given - by user, without symbolic links and pathname resolved. It is not - NULL iff EBFD is not NULL. */ - gdb::unique_xmalloc_ptr exec_filename; /* Binary file diddling handle for the core file. */ gdb_bfd_ref_ptr cbfd; @@ -414,6 +419,9 @@ private: /* The set of target sections matching the sections mapped into this program space. Managed by both exec_ops and solib.c. */ std::vector m_target_sections; + + /* See `exec_filename`. */ + gdb::unique_xmalloc_ptr m_exec_filename; }; /* The list of all program spaces. There's always at least one. */ -- cgit v1.1