This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Implement show | set can-call-inferior-functions [on|off]
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 24 Apr 2019 09:53:33 +0300
- Subject: Re: [RFA] Implement show | set can-call-inferior-functions [on|off]
- References: <20190423215826.9936-1-philippe.waroquiers@skynet.be>
> From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
> Cc: Philippe Waroquiers <philippe.waroquiers@skynet.be>
> Date: Tue, 23 Apr 2019 23:58:26 +0200
>
> Inferior function calls are powerful but might lead to undesired
> results such as crashes when calling nested functions (frequently
> used in particular in Ada).
>
> This implements a GDB setting to disable calling inferior functions.
Thanks, I think this is useful functionality.
However, I question the wisdom of erroring out when an attempt is made
to call inferior functions when that's disabled. If this inferior
call is part of some script, the script will error out at that point,
which might not be what the user wants. Erroring out is justified
when the inferior function was called interactively, though. Can we
come up with something more useful for the scripting use case? Like
perhaps 'call' should display a warning and do nothing, 'print' should
just display a warning, and otherwise the inferior would always return
zero? Or maybe this should be subject to some additional knob?
> +set can-call-inferior-functions [on|off]
> +show can-call-inferior-functions
> + Control whether GDB is allowed to do inferior function calls.
> + Inferior function calls are e.g. needed to evaluate and print
> + some expressions. Such inferior function calls can have undesired
> + side effects. It is now possible to forbid such inferior function
> + calls.
> + By default, GDB is allowed to do inferior function calls.
I think this should tell what happens if the function is called when
inferior calls are not allowed.
> +@item set can-call-inferior-functions
> +@kindex set can-call-inferior-functions
> +@cindex disabling inferior function calls.
Index entries should not end with a period.
Also, I think an additional index entry here will be useful:
@cindex inferior function calls, disabling
> + add_setshow_boolean_cmd ("can-call-inferior-functions", no_class,
> + &can_call_inferior_functions_p, _("\
> +Set debugger's willingness to call inferior functions."), _("\
> +Show debugger's willingness to call inferior functions."), _("\
> +To call an inferior function, GDB has to temporarily modify the state\n\
> +of the inferior. This has potentially undesired side effects.\n\
> +Also, having GDB calling nested functions is likely to be erroneous\n\
> +and may even crash the program being debugged.\n\
> +You can avoid such hazards by forbidding GDB to do inferior functions calls.\n\
> +The default is to allow inferior function calls."),
I think this doc string is too detailed, you in effect copied here
everything that we have in the manual, which is too much. I suggest
to leave out the rationale for disabling the inferior calls, and
describe just the effects. I do think this should say what happens
with calls when they are disallowed.
Thanks, the documentation parts are OK once the above nits are taken
care of.