diff options
author | Tom Tromey <tromey@redhat.com> | 2014-07-21 14:32:43 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-07-30 07:51:08 -0600 |
commit | 8981c75857ec8ef645ccb4f7ccc70fccc609085d (patch) | |
tree | 1f4ed9a9b62ec436d21bedd02a104f7ef25a8b1e /gdb | |
parent | cc6563d29b6f86b23c4f9a8ea73dabf9f7fc0d91 (diff) | |
download | gdb-8981c75857ec8ef645ccb4f7ccc70fccc609085d.zip gdb-8981c75857ec8ef645ccb4f7ccc70fccc609085d.tar.gz gdb-8981c75857ec8ef645ccb4f7ccc70fccc609085d.tar.bz2 |
fix to_open debug setting
This is a follow-on to the patch to auto-generate target debug methods.
While working on that patch I noticed that the to_open debug setting
will never work. There is no path by which debug_to_open can be
called.
This patch fixes the problem by using a generic function as the
implementation of the various "target" subcommands, and then putting
the debug printing there.
This is also a tiny step toward fixing PR 7250 (and apparently why
command contexts were introduced).
Built and regtested on x86-64 Fedora 20.
2014-07-30 Tom Tromey <tromey@redhat.com>
* target.c (open_target): New function.
(add_target_with_completer, add_deprecated_target_alias): Use
set_cmd_sfunc, set_cmd_context.
(debug_to_open): Remove.
(setup_target_debug): Update.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/target.c | 37 |
2 files changed, 32 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e6f56c0..deccd31 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2014-07-30 Tom Tromey <tromey@redhat.com> + + * target.c (open_target): New function. + (add_target_with_completer, add_deprecated_target_alias): Use + set_cmd_sfunc, set_cmd_context. + (debug_to_open): Remove. + (setup_target_debug): Update. + 2014-07-30 Yao Qi <yao@codesourcery.com> * parser-defs.h (struct exp_descriptor) <operator_check>: Update diff --git a/gdb/target.c b/gdb/target.c index 46186bb..f5c9ba3 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -118,8 +118,6 @@ static struct target_ops debug_target; static void init_dummy_target (void); -static void debug_to_open (char *, int); - /* Pointer to array of target architecture structures; the size of the array; the current index into the array; the allocated size of the array. */ @@ -345,6 +343,24 @@ complete_target_initialization (struct target_ops *t) install_delegators (t); } +/* This is used to implement the various target commands. */ + +static void +open_target (char *args, int from_tty, struct cmd_list_element *command) +{ + struct target_ops *ops = get_cmd_context (command); + + if (targetdebug) + fprintf_unfiltered (gdb_stdlog, "-> %s->to_open (...)\n", + ops->to_shortname); + + ops->to_open (args, from_tty); + + if (targetdebug) + fprintf_unfiltered (gdb_stdlog, "<- %s->to_open (%s, %d)\n", + ops->to_shortname, args, from_tty); +} + /* Add possible target architecture T to the list and add a new command 'target T->to_shortname'. Set COMPLETER as the command's completer if not NULL. */ @@ -380,8 +396,9 @@ Remaining arguments are interpreted by the target protocol. For more\n\ information on the arguments for a particular protocol, type\n\ `help target ' followed by the protocol name."), &targetlist, "target ", 0, &cmdlist); - c = add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, - &targetlist); + c = add_cmd (t->to_shortname, no_class, NULL, t->to_doc, &targetlist); + set_cmd_sfunc (c, open_target); + set_cmd_context (c, t); if (completer != NULL) set_cmd_completer (c, completer); } @@ -404,7 +421,9 @@ add_deprecated_target_alias (struct target_ops *t, char *alias) /* If we use add_alias_cmd, here, we do not get the deprecated warning, see PR cli/15104. */ - c = add_cmd (alias, no_class, t->to_open, t->to_doc, &targetlist); + c = add_cmd (alias, no_class, NULL, t->to_doc, &targetlist); + set_cmd_sfunc (c, open_target); + set_cmd_context (c, t); alt = xstrprintf ("target %s", t->to_shortname); deprecate_cmd (c, alt); } @@ -2963,13 +2982,6 @@ init_dummy_target (void) install_dummy_methods (&dummy_target); } -static void -debug_to_open (char *args, int from_tty) -{ - debug_target.to_open (args, from_tty); - - fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty); -} void target_close (struct target_ops *targ) @@ -3415,7 +3427,6 @@ setup_target_debug (void) { memcpy (&debug_target, ¤t_target, sizeof debug_target); - current_target.to_open = debug_to_open; init_debug_target (¤t_target); } |