* [PATCH] gdb: fix remote-sim.c build
@ 2021-10-04 1:25 Simon Marchi
2021-10-04 19:42 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Simon Marchi @ 2021-10-04 1:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Commit e0700ba44c56 ("gdb: make string-like set show commands use
std::string variable") broke the build:
CXX remote-sim.o
/home/smarchi/src/binutils-gdb/gdb/remote-sim.c: In function ‘void gdbsim_target_open(const char*, int)’:
/home/smarchi/src/binutils-gdb/gdb/remote-sim.c:686:27: error: cannot convert ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to ‘const char*’
686 | if (is_target_filename (sysroot))
| ^~~~~~~
| |
| const string {aka const std::__cxx11::basic_string<char>}
In file included from /home/smarchi/src/binutils-gdb/gdb/remote-sim.c:24:
/home/smarchi/src/binutils-gdb/gdb/gdb_bfd.h:39:37: note: initializing argument 1 of ‘int is_target_filename(const char*)’
39 | int is_target_filename (const char *name);
| ~~~~~~~~~~~~^~~~
Fix that by making the code look like it was before that commit
but with a .c_str() added (instead of trying to use an std::string
reference).
Change-Id: I7ae5d39e1fcb06ff9a3d3717f403d8be95dc122b
---
gdb/remote-sim.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 5bfce2a9a31..84a223411cb 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -680,9 +680,10 @@ gdbsim_target_open (const char *args, int from_tty)
int len;
char *arg_buf;
struct sim_inferior_data *sim_data;
+ const char *sysroot;
SIM_DESC gdbsim_desc;
- const std::string &sysroot = gdb_sysroot;
+ sysroot = gdb_sysroot.c_str ();
if (is_target_filename (sysroot))
sysroot += strlen (TARGET_SYSROOT_PREFIX);
@@ -703,7 +704,7 @@ gdbsim_target_open (const char *args, int from_tty)
len = (7 + 1 /* gdbsim */
+ strlen (" -E little")
+ strlen (" --architecture=xxxxxxxxxx")
- + strlen (" --sysroot=") + sysroot.length () +
+ + strlen (" --sysroot=") + strlen (sysroot) +
+ (args ? strlen (args) : 0)
+ 50) /* slack */ ;
arg_buf = (char *) alloca (len);
@@ -730,7 +731,7 @@ gdbsim_target_open (const char *args, int from_tty)
}
/* Pass along gdb's concept of the sysroot. */
strcat (arg_buf, " --sysroot=");
- strcat (arg_buf, sysroot.c_str ());
+ strcat (arg_buf, sysroot);
/* finally, any explicit args */
if (args)
{
--
2.33.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gdb: fix remote-sim.c build
2021-10-04 1:25 [PATCH] gdb: fix remote-sim.c build Simon Marchi
@ 2021-10-04 19:42 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2021-10-04 19:42 UTC (permalink / raw)
To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> Commit e0700ba44c56 ("gdb: make string-like set show commands use
Simon> std::string variable") broke the build:
[...]
I found this before reading the list, so I ended up already pushing a
nearly identical patch to fix the build.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-04 19:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 1:25 [PATCH] gdb: fix remote-sim.c build Simon Marchi
2021-10-04 19:42 ` Tom Tromey
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).