Bug 7250 - Fix implementation of ``target xxx''.
Summary: Fix implementation of ``target xxx''.
Alias: None
Product: gdb
Classification: Unclassified
Component: remote (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2001-07-06 20:18 UTC by ac131313
Modified: 2014-07-30 13:55 UTC (History)
2 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description ac131313 2001-07-07 03:18:01 UTC
[Converted from Gnats 145]

Fix implementation of  ``target xxx''.

At present when the user specifies ``target xxxx'', the CLI maps that
directly onto a target open method.  It is then assumed that the
target open method should do all sorts of complicated things as this
is the only chance it has.  Check how the various remote targets
duplicate the target operations.  Check also how the various targets
behave differently for purely arbitrary reasons.

What should happen is that ``target xxxx'' should call a generic
``target'' function and that should then co-ordinate the opening of
``xxxx''.  This becomes especially important when you're trying to
open an asynchronous target that may need to perform background tasks
as part of the ``attach'' phase.

Unfortunately, due to limitations in the old/creaking command.h
interface, that isn't possible.  The function being called isn't told
of the ``xxx'' or any other context information.

Consequently a precursor to fixing ``target xxxx'' is to clean up the
CLI code so that it passes to the callback function (attatched to a
command) useful information such as the actual command and a context
for that command.  Other changes such as making ``struct command''
opaque may also help.

See also:

Comment 1 Andrew Cagney 2002-03-19 02:19:18 UTC
From: cagney@sources.redhat.com
To: gdb-gnats@sources.redhat.com
Subject: gdb/145
Date: 19 Mar 2002 02:19:18 -0000

 CVSROOT:	/cvs/src
 Module name:	src
 Changes by:	cagney@sources.redhat.com	2002-03-18 18:19:18
 Modified files:
 	gdb            : ChangeLog command.h 
 	gdb/cli        : cli-decode.c cli-decode.h 
 Log message:
 	* command.h (struct cmd_list_element): Add field context.
 	(set_cmd_context, get_cmd_context): Declare.
 	* cli/cli-decode.h: Ditto.
 	* cli/cli-decode.c (get_cmd_context): New function.
 	(set_cmd_context): New function.
 	(add_cmd): Initialize context.
 	Part of fixing PR gdb/145 and PR gdb/146.
Comment 2 cvs-commit@gcc.gnu.org 2014-07-30 13:55:28 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  8981c75857ec8ef645ccb4f7ccc70fccc609085d (commit)
      from  cc6563d29b6f86b23c4f9a8ea73dabf9f7fc0d91 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------

commit 8981c75857ec8ef645ccb4f7ccc70fccc609085d
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Jul 21 14:32:43 2014 -0600

    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
    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.


Summary of changes:
 gdb/ChangeLog |    8 ++++++++
 gdb/target.c  |   37 ++++++++++++++++++++++++-------------
 2 files changed, 32 insertions(+), 13 deletions(-)