aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2011-02-25 19:19:26 +0000
committerMichael Snyder <msnyder@vmware.com>2011-02-25 19:19:26 +0000
commitc82c0b55e7f5182e3822f3878b9bc67a241d4f21 (patch)
tree6c0a9c8dd7f02ac84d7cf46af434a0ab79a2b6af /gdb
parent093a6ec67f9a17e6ef0e1b8ae828cbe5936f97fd (diff)
downloadgdb-c82c0b55e7f5182e3822f3878b9bc67a241d4f21.zip
gdb-c82c0b55e7f5182e3822f3878b9bc67a241d4f21.tar.gz
gdb-c82c0b55e7f5182e3822f3878b9bc67a241d4f21.tar.bz2
2011-02-25 Michael Snyder <msnyder@vmware.com>
* inferior.c (print_inferior): Accept a string instead of an int for requested_inferiors, and use get_number_or_range to parse it. (info_inferiors_command): Pass args string to print_inferior. (initialize_inferiors): Change help string for info inferiors. * inferior.h (print_inferior): Export prototype change. 2011-02-25 Michael Snyder <msnyder@vmware.com> * gdb.multi/base.exp: Add tests for info inferiors with args.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/inferior.c30
-rw-r--r--gdb/inferior.h6
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.multi/base.exp54
5 files changed, 78 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5b11f3a..eef187a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2011-02-25 Michael Snyder <msnyder@vmware.com>
+
+ * inferior.c (print_inferior): Accept a string instead of an int
+ for requested_inferiors, and use get_number_or_range to parse it.
+ (info_inferiors_command): Pass args string to print_inferior.
+ (initialize_inferiors): Change help string for info inferiors.
+ * inferior.h (print_inferior): Export prototype change.
+
2011-02-25 Tom Tromey <tromey@redhat.com>
* common/ax.def (invalid2): Set to 0x31.
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 081849e..ebe13bf 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -30,6 +30,7 @@
#include "gdbcore.h"
#include "symfile.h"
#include "environ.h"
+#include "cli/cli-utils.h"
void _initialize_inferiors (void);
@@ -533,10 +534,12 @@ number_of_inferiors (void)
/* Prints the list of inferiors and their details on UIOUT. This is a
version of 'info_inferior_command' suitable for use from MI.
- If REQUESTED_INFERIOR is not -1, it's the GDB id of the inferior that
- should be printed. Otherwise, all inferiors are printed. */
-void
-print_inferior (struct ui_out *uiout, int requested_inferior)
+ If REQUESTED_INFERIORS is not NULL, it's a list of GDB ids of the
+ inferiors that should be printed. Otherwise, all inferiors are
+ printed. */
+
+static void
+print_inferior (struct ui_out *uiout, char *requested_inferiors)
{
struct inferior *inf;
struct cleanup *old_chain;
@@ -545,7 +548,7 @@ print_inferior (struct ui_out *uiout, int requested_inferior)
/* Compute number of inferiors we will print. */
for (inf = inferior_list; inf; inf = inf->next)
{
- if (requested_inferior != -1 && inf->num != requested_inferior)
+ if (!number_is_in_list (requested_inferiors, inf->num))
continue;
++inf_count;
@@ -569,7 +572,7 @@ print_inferior (struct ui_out *uiout, int requested_inferior)
{
struct cleanup *chain2;
- if (requested_inferior != -1 && inf->num != requested_inferior)
+ if (!number_is_in_list (requested_inferiors, inf->num))
continue;
chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
@@ -726,16 +729,7 @@ inferior_command (char *args, int from_tty)
static void
info_inferiors_command (char *args, int from_tty)
{
- int requested = -1;
-
- if (args && *args)
- {
- requested = parse_and_eval_long (args);
- if (!valid_gdb_inferior_id (requested))
- error (_("Inferior ID %d not known."), requested);
- }
-
- print_inferior (uiout, requested);
+ print_inferior (uiout, args);
}
/* remove-inferior ID */
@@ -1048,8 +1042,8 @@ initialize_inferiors (void)
current_inferior_->pspace = current_program_space;
current_inferior_->aspace = current_program_space->aspace;
- add_info ("inferiors", info_inferiors_command,
- _("IDs of currently known inferiors."));
+ add_info ("inferiors", info_inferiors_command,
+ _("IDs of specified inferiors (all inferiors if no argument)."));
add_com ("add-inferior", no_class, add_inferior_command, _("\
Add a new inferior.\n\
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 381fd82..8508ce4 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -616,12 +616,6 @@ extern struct inferior *iterate_over_inferiors (int (*) (struct inferior *,
void *),
void *);
-/* Prints the list of inferiors and their details on UIOUT.
-
- If REQUESTED_INFERIOR is not -1, it's the GDB id of the inferior
- that should be printed. Otherwise, all inferiors are printed. */
-extern void print_inferior (struct ui_out *uiout, int requested_inferior);
-
/* Returns true if the inferior list is not empty. */
extern int have_inferiors (void);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index deedcd9..8e26291 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-25 Michael Snyder <msnyder@vmware.com>
+
+ * gdb.multi/base.exp: Add tests for info inferiors with args.
+
2011-02-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.dwarf2/dw2-ranges.S: Rename to ...
diff --git a/gdb/testsuite/gdb.multi/base.exp b/gdb/testsuite/gdb.multi/base.exp
index 55f90fd..c45b846 100644
--- a/gdb/testsuite/gdb.multi/base.exp
+++ b/gdb/testsuite/gdb.multi/base.exp
@@ -61,6 +61,60 @@ gdb_test "add-inferior -exec ${binfile3}" \
gdb_test "info inferiors" \
"Executable.*${exec3}.*${exec2}.*${exec1}.*"
+# Test info inferiors with args
+
+set see1 0
+set see2 0
+set see3 0
+
+gdb_test_multiple "info inferior 2 3" "info inferior 2 3" {
+ -re ". 3 \[^\r\n\]*${exec3}" {
+ set see3 1
+ exp_continue
+ }
+ -re ". 2 \[^\r\n\]*${exec2}" {
+ set see2 1
+ exp_continue
+ }
+ -re ". 1 \[^\r\n\]*${exec1}" {
+ set see1 1
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ if { !$see1 && $see2 && $see3 } then {
+ pass "info inferior 2 3"
+ } else {
+ fail "info inferior 2 3"
+ }
+ }
+}
+
+set see1 0
+set see2 0
+set see3 0
+
+gdb_test_multiple "info inferior 1-2" "info inferior 1-2" {
+ -re ". 3 \[^\r\n\]*${exec3}" {
+ set see3 1
+ exp_continue
+ }
+ -re ". 2 \[^\r\n\]*${exec2}" {
+ set see2 1
+ exp_continue
+ }
+ -re ". 1 \[^\r\n\]*${exec1}" {
+ set see1 1
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ if { $see1 && $see2 && !$see3 } then {
+ pass "info inferior 1-2"
+ } else {
+ fail "info inferior 1-2"
+ }
+ }
+}
+
# Test that we have multiple symbol tables.
gdb_test "inferior 1" ".*" "switch to inferior 1"