aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-05-05 21:39:06 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-05-07 09:53:50 +0100
commit9589edb8366d9cf670dbfeeea355337c8b32e6d4 (patch)
tree42e357cfec744611782cd2798e4a558474704305 /gdb
parent4896932e620876a1afa1c9e8d2b8a5e49aa53d53 (diff)
downloadgdb-9589edb8366d9cf670dbfeeea355337c8b32e6d4.zip
gdb-9589edb8366d9cf670dbfeeea355337c8b32e6d4.tar.gz
gdb-9589edb8366d9cf670dbfeeea355337c8b32e6d4.tar.bz2
gdb/guile: Have gdbscm_safe_source_script return a unique_ptr
Change gdbscm_safe_source_script to return a gdb::unique_xmalloc_ptr<char> instead of a raw char*. Update the users of this function. There should be no user visible change after this commit. gdb/ChangeLog: * guile/guile-internal.h (gdbscm_safe_source_script): Change function return type. * guile/guile.c (gdbscm_source_script): Update to handle change in gdbscm_safe_source_script. * guile/scm-objfile.c (gdbscm_source_objfile_script): Likewise. * guile/scm-safe-call.c (gdbscm_safe_source_script): Change return type.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/guile/guile-internal.h3
-rw-r--r--gdb/guile/guile.c7
-rw-r--r--gdb/guile/scm-objfile.c9
-rw-r--r--gdb/guile/scm-safe-call.c4
5 files changed, 18 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6633ac5..4e57a16 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2021-05-07 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * guile/guile-internal.h (gdbscm_safe_source_script): Change
+ function return type.
+ * guile/guile.c (gdbscm_source_script): Update to handle change in
+ gdbscm_safe_source_script.
+ * guile/scm-objfile.c (gdbscm_source_objfile_script): Likewise.
+ * guile/scm-safe-call.c (gdbscm_safe_source_script): Change return
+ type.
+
2021-05-06 Simon Marchi <simon.marchi@polymtl.ca>
* inferior.h (class inferior) <args>: Change type to
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index c48547a..73fa380 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -408,7 +408,8 @@ extern SCM gdbscm_unsafe_call_1 (SCM proc, SCM arg0);
extern gdb::unique_xmalloc_ptr<char> gdbscm_safe_eval_string
(const char *string, int display_result);
-extern char *gdbscm_safe_source_script (const char *filename);
+extern gdb::unique_xmalloc_ptr<char> gdbscm_safe_source_script
+ (const char *filename);
extern void gdbscm_enter_repl (void);
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index c6959f5..71d61f3 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -270,13 +270,10 @@ static void
gdbscm_source_script (const struct extension_language_defn *extlang,
FILE *file, const char *filename)
{
- char *msg = gdbscm_safe_source_script (filename);
+ gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_source_script (filename);
if (msg != NULL)
- {
- fprintf_filtered (gdb_stderr, "%s\n", msg);
- xfree (msg);
- }
+ fprintf_filtered (gdb_stderr, "%s\n", msg.get ());
}
/* (execute string [#:from-tty boolean] [#:to-string boolean])
diff --git a/gdb/guile/scm-objfile.c b/gdb/guile/scm-objfile.c
index 30e63f3..cc8bbe6 100644
--- a/gdb/guile/scm-objfile.c
+++ b/gdb/guile/scm-objfile.c
@@ -310,16 +310,11 @@ gdbscm_source_objfile_script (const struct extension_language_defn *extlang,
struct objfile *objfile, FILE *file,
const char *filename)
{
- char *msg;
-
ofscm_current_objfile = objfile;
- msg = gdbscm_safe_source_script (filename);
+ gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_source_script (filename);
if (msg != NULL)
- {
- fprintf_filtered (gdb_stderr, "%s", msg);
- xfree (msg);
- }
+ fprintf_filtered (gdb_stderr, "%s", msg.get ());
ofscm_current_objfile = NULL;
}
diff --git a/gdb/guile/scm-safe-call.c b/gdb/guile/scm-safe-call.c
index 2a38d63..fea4e52 100644
--- a/gdb/guile/scm-safe-call.c
+++ b/gdb/guile/scm-safe-call.c
@@ -431,7 +431,7 @@ scscm_source_scheme_script (void *data)
printed according to "set guile print-stack" and the result is an error
message allocated with malloc, caller must free. */
-char *
+gdb::unique_xmalloc_ptr<char>
gdbscm_safe_source_script (const char *filename)
{
/* scm_c_primitive_load_path only looks in %load-path for files with
@@ -452,7 +452,7 @@ gdbscm_safe_source_script (const char *filename)
(void *) filename);
if (result != NULL)
- return xstrdup (result);
+ return make_unique_xstrdup (result);
return NULL;
}