diff options
author | Tom Tromey <tromey@adacore.com> | 2019-10-15 10:57:40 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-10-15 11:03:57 -0600 |
commit | 953cff563058831ab0bf863c7655d23b5e6a5989 (patch) | |
tree | b7c925518139ea7492e4ffdee4ef3ae6f11667ad /gdb/arch-utils.c | |
parent | 81e6b8eb208c427028d919afb2b5cabbc355fc88 (diff) | |
download | gdb-953cff563058831ab0bf863c7655d23b5e6a5989.zip gdb-953cff563058831ab0bf863c7655d23b5e6a5989.tar.gz gdb-953cff563058831ab0bf863c7655d23b5e6a5989.tar.bz2 |
Change gcc_target_options to return std::string
This patch was inspired by a recent review that recommended using
std::string in a new implementation of the gcc_target_options gdbarch
function. It changes this function to return std::string rather than
an ordinary xmalloc'd string.
I believe this caught a latent memory leak in compile.c:get_args.
Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-10-15 Tom Tromey <tromey@adacore.com>
* gdbarch.h, gdbarch.c: Rebuild.
* gdbarch.sh (gcc_target_options): Change return type to
std::string.
* compile/compile.c (get_args): Update.
* nios2-tdep.c (nios2_gcc_target_options): Return std::string.
* arm-linux-tdep.c (arm_linux_gcc_target_options): Return
std::string.
* aarch64-linux-tdep.c (aarch64_linux_gcc_target_options): Return
std::string.
* arch-utils.c (default_gcc_target_options): Return std::string.
* arch-utils.h (default_gcc_target_options): Return std::string.
* s390-tdep.c (s390_gcc_target_options): Return std::string.
Change-Id: I51f61703426a323089e646da8f22320a2cafbc1f
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r-- | gdb/arch-utils.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index c61fa6f..571646e 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -903,11 +903,12 @@ default_infcall_munmap (CORE_ADDR addr, CORE_ADDR size) /* -mcmodel=large is used so that no GOT (Global Offset Table) is needed to be created in inferior memory by GDB (normally it is set by ld.so). */ -char * +std::string default_gcc_target_options (struct gdbarch *gdbarch) { - return xstrprintf ("-m%d%s", gdbarch_ptr_bit (gdbarch), - gdbarch_ptr_bit (gdbarch) == 64 ? " -mcmodel=large" : ""); + return string_printf ("-m%d%s", gdbarch_ptr_bit (gdbarch), + (gdbarch_ptr_bit (gdbarch) == 64 + ? " -mcmodel=large" : "")); } /* gdbarch gnu_triplet_regexp method. */ |