* [PATCH] gdb: change file_file_name to return an std::string
@ 2022-04-07 20:46 Simon Marchi
2022-04-07 22:56 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2022-04-07 20:46 UTC (permalink / raw)
To: gdb-patches
Straightforward change, return an std::string instead of a
gdb::unique_xmalloc_ptr<char>. No behavior change expected.
Change-Id: Ia5e94c94221c35f978bb1b7bdffbff7209e0520e
---
| 16 +++++-----------
| 6 ++----
gdb/dwarf2/macro.c | 6 +++---
3 files changed, 10 insertions(+), 18 deletions(-)
--git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index 4807fcaa5839..77e7e553b21e 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -60,7 +60,7 @@ line_header::add_file_name (const char *name,
m_file_names.emplace_back (name, d_index, mod_time, length);
}
-gdb::unique_xmalloc_ptr<char>
+std::string
line_header::file_file_name (int file) const
{
/* Is the file number a valid index into the line header's file name
@@ -73,26 +73,20 @@ line_header::file_file_name (int file) const
{
const char *dir = fe->include_dir (this);
if (dir != NULL)
- return gdb::unique_xmalloc_ptr<char> (concat (dir, SLASH_STRING,
- fe->name,
- (char *) NULL));
+ return string_printf ("%s/%s", dir, fe->name);
}
- return make_unique_xstrdup (fe->name);
+
+ return fe->name;
}
else
{
/* The compiler produced a bogus file number. We can at least
record the macro definitions made in the file, even if we
won't be able to find the file by name. */
- char fake_name[80];
-
- xsnprintf (fake_name, sizeof (fake_name),
- "<bad macro file number %d>", file);
-
complaint (_("bad file number in macro information (%d)"),
file);
- return make_unique_xstrdup (fake_name);
+ return string_printf ("<bad macro file number %d>", file);
}
}
--git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index 8fb44be56b2e..252dddd846b2 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -163,10 +163,8 @@ struct line_header
const gdb_byte *statement_program_start {}, *statement_program_end {};
/* Return file name relative to the compilation directory of file
- number I in this object's file name table. The result is
- allocated using xmalloc; the caller is responsible for freeing
- it. */
- gdb::unique_xmalloc_ptr<char> file_file_name (int file) const;
+ number FILE in this object's file name table. */
+ std::string file_file_name (int file) const;
private:
/* The include_directories table. Note these are observing
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index b378d7974792..99c3653a2c3a 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -52,7 +52,7 @@ macro_start_file (buildsym_compunit *builder,
const struct line_header *lh)
{
/* File name relative to the compilation directory of this source file. */
- gdb::unique_xmalloc_ptr<char> file_name = lh->file_file_name (file);
+ std::string file_name = lh->file_file_name (file);
if (! current_file)
{
@@ -62,11 +62,11 @@ macro_start_file (buildsym_compunit *builder,
/* If we have no current file, then this must be the start_file
directive for the compilation unit's main source file. */
- current_file = macro_set_main (macro_table, file_name.get ());
+ current_file = macro_set_main (macro_table, file_name.c_str ());
macro_define_special (macro_table);
}
else
- current_file = macro_include (current_file, line, file_name.get ());
+ current_file = macro_include (current_file, line, file_name.c_str ());
return current_file;
}
base-commit: 3fb842cea15503ed101c2d5adb77068206d3d684
--
2.35.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb: change file_file_name to return an std::string
2022-04-07 20:46 [PATCH] gdb: change file_file_name to return an std::string Simon Marchi
@ 2022-04-07 22:56 ` Tom Tromey
2022-04-08 0:32 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2022-04-07 22:56 UTC (permalink / raw)
To: Simon Marchi via Gdb-patches
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> Straightforward change, return an std::string instead of a
Simon> gdb::unique_xmalloc_ptr<char>. No behavior change expected.
Looks good. Thank you.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb: change file_file_name to return an std::string
2022-04-07 22:56 ` Tom Tromey
@ 2022-04-08 0:32 ` Simon Marchi
0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2022-04-08 0:32 UTC (permalink / raw)
To: Tom Tromey, Simon Marchi via Gdb-patches
On 2022-04-07 18:56, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> Straightforward change, return an std::string instead of a
> Simon> gdb::unique_xmalloc_ptr<char>. No behavior change expected.
>
> Looks good. Thank you.
>
> Tom
Thanks, pushed.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-08 0:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 20:46 [PATCH] gdb: change file_file_name to return an std::string Simon Marchi
2022-04-07 22:56 ` Tom Tromey
2022-04-08 0:32 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).