* RFA: change for gdb/mi 790
@ 2002-10-17 11:27 J. Johnston
2002-10-19 23:14 ` Eli Zaretskii
2002-10-22 8:50 ` Elena Zannoni
0 siblings, 2 replies; 3+ messages in thread
From: J. Johnston @ 2002-10-17 11:27 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 613 bytes --]
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 <jjohnstn@redhat.com>
* gdbmi.texinfo (-target-attach): Add example.
* mi-main.c (mi_cmd_target_attach): New command.
* mi-cmds.h (mi_cmd_target_attach): New prototype.
[-- Attachment #2: 790.patch --]
[-- Type: text/plain, Size: 3928 bytes --]
--- 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 <ctype.h>
#include <sys/time.h>
@@ -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 <pid> | <file>");
+
+ 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;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: RFA: change for gdb/mi 790
2002-10-17 11:27 RFA: change for gdb/mi 790 J. Johnston
@ 2002-10-19 23:14 ` Eli Zaretskii
2002-10-22 8:50 ` Elena Zannoni
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2002-10-19 23:14 UTC (permalink / raw)
To: J. Johnston; +Cc: gdb-patches
On Thu, 17 Oct 2002, J. Johnston wrote:
> Eli, there is a documentation change in the mi portions of the manual.
Thanks for the heads-up. The doco change is approved, but please break
the long line into 2, each one shorter than 64 characters, to avoid
ugliness in the printed manual. If you find that necessary, you can add
a note telling that the actual output is one long line.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFA: change for gdb/mi 790
2002-10-17 11:27 RFA: change for gdb/mi 790 J. Johnston
2002-10-19 23:14 ` Eli Zaretskii
@ 2002-10-22 8:50 ` Elena Zannoni
1 sibling, 0 replies; 3+ messages in thread
From: Elena Zannoni @ 2002-10-22 8:50 UTC (permalink / raw)
To: J. Johnston; +Cc: gdb-patches
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 <jjohnstn@redhat.com>
>
> * 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 <ctype.h>
> #include <sys/time.h>
> @@ -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 <pid> | <file>");
> +
> + 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;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-10-22 15:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-17 11:27 RFA: change for gdb/mi 790 J. Johnston
2002-10-19 23:14 ` Eli Zaretskii
2002-10-22 8:50 ` Elena Zannoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox