From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13704 invoked by alias); 22 Oct 2002 15:50:27 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 13639 invoked from network); 22 Oct 2002 15:50:25 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 22 Oct 2002 15:50:25 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id g9MFT7w24353 for ; Tue, 22 Oct 2002 11:29:07 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g9MFoOf08402; Tue, 22 Oct 2002 11:50:24 -0400 Received: from localhost.redhat.com (IDENT:H0Ba/xGc3ch1+BonuGCcVYU38vUsa7QZ@tooth.toronto.redhat.com [172.16.14.29]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g9MFoNw27134; Tue, 22 Oct 2002 11:50:23 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id 7D11BFF79; Tue, 22 Oct 2002 11:47:41 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15797.29469.402312.460926@localhost.redhat.com> Date: Tue, 22 Oct 2002 08:50:00 -0000 To: "J. Johnston" Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: change for gdb/mi 790 In-Reply-To: <3DAF0107.2AB28548@redhat.com> References: <3DAF0107.2AB28548@redhat.com> X-SW-Source: 2002-10/txt/msg00401.txt.bz2 J. Johnston writes: > The following patch adds support for -target-attach. It essentially copies the > code from target.c but removes the query in the case where target execution is > already in progress and simply performs the target_kill. I also changed the > output message to issue ^attached, .... as requested. > > Eli, there is a documentation change in the mi portions of the manual. > > Approval to commit? > Sorry, no. Look at the comments by Andrew in the PR about how to correctly fix this. It is going to be a bit more involved. Elena > -- Jeff J. > > gdb/mi/ChangeLog > > 2002-10-17 Jeff Johnston > > * gdbmi.texinfo (-target-attach): Add example. > * mi-main.c (mi_cmd_target_attach): New command. > * mi-cmds.h (mi_cmd_target_attach): New prototype.--- mi/mi-main.1.c Wed Oct 16 17:02:32 2002 > +++ mi/mi-main.c Thu Oct 17 14:08:41 2002 > @@ -40,6 +40,8 @@ > #include "regcache.h" > #include "gdb.h" > #include "frame.h" > +#include "command.h" /* for dont_repeat */ > +#include "symfile.h" /* for symbol_file_add_main */ > > #include > #include > @@ -752,6 +754,90 @@ > mi_out_rewind (uiout); > fputs_unfiltered ("\n", raw_stdout); > do_exec_cleanups (ALL_CLEANUPS); > + return MI_CMD_QUIET; > +} > + > +/* Attach a program either by pid or filename */ > +enum mi_cmd_result > +mi_cmd_target_attach (char *command, char **argv, int argc) > +{ > + char *exec_file; > + char *full_exec_path = NULL; > + > + dont_repeat (); /* Not for the faint of heart */ > + > + if (argc == 0 || argc > 1) > + error ("mi_cmd_target_attach: Usage -target-attach | "); > + > + if (target_has_execution) > + target_kill (); /* we kill any existing program being debugged */ > + > + target_attach (argv[0], FROM_TTY); > + > + /* Set up the "saved terminal modes" of the inferior > + based on what modes we are starting it with. */ > + target_terminal_init (); > + > + /* Install inferior's terminal modes. */ > + target_terminal_inferior (); > + > + /* Set up execution context to know that we should return from > + wait_for_inferior as soon as the target reports a stop. */ > + init_wait_for_inferior (); > + clear_proceed_status (); > + > + /* No traps are generated when attaching to inferior under Mach 3 > + or GNU hurd. */ > +#ifndef ATTACH_NO_WAIT > + stop_soon_quietly = 1; > + wait_for_inferior (); > +#endif > + > + /* > + * If no exec file is yet known, try to determine it from the > + * process itself. > + */ > + exec_file = (char *) get_exec_file (0); > + if (!exec_file) > + { > + exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid)); > + if (exec_file) > + { > + /* It's possible we don't have a full path, but rather just a > + filename. Some targets, such as HP-UX, don't provide the > + full path, sigh. > + > + Attempt to qualify the filename against the source path. > + (If that fails, we'll just fall back on the original > + filename. Not much more we can do...) > + */ > + if (!source_full_path_of (exec_file, &full_exec_path)) > + full_exec_path = savestring (exec_file, strlen (exec_file)); > + > + exec_file_attach (full_exec_path, FROM_TTY); > + symbol_file_add_main (full_exec_path, FROM_TTY); > + } > + } > + > +#ifdef SOLIB_ADD > + /* Add shared library symbols from the newly attached process, if any. */ > + SOLIB_ADD ((char *) 0, FROM_TTY, ¤t_target, auto_solib_add); > + re_enable_breakpoints_in_shlibs (); > +#endif > + > + /* Take any necessary post-attaching actions for this platform. > + */ > + target_post_attach (PIDGET (inferior_ptid)); > + > + normal_stop (); > + > + if (attach_hook) > + attach_hook (); > + > + fputs_unfiltered ("^attached", raw_stdout); > + mi_out_put (uiout, raw_stdout); > + mi_out_rewind (uiout); > + fputs_unfiltered ("\n", raw_stdout); > return MI_CMD_QUIET; > } > > --- mi/gdbmi.0.texinfo Thu Oct 17 14:23:25 2002 > +++ mi/gdbmi.texinfo Thu Oct 17 14:22:49 2002 > @@ -3073,8 +3073,13 @@ > The corresponding @value{GDBN} command is @samp{attach}. > > @subsubheading Example > -N.A. > > +@smallexample > +(@value{GDBP}) > +-target-attach 4567 > +^attached,thread-id="0",frame={addr="0x08048365",func="main",args=[],file="infloop.c",line="12"} > +(@value{GDBP}) > +@end smallexample > > @subheading The @code{-target-compare-sections} Command > @findex -target-compare-sections > --- mi/mi-cmds.0.h Wed Oct 16 17:34:22 2002 > +++ mi/mi-cmds.h Wed Oct 16 17:35:36 2002 > @@ -84,6 +84,7 @@ > extern mi_cmd_argv_ftype mi_cmd_stack_list_frames; > extern mi_cmd_argv_ftype mi_cmd_stack_list_locals; > extern mi_cmd_argv_ftype mi_cmd_stack_select_frame; > +extern mi_cmd_argv_ftype mi_cmd_target_attach; > extern mi_cmd_args_ftype mi_cmd_target_download; > extern mi_cmd_args_ftype mi_cmd_target_select; > extern mi_cmd_argv_ftype mi_cmd_thread_list_ids;