From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 47A153858D28; Fri, 8 Apr 2022 00:32:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 47A153858D28 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: change file_file_name to return an std::string X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: a32c49c6dd0c80e4a06e23bebde7149d79cd48ee X-Git-Newrev: d3a76a5583ddb34402e79969f61f195cfa08ad62 Message-Id: <20220408003214.47A153858D28@sourceware.org> Date: Fri, 8 Apr 2022 00:32:14 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2022 00:32:14 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd3a76a5583dd= b34402e79969f61f195cfa08ad62 commit d3a76a5583ddb34402e79969f61f195cfa08ad62 Author: Simon Marchi Date: Thu Apr 7 16:43:05 2022 -0400 gdb: change file_file_name to return an std::string =20 Straightforward change, return an std::string instead of a gdb::unique_xmalloc_ptr. No behavior change expected. =20 Change-Id: Ia5e94c94221c35f978bb1b7bdffbff7209e0520e Diff: --- gdb/dwarf2/line-header.c | 16 +++++----------- gdb/dwarf2/line-header.h | 6 ++---- gdb/dwarf2/macro.c | 6 +++--- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c index 4807fcaa583..77e7e553b21 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); } =20 -gdb::unique_xmalloc_ptr +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 =3D fe->include_dir (this); if (dir !=3D NULL) - return gdb::unique_xmalloc_ptr (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), - "", file); - complaint (_("bad file number in macro information (%d)"), file); =20 - return make_unique_xstrdup (fake_name); + return string_printf ("", file); } } =20 diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h index 8fb44be56b2..252dddd846b 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 {}; =20 /* 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 file_file_name (int file) const; + number FILE in this object's file name table. */ + std::string file_file_name (int file) const; =20 private: /* The include_directories table. Note these are observing diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c index b378d797479..99c3653a2c3 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 file_name =3D lh->file_file_name (file); + std::string file_name =3D lh->file_file_name (file); =20 if (! current_file) { @@ -62,11 +62,11 @@ macro_start_file (buildsym_compunit *builder, =20 /* If we have no current file, then this must be the start_file directive for the compilation unit's main source file. */ - current_file =3D macro_set_main (macro_table, file_name.get ()); + current_file =3D macro_set_main (macro_table, file_name.c_str ()); macro_define_special (macro_table); } else - current_file =3D macro_include (current_file, line, file_name.get ()); + current_file =3D macro_include (current_file, line, file_name.c_str ()= ); =20 return current_file; }