diff options
author | Tom de Vries <tdevries@suse.de> | 2024-07-24 16:32:35 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-07-24 16:32:35 +0200 |
commit | de272a5e905afb20ec0a2c192538acf9c9103974 (patch) | |
tree | c52a40f5e254ab44b13e08bf49809a35b556aa30 /gdb/value.h | |
parent | 88141209e25ce19473ec07d7aac09cc68f06a630 (diff) | |
download | fsf-binutils-gdb-de272a5e905afb20ec0a2c192538acf9c9103974.zip fsf-binutils-gdb-de272a5e905afb20ec0a2c192538acf9c9103974.tar.gz fsf-binutils-gdb-de272a5e905afb20ec0a2c192538acf9c9103974.tar.bz2 |
[gdb/exp] Allow internal function to indicate return type
Currently an internal function handler has this prototype:
...
struct value *handler (struct gdbarch *gdbarch,
const struct language_defn *language,
void *cookie, int argc, struct value **argv);
...
Also allow an internal function with a handler with an additional
"enum noside noside" parameter:
...
struct value *handler (struct gdbarch *gdbarch,
const struct language_defn *language, void *cookie,
int argc, struct value **argv, enum noside noside);
...
In case such a handler is called with noside == EVAL_AVOID_SIDE_EFFECTS, it's
expected to return some value with the correct return type.
At least, provided it can do so without side effects, otherwise it should
throw an error.
No functional changes.
Tested on x86_64-linux and aarch64-linux.
Reviewed-By: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb/value.h')
-rw-r--r-- | gdb/value.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/gdb/value.h b/gdb/value.h index 9d7e88d..13cfb00 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1598,13 +1598,24 @@ extern struct value *find_function_in_inferior (const char *, extern struct value *value_allocate_space_in_inferior (int); -/* User function handler. */ - -typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch, - const struct language_defn *language, - void *cookie, - int argc, - struct value **argv); +/* User function handler. The internal_function_fn variant assumes return + type int. The internal_function_fn_noside returns some value with the + return type when passed noside == EVAL_AVOID_SIDE_EFFECTS. */ + +using internal_function_fn + = std::function<struct value *(struct gdbarch *gdbarch, + const struct language_defn *language, + void *cookie, + int argc, + struct value **argv)>; + +using internal_function_fn_noside + = std::function<struct value *(struct gdbarch *gdbarch, + const struct language_defn *language, + void *cookie, + int argc, + struct value **argv, + enum noside noside)>; /* Add a new internal function. NAME is the name of the function; DOC is a documentation string describing the function. HANDLER is @@ -1615,6 +1626,9 @@ typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch, extern void add_internal_function (const char *name, const char *doc, internal_function_fn handler, void *cookie); +extern void add_internal_function (const char *name, const char *doc, + internal_function_fn_noside handler, + void *cookie); /* This overload takes an allocated documentation string. */ @@ -1622,11 +1636,16 @@ extern void add_internal_function (gdb::unique_xmalloc_ptr<char> &&name, gdb::unique_xmalloc_ptr<char> &&doc, internal_function_fn handler, void *cookie); +extern void add_internal_function (gdb::unique_xmalloc_ptr<char> &&name, + gdb::unique_xmalloc_ptr<char> &&doc, + internal_function_fn_noside handler, + void *cookie); struct value *call_internal_function (struct gdbarch *gdbarch, const struct language_defn *language, struct value *function, - int argc, struct value **argv); + int argc, struct value **argv, + enum noside noside); const char *value_internal_function_name (struct value *); |