aboutsummaryrefslogtreecommitdiff
path: root/gdb/value.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-11-15 16:49:17 -0700
committerTom Tromey <tom@tromey.com>2019-11-26 14:20:29 -0700
commit1a6d41c6433a0980f302c480b1d1db71234b49e4 (patch)
treed751d01c179f3b3d40ca503d3a73a11056177536 /gdb/value.h
parent8318f3c337cf46ee6309b4a7f06f3934fc94b4bd (diff)
downloadbinutils-1a6d41c6433a0980f302c480b1d1db71234b49e4.zip
binutils-1a6d41c6433a0980f302c480b1d1db71234b49e4.tar.gz
binutils-1a6d41c6433a0980f302c480b1d1db71234b49e4.tar.bz2
Add add_internal_function overload
add_internal_function sets a command destroyer that frees the doc string. However, many callers do not pass in an allocated doc string. This adds a new overload to clearly differentiate the two cases, fixing the latent bug. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * value.h (add_internal_function): Add new overload. Move documentation from value.h. * value.c (do_add_internal_function): New function. (add_internal_function): Use it. Add new overload. (function_destroyer): Don't free doc. * python/py-function.c (fnpy_init): Update. Change-Id: I3f6df925bc6b3e1bccbad9eeebc487b908bb5a2a
Diffstat (limited to 'gdb/value.h')
-rw-r--r--gdb/value.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/gdb/value.h b/gdb/value.h
index 2b5d784..fdef835 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1165,9 +1165,22 @@ typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch,
int argc,
struct value **argv);
-void add_internal_function (const char *name, const char *doc,
- internal_function_fn handler,
- void *cookie);
+/* Add a new internal function. NAME is the name of the function; DOC
+ is a documentation string describing the function. HANDLER is
+ called when the function is invoked. COOKIE is an arbitrary
+ pointer which is passed to HANDLER and is intended for "user
+ data". */
+
+extern void add_internal_function (const char *name, const char *doc,
+ internal_function_fn handler,
+ void *cookie);
+
+/* This overload takes an allocated documentation string. */
+
+extern void add_internal_function (const char *name,
+ gdb::unique_xmalloc_ptr<char> &&doc,
+ internal_function_fn handler,
+ void *cookie);
struct value *call_internal_function (struct gdbarch *gdbarch,
const struct language_defn *language,