From: Dennis Brueni <dbrueni@slickedit.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Dennis Brueni <dbrueni@slickedit.com>
Subject: PATCH: GDB/MI - implement -exec-abort
Date: Thu, 23 Oct 2014 20:25:00 -0000 [thread overview]
Message-ID: <D06EB23F.17560%dbrueni@slickedit.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 541 bytes --]
The -exec–abort command has been documented as the MI equivalent to the kill command since GDB 5.1, but it was never implemented.
This patch does that.
gdb/ChangeLog
2014-10-23 Dennis Brueni <dbrueni@slickedit.com>
* mi/mi-cmds.c Add "exec-abort”
* mi/mi-cmds.h Add prototype for mi_cmd_exec_abort
* mi/mi-main.c Add mi_cmd_exec_abort (identical to kill_command minus prompting)
gdb/doc/ChangeLog
2014-10-23 Dennis Brueni <dbrueni@slickedit.com>
* doc/gdb.texinfo Revive -exec–abort documentation, add example.
[-- Attachment #2: gdb-7.8-exec-abort.diff --]
[-- Type: application/octet-stream, Size: 3149 bytes --]
diff -urN gdb-7.8-dist/gdb/mi/mi-cmds.c gdb-7.8/gdb/mi/mi-cmds.c
--- gdb-7.8-dist/gdb/mi/mi-cmds.c 2014-06-11 09:34:41.000000000 -0700
+++ gdb-7.8/gdb/mi/mi-cmds.c 2014-10-23 10:59:36.000000000 -0700
@@ -103,6 +103,7 @@
DEF_MI_CMD_MI ("exec-finish", mi_cmd_exec_finish),
DEF_MI_CMD_MI ("exec-jump", mi_cmd_exec_jump),
DEF_MI_CMD_MI ("exec-interrupt", mi_cmd_exec_interrupt),
+ DEF_MI_CMD_MI ("exec-abort", mi_cmd_exec_abort),
DEF_MI_CMD_MI ("exec-next", mi_cmd_exec_next),
DEF_MI_CMD_MI ("exec-next-instruction", mi_cmd_exec_next_instruction),
DEF_MI_CMD_MI ("exec-return", mi_cmd_exec_return),
diff -urN gdb-7.8-dist/gdb/mi/mi-cmds.h gdb-7.8/gdb/mi/mi-cmds.h
--- gdb-7.8-dist/gdb/mi/mi-cmds.h 2014-06-11 09:34:41.000000000 -0700
+++ gdb-7.8/gdb/mi/mi-cmds.h 2014-10-23 10:59:34.000000000 -0700
@@ -61,6 +61,7 @@
extern mi_cmd_argv_ftype mi_cmd_exec_continue;
extern mi_cmd_argv_ftype mi_cmd_exec_finish;
extern mi_cmd_argv_ftype mi_cmd_exec_interrupt;
+extern mi_cmd_argv_ftype mi_cmd_exec_abort;
extern mi_cmd_argv_ftype mi_cmd_exec_jump;
extern mi_cmd_argv_ftype mi_cmd_exec_next;
extern mi_cmd_argv_ftype mi_cmd_exec_next_instruction;
diff -urN gdb-7.8-dist/gdb/mi/mi-main.c gdb-7.8/gdb/mi/mi-main.c
--- gdb-7.8-dist/gdb/mi/mi-main.c 2014-07-29 05:37:42.000000000 -0700
+++ gdb-7.8/gdb/mi/mi-main.c 2014-10-23 11:27:27.000000000 -0700
@@ -405,6 +405,36 @@
}
}
+/* Stop the execution of the target. */
+
+void
+mi_cmd_exec_abort (char *command, char **argv, int argc)
+{
+ /* FIXME: This should not really be inferior_ptid (or target_has_execution).
+ It should be a distinct flag that indicates that a target is active, cuz
+ some targets don't have processes! */
+
+ if (ptid_equal (inferior_ptid, null_ptid))
+ error (_("The program is not being run."));
+ target_kill ();
+
+ /* If we still have other inferiors to debug, then don't mess with
+ with their threads. */
+ if (!have_inferiors ())
+ {
+ init_thread_list (); /* Destroy thread info. */
+
+ /* Killing off the inferior can leave us with a core file. If
+ so, print the state we are left in. */
+ if (target_has_stack)
+ {
+ printf_filtered (_("In %s,\n"), target_longname);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+ }
+ }
+ bfd_cache_close_all ();
+}
+
/* Callback for iterate_over_inferiors which starts the execution
of the given inferior.
diff -urN gdb-7.8-dist/gdb/doc/gdb.texinfo gdb-7.8/gdb/doc/gdb.texinfo
--- gdb-7.8-dist/gdb/doc/gdb.texinfo 2014-07-29 05:37:42.000000000 -0700
+++ gdb-7.8/gdb/doc/gdb.texinfo 2014-10-23 13:17:12.000000000 -0700
@@ -31051,7 +31051,6 @@
@end smallexample
-@ignore
@subheading The @code{-exec-abort} Command
@findex -exec-abort
@@ -31068,8 +31067,16 @@
The corresponding @value{GDBN} command is @samp{kill}.
@subsubheading Example
-N.A.
-@end ignore
+@smallexample
+(gdb)
+-exec-abort
+=thread-exited,id="9",group-id="i1"
+=thread-exited,id="2",group-id="i1"
+=thread-exited,id="1",group-id="i1"
+=thread-group-exited,id="i1"
+^done
+(gdb)
+@end smallexample
@subheading The @code{-gdb-set} Command
next reply other threads:[~2014-10-23 20:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 20:25 Dennis Brueni [this message]
2014-10-23 20:43 ` Eli Zaretskii
2014-10-23 22:01 ` Dennis Brueni
2014-10-24 6:50 ` Eli Zaretskii
2014-11-23 7:18 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D06EB23F.17560%dbrueni@slickedit.com \
--to=dbrueni@slickedit.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox