diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-04-02 11:23:52 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-04-02 11:35:29 -0400 |
commit | 4a4f97c129b26445ff14d0e5323feeb80610a539 (patch) | |
tree | d477370ea39e6b4c7407ebc1b6eb43f6c38be9ac | |
parent | 0672875f3c7c03580ed88dfa48c2e3a3b16d0697 (diff) | |
download | gdb-4a4f97c129b26445ff14d0e5323feeb80610a539.zip gdb-4a4f97c129b26445ff14d0e5323feeb80610a539.tar.gz gdb-4a4f97c129b26445ff14d0e5323feeb80610a539.tar.bz2 |
gdb: add intern methods to objfile_per_bfd_storage
This allows keeping the objfile_per_bfd_storage implementation details
into objfile_per_bfd_storage, instead of into objfile. And this makes
the intern methods usable for code that only has an
objfile_per_bfd_storage to work with.
gdb/ChangeLog:
* objfiles.h (struct objfile_per_bfd_storage) <intern>: New
methods.
(struct objfile) <intern>: Use
objfile::objfile_per_bfd_storage::intern.
Change-Id: Ifd54026c5efaeffafac9b84ff84c199acc7ce78a
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/objfiles.h | 22 |
2 files changed, 26 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1bdd652..ac64f5c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-04-02 Simon Marchi <simon.marchi@polymtl.ca> + + * objfiles.h (struct objfile_per_bfd_storage) <intern>: New + methods. + (struct objfile) <intern>: Use + objfile::objfile_per_bfd_storage::intern. + 2021-04-01 Simon Marchi <simon.marchi@efficios.com> * gdbtypes.h (TYPE_FLAG_ENUM): Remove, replace all uses diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 4cd392b..e8a8b5f 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -270,6 +270,23 @@ struct objfile_per_bfd_storage ~objfile_per_bfd_storage (); + /* Intern STRING in this object's string cache and return the unique copy. + The copy has the same lifetime as this object. + + STRING must be null-terminated. */ + + const char *intern (const char *str) + { + return (const char *) string_cache.insert (str, strlen (str) + 1); + } + + /* Same as the above, but for an std::string. */ + + const char *intern (const std::string &str) + { + return (const char *) string_cache.insert (str.c_str (), str.size () + 1); + } + /* The storage has an obstack of its own. */ auto_obstack storage_obstack; @@ -516,15 +533,14 @@ public: lifetime as the per-BFD object. */ const char *intern (const char *str) { - return (const char *) per_bfd->string_cache.insert (str, strlen (str) + 1); + return per_bfd->intern (str); } /* Intern STRING and return the unique copy. The copy has the same lifetime as the per-BFD object. */ const char *intern (const std::string &str) { - return (const char *) per_bfd->string_cache.insert (str.c_str (), - str.size () + 1); + return per_bfd->intern (str); } /* Retrieve the gdbarch associated with this objfile. */ |