From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1936) id F268F3858C83; Tue, 26 Apr 2022 16:14:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F268F3858C83 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: John Baldwin To: gdb-cvs@sourceware.org Subject: [binutils-gdb] bsd-kvm: Fix build after recent changes to path handling functions. X-Act-Checkin: binutils-gdb X-Git-Author: John Baldwin X-Git-Refname: refs/heads/master X-Git-Oldrev: 6bdd7cf11d503be3b85320668b223fcd5cc9f2f4 X-Git-Newrev: c62dced2d48a8a3a818c87d0d9d41709fe7997d9 Message-Id: <20220426161457.F268F3858C83@sourceware.org> Date: Tue, 26 Apr 2022 16:14:57 +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: Tue, 26 Apr 2022 16:14:58 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc62dced2d48a= 8a3a818c87d0d9d41709fe7997d9 commit c62dced2d48a8a3a818c87d0d9d41709fe7997d9 Author: John Baldwin Date: Tue Apr 26 09:13:12 2022 -0700 bsd-kvm: Fix build after recent changes to path handling functions. =20 Convert bsd_kvm_corefile and the local filename in bsd_kvm_open to std::string rather than simple char * pointers freed by xfree. Diff: --- gdb/bsd-kvm.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c index 45c7f116472..e9e41df1bec 100644 --- a/gdb/bsd-kvm.c +++ b/gdb/bsd-kvm.c @@ -21,6 +21,7 @@ #include "defs.h" #include "cli/cli-cmds.h" #include "command.h" +#include "filenames.h" #include "frame.h" #include "regcache.h" #include "target.h" @@ -30,6 +31,7 @@ #include "inferior.h" /* for get_exec_file */ #include "gdbthread.h" #include "gdbsupport/pathstuff.h" +#include "gdbsupport/gdb_tilde_expand.h" =20 #include #include @@ -47,7 +49,7 @@ #include "bsd-kvm.h" =20 /* Kernel memory device file. */ -static const char *bsd_kvm_corefile; +static std::string bsd_kvm_corefile; =20 /* Kernel memory interface descriptor. */ static kvm_t *core_kd; @@ -109,24 +111,19 @@ bsd_kvm_target_open (const char *arg, int from_tty) char errbuf[_POSIX2_LINE_MAX]; const char *execfile =3D NULL; kvm_t *temp_kd; - char *filename =3D NULL; + std::string filename; =20 target_preopen (from_tty); =20 if (arg) { - filename =3D tilde_expand (arg); - if (filename[0] !=3D '/') - { - gdb::unique_xmalloc_ptr temp (gdb_abspath (filename)); - - xfree (filename); - filename =3D temp.release (); - } + filename =3D gdb_tilde_expand (arg); + if (!IS_ABSOLUTE_PATH (filename)) + filename =3D gdb_abspath (filename.c_str ()); } =20 execfile =3D get_exec_file (0); - temp_kd =3D kvm_openfiles (execfile, filename, NULL, + temp_kd =3D kvm_openfiles (execfile, filename.c_str (), NULL, write_files ? O_RDWR : O_RDONLY, errbuf); if (temp_kd =3D=3D NULL) error (("%s"), errbuf); @@ -155,6 +152,7 @@ bsd_kvm_target::close () core_kd =3D NULL; } =20 + bsd_kvm_corefile.clear (); switch_to_no_thread (); exit_inferior_silent (current_inferior ()); } @@ -203,9 +201,9 @@ bsd_kvm_target::xfer_partial (enum target_object object, void bsd_kvm_target::files_info () { - if (bsd_kvm_corefile && strcmp (bsd_kvm_corefile, _PATH_MEM) !=3D 0) + if (bsd_kvm_corefile !=3D _PATH_MEM) gdb_printf (_("\tUsing the kernel crash dump %s.\n"), - bsd_kvm_corefile); + bsd_kvm_corefile.c_str ()); else gdb_printf (_("\tUsing the currently running kernel.\n")); }