From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14357 invoked by alias); 17 Oct 2002 18:27:23 -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 14338 invoked from network); 17 Oct 2002 18:27:20 -0000 Received: from unknown (HELO touchme.toronto.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 17 Oct 2002 18:27:20 -0000 Received: from redhat.com (toocool.toronto.redhat.com [172.16.14.72]) by touchme.toronto.redhat.com (Postfix) with ESMTP id 78EEC8000E3 for ; Thu, 17 Oct 2002 14:27:19 -0400 (EDT) Message-ID: <3DAF0107.2AB28548@redhat.com> Date: Thu, 17 Oct 2002 11:27:00 -0000 From: "J. Johnston" Organization: Red Hat Inc. X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: RFA: change for gdb/mi 790 Content-Type: multipart/mixed; boundary="------------86902059FFA20D6F682AD228" X-SW-Source: 2002-10/txt/msg00288.txt.bz2 This is a multi-part message in MIME format. --------------86902059FFA20D6F682AD228 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 613 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? -- 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. --------------86902059FFA20D6F682AD228 Content-Type: text/plain; charset=us-ascii; name="790.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="790.patch" Content-length: 3928 --- 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; --------------86902059FFA20D6F682AD228--