summaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2002-10-01 00:46:48 +0000
committerKeith Seitz <keiths@redhat.com>2002-10-01 00:46:48 +0000
commit24b8c9b305c0d4fdab9f54d39a20585c8bf84635 (patch)
treed202b91f41658f5076cb9eec4f4f839133e2720c /gdb/mi
parent9c562db82642857e703d44ff0f22667742882b92 (diff)
downloadgdb-24b8c9b305c0d4fdab9f54d39a20585c8bf84635.tar.gz
Merge with kseitz_interps-20020930-merge.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/ChangeLog25
-rw-r--r--gdb/mi/gdbmi.texinfo3
-rw-r--r--gdb/mi/mi-cmd-disas.c353
-rw-r--r--gdb/mi/mi-main.c96
-rw-r--r--gdb/mi/mi-out.c9
-rw-r--r--gdb/mi/mi-out.h3
6 files changed, 78 insertions, 411 deletions
diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog
index fd8558d728e..d895a044529 100644
--- a/gdb/mi/ChangeLog
+++ b/gdb/mi/ChangeLog
@@ -151,6 +151,31 @@
(mi_init_ui): Remove.
(_initialize_mi_main): Remove. No longer needed.
+2002-09-29 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-out.c (mi_version): New function.
+ * mi-out.h (mi_version): Declare.
+
+2002-09-27 Andrew Cagney <ac131313@redhat.com>
+
+ From 2002-07-12 Mo DeJong <supermo@bayarea.net>
+ * gdbmi.texinfo (var-evaluate-expression): Note that
+ var-list-children must be invoked before child variable
+ values can be evaluated.
+
+2002-09-26 Elena Zannoni <ezannoni@redhat.com>
+
+ * mi-cmd-disas.c (dump_insns): Add text only output for CLI.
+ (do_mixed_source_and_assembly): Ditto.
+
+2002-09-11 Keith Seitz <keiths@redhat.com>
+
+ * mi-main.c (mi_cmd_data_list_register_names): Use cleanups
+ for the uiout list. Do the cleanups when returning an error.
+ (mi_cmd_data_list_changed_registers): Ditto.
+ (mi_cmd_data_list_register_values): Use cleanups for the uiout list
+ and tuples. Do the cleanups when returning errors.
+
2002-07-29 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-var.c: Include "gdb_string.h".
diff --git a/gdb/mi/gdbmi.texinfo b/gdb/mi/gdbmi.texinfo
index e2d6c0fd24e..6efedd32ee3 100644
--- a/gdb/mi/gdbmi.texinfo
+++ b/gdb/mi/gdbmi.texinfo
@@ -3854,6 +3854,9 @@ for the object:
value=@var{value}
@end example
+Note that one must invoke @code{-var-list-children} for a variable
+before the value of a child variable can be evaluated.
+
@subheading The @code{-var-assign} Command
@findex -var-assign
diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c
index 028dc0758f3..168ca171666 100644
--- a/gdb/mi/mi-cmd-disas.c
+++ b/gdb/mi/mi-cmd-disas.c
@@ -24,348 +24,9 @@
#include "value.h"
#include "mi-cmds.h"
#include "mi-getopt.h"
-#include "ui-out.h"
#include "gdb_string.h"
-
-/* Disassemble functions. FIXME: these do not really belong here. We
- should get rid of all the duplicate code in gdb that does the same
- thing: disassemble_command() and the gdbtk variation. */
-
-/* This Structure is used in mi_cmd_disassemble.
- We need a different sort of line table from the normal one cuz we can't
- depend upon implicit line-end pc's for lines to do the
- reordering in this function. */
-
-struct dis_line_entry
-{
- int line;
- CORE_ADDR start_pc;
- CORE_ADDR end_pc;
-};
-
-/* This variable determines where memory used for disassembly is read from. */
-int gdb_disassemble_from_exec = -1;
-
-/* This is the memory_read_func for gdb_disassemble when we are
- disassembling from the exec file. */
-static int
-gdb_dis_asm_read_memory (bfd_vma memaddr, bfd_byte * myaddr,
- unsigned int len, disassemble_info * info)
-{
- extern struct target_ops exec_ops;
- int res;
-
- errno = 0;
- res = xfer_memory (memaddr, myaddr, len, 0, 0, &exec_ops);
-
- if (res == len)
- return 0;
- else if (errno == 0)
- return EIO;
- else
- return errno;
-}
-
-static int
-compare_lines (const PTR mle1p, const PTR mle2p)
-{
- struct dis_line_entry *mle1, *mle2;
- int val;
-
- mle1 = (struct dis_line_entry *) mle1p;
- mle2 = (struct dis_line_entry *) mle2p;
-
- val = mle1->line - mle2->line;
-
- if (val != 0)
- return val;
-
- return mle1->start_pc - mle2->start_pc;
-}
-
-static int
-dump_insns (disassemble_info * di, CORE_ADDR low, CORE_ADDR high,
- int how_many, struct ui_stream *stb)
-{
- int num_displayed = 0;
- CORE_ADDR pc;
-
- /* parts of the symbolic representation of the address */
- int unmapped;
- char *filename = NULL;
- char *name = NULL;
- int offset;
- int line;
-
- for (pc = low; pc < high;)
- {
- QUIT;
- if (how_many >= 0)
- {
- if (num_displayed >= how_many)
- break;
- else
- num_displayed++;
- }
- ui_out_tuple_begin (uiout, NULL);
- ui_out_field_core_addr (uiout, "address", pc);
-
- if (!build_address_symbolic (pc, 0, &name, &offset, &filename,
- &line, &unmapped))
- {
- /* We don't care now about line, filename and
- unmapped. But we might in the future. */
- ui_out_field_string (uiout, "func-name", name);
- ui_out_field_int (uiout, "offset", offset);
- }
- if (filename != NULL)
- xfree (filename);
- if (name != NULL)
- xfree (name);
-
- ui_file_rewind (stb->stream);
- pc += TARGET_PRINT_INSN (pc, di);
- ui_out_field_stream (uiout, "inst", stb);
- ui_file_rewind (stb->stream);
- ui_out_tuple_end (uiout);
- }
- return num_displayed;
-}
-
-/* The idea here is to present a source-O-centric view of a
- function to the user. This means that things are presented
- in source order, with (possibly) out of order assembly
- immediately following. */
-static void
-do_mixed_source_and_assembly (struct disassemble_info *di, int nlines,
- struct linetable_entry *le,
- CORE_ADDR low, CORE_ADDR high,
- struct symtab *symtab,
- int how_many, struct ui_stream *stb)
-{
- int newlines = 0;
- struct dis_line_entry *mle;
- struct symtab_and_line sal;
- int i;
- int out_of_order = 0;
- int next_line = 0;
- CORE_ADDR pc;
- int num_displayed = 0;
-
- mle = (struct dis_line_entry *) alloca (nlines
- * sizeof (struct dis_line_entry));
-
- /* Copy linetable entries for this function into our data
- structure, creating end_pc's and setting out_of_order as
- appropriate. */
-
- /* First, skip all the preceding functions. */
-
- for (i = 0; i < nlines - 1 && le[i].pc < low; i++);
-
- /* Now, copy all entries before the end of this function. */
-
- for (; i < nlines - 1 && le[i].pc < high; i++)
- {
- if (le[i].line == le[i + 1].line && le[i].pc == le[i + 1].pc)
- continue; /* Ignore duplicates */
-
- /* Skip any end-of-function markers. */
- if (le[i].line == 0)
- continue;
-
- mle[newlines].line = le[i].line;
- if (le[i].line > le[i + 1].line)
- out_of_order = 1;
- mle[newlines].start_pc = le[i].pc;
- mle[newlines].end_pc = le[i + 1].pc;
- newlines++;
- }
-
- /* If we're on the last line, and it's part of the function,
- then we need to get the end pc in a special way. */
-
- if (i == nlines - 1 && le[i].pc < high)
- {
- mle[newlines].line = le[i].line;
- mle[newlines].start_pc = le[i].pc;
- sal = find_pc_line (le[i].pc, 0);
- mle[newlines].end_pc = sal.end;
- newlines++;
- }
-
- /* Now, sort mle by line #s (and, then by addresses within
- lines). */
-
- if (out_of_order)
- qsort (mle, newlines, sizeof (struct dis_line_entry), compare_lines);
-
- /* Now, for each line entry, emit the specified lines (unless
- they have been emitted before), followed by the assembly code
- for that line. */
-
- ui_out_list_begin (uiout, "asm_insns");
-
- for (i = 0; i < newlines; i++)
- {
- int close_list = 1;
- /* Print out everything from next_line to the current line. */
- if (mle[i].line >= next_line)
- {
- if (next_line != 0)
- {
- /* Just one line to print. */
- if (next_line == mle[i].line)
- {
- ui_out_tuple_begin (uiout, "src_and_asm_line");
- print_source_lines (symtab, next_line, mle[i].line + 1, 0);
- }
- else
- {
- /* Several source lines w/o asm instructions associated. */
- for (; next_line < mle[i].line; next_line++)
- {
- ui_out_tuple_begin (uiout, "src_and_asm_line");
- print_source_lines (symtab, next_line, next_line + 1,
- 0);
- ui_out_list_begin (uiout, "line_asm_insn");
- ui_out_list_end (uiout);
- ui_out_tuple_end (uiout);
- }
- /* Print the last line and leave list open for
- asm instructions to be added. */
- ui_out_tuple_begin (uiout, "src_and_asm_line");
- print_source_lines (symtab, next_line, mle[i].line + 1, 0);
- }
- }
- else
- {
- ui_out_tuple_begin (uiout, "src_and_asm_line");
- print_source_lines (symtab, mle[i].line, mle[i].line + 1, 0);
- }
-
- next_line = mle[i].line + 1;
- ui_out_list_begin (uiout, "line_asm_insn");
- /* Don't close the list if the lines are not in order. */
- if (i < (newlines - 1) && mle[i + 1].line <= mle[i].line)
- close_list = 0;
- }
-
- num_displayed += dump_insns (di, mle[i].start_pc, mle[i].end_pc,
- how_many, stb);
- if (close_list)
- {
- ui_out_list_end (uiout);
- ui_out_tuple_end (uiout);
- close_list = 0;
- }
- if (how_many >= 0)
- if (num_displayed >= how_many)
- break;
- }
- ui_out_list_end (uiout);
-}
-
-
-static void
-do_assembly_only (disassemble_info * di, CORE_ADDR low,
- CORE_ADDR high, int how_many, struct ui_stream *stb)
-{
- int num_displayed = 0;
-
- ui_out_list_begin (uiout, "asm_insns");
-
- num_displayed = dump_insns (di, low, high, how_many, stb);
-
- ui_out_list_end (uiout);
-}
-
-enum mi_cmd_result
-do_disassembly (char *file_string,
- int line_num,
- int mixed_source_and_assembly,
- int how_many, CORE_ADDR low, CORE_ADDR high)
-{
- static disassemble_info di;
- static int di_initialized;
- /* To collect the instruction outputted from opcodes. */
- static struct ui_stream *stb = NULL;
- struct symtab *symtab = NULL;
- struct linetable_entry *le = NULL;
- int nlines = -1;
-
- if (!di_initialized)
- {
- /* We don't add a cleanup for this, because the allocation of
- the stream is done once only for each gdb run, and we need to
- keep it around until the end. Hopefully there won't be any
- errors in the init code below, that make this function bail
- out. */
- stb = ui_out_stream_new (uiout);
- INIT_DISASSEMBLE_INFO_NO_ARCH (di, stb->stream,
- (fprintf_ftype) fprintf_unfiltered);
- di.flavour = bfd_target_unknown_flavour;
- di.memory_error_func = dis_asm_memory_error;
- di.print_address_func = dis_asm_print_address;
- di_initialized = 1;
- }
-
- di.mach = TARGET_PRINT_INSN_INFO->mach;
- if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
- di.endian = BFD_ENDIAN_BIG;
- else
- di.endian = BFD_ENDIAN_LITTLE;
-
- /* If gdb_disassemble_from_exec == -1, then we use the following heuristic to
- determine whether or not to do disassembly from target memory or from the
- exec file:
-
- If we're debugging a local process, read target memory, instead of the
- exec file. This makes disassembly of functions in shared libs work
- correctly. Also, read target memory if we are debugging native threads.
-
- Else, we're debugging a remote process, and should disassemble from the
- exec file for speed. However, this is no good if the target modifies its
- code (for relocation, or whatever). */
-
- if (gdb_disassemble_from_exec == -1)
- {
- if (strcmp (target_shortname, "child") == 0
- || strcmp (target_shortname, "procfs") == 0
- || strcmp (target_shortname, "vxprocess") == 0
- || strstr (target_shortname, "-threads") != NULL)
- gdb_disassemble_from_exec = 0; /* It's a child process, read inferior mem */
- else
- gdb_disassemble_from_exec = 1; /* It's remote, read the exec file */
- }
-
- if (gdb_disassemble_from_exec)
- di.read_memory_func = gdb_dis_asm_read_memory;
- else
- di.read_memory_func = dis_asm_read_memory;
-
- /* Assume symtab is valid for whole PC range */
- symtab = find_pc_symtab (low);
-
- if (symtab != NULL && symtab->linetable != NULL)
- {
- /* Convert the linetable to a bunch of my_line_entry's. */
- le = symtab->linetable->item;
- nlines = symtab->linetable->nitems;
- }
-
- if (!mixed_source_and_assembly || nlines <= 0
- || symtab == NULL || symtab->linetable == NULL)
- do_assembly_only (&di, low, high, how_many, stb);
-
- else if (mixed_source_and_assembly)
- do_mixed_source_and_assembly (&di, nlines, le, low,
- high, symtab, how_many, stb);
-
- gdb_flush (gdb_stdout);
-
- return MI_CMD_DONE;
-}
+#include "ui-out.h"
+#include "disasm.h"
/* The arguments to be passed on the command line and parsed here are:
@@ -493,8 +154,10 @@ mi_cmd_disassemble (char *command, char **argv, int argc)
error ("mi_cmd_disassemble: No function contains specified address");
}
- retval = do_disassembly (file_string,
- line_num,
- mixed_source_and_assembly, how_many, low, high);
- return retval;
+ gdb_disassembly (uiout,
+ file_string,
+ line_num,
+ mixed_source_and_assembly, how_many, low, high);
+
+ return MI_CMD_DONE;
}
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index ef695aae51f..533c2fbd9c4 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -282,7 +282,8 @@ enum mi_cmd_result
mi_cmd_data_list_register_names (char *command, char **argv, int argc)
{
int regnum, numregs;
- int i, numbers;
+ int i;
+ struct cleanup *cleanup;
/* Note that the test for a valid register must include checking the
REGISTER_NAME because NUM_REGS may be allocated for the union of
@@ -291,28 +292,8 @@ mi_cmd_data_list_register_names (char *command, char **argv, int argc)
the particular processor being debugged. */
numregs = NUM_REGS + NUM_PSEUDO_REGS;
- numbers = 0;
- if (!gdb_current_interpreter_is_named (GDB_INTERPRETER_MI0)
- && !gdb_current_interpreter_is_named (GDB_INTERPRETER_MI1)
- && argc > 0 && *argv[0] == '-')
- {
- if (strncmp (argv[0], "-numbers", strlen (argv[0])) == 0)
- {
- numbers = 1;
- --argc;
- ++argv;
- }
- else
- {
- xasprintf (&mi_error_message,
- "mi_cmd_data_list_register_names: invalid option \"%s\"",
- argv[0]);
- return MI_CMD_ERROR;
- }
- }
-
- ui_out_list_begin (uiout, "register-names");
+ cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-names");
if (argc == 0) /* No args, just do all the regs */
{
@@ -324,17 +305,7 @@ mi_cmd_data_list_register_names (char *command, char **argv, int argc)
|| *(REGISTER_NAME (regnum)) == '\0')
ui_out_field_string (uiout, NULL, "");
else
- {
- if (numbers)
- {
- ui_out_tuple_begin (uiout, NULL);
- ui_out_field_int (uiout, "number", regnum);
- ui_out_field_string (uiout, "name", REGISTER_NAME (regnum));
- ui_out_tuple_end (uiout);
- }
- else
- ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
- }
+ ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
}
}
@@ -344,36 +315,17 @@ mi_cmd_data_list_register_names (char *command, char **argv, int argc)
regnum = atoi (argv[i]);
if (regnum < 0 || regnum >= numregs)
{
+ do_cleanups (cleanup);
xasprintf (&mi_error_message, "bad register number");
return MI_CMD_ERROR;
}
if (REGISTER_NAME (regnum) == NULL
|| *(REGISTER_NAME (regnum)) == '\0')
- {
- if (numbers)
- {
- ui_out_tuple_begin (uiout, NULL);
- ui_out_field_int (uiout, "number", regnum);
- ui_out_field_string (uiout, "name", "");
- ui_out_tuple_end (uiout);
- }
- else
- ui_out_field_string (uiout, NULL, "");
- }
+ ui_out_field_string (uiout, NULL, "");
else
- {
- if (numbers)
- {
- ui_out_tuple_begin (uiout, NULL);
- ui_out_field_int (uiout, "number", regnum);
- ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
- ui_out_tuple_end (uiout);
- }
- else
- ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
- }
+ ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
}
- ui_out_list_end (uiout);
+ do_cleanups (cleanup);
return MI_CMD_DONE;
}
@@ -382,6 +334,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
{
int regnum, numregs, changed;
int i;
+ struct cleanup *cleanup;
/* Note that the test for a valid register must include checking the
REGISTER_NAME because NUM_REGS may be allocated for the union of
@@ -391,7 +344,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
numregs = NUM_REGS;
- ui_out_list_begin (uiout, "changed-registers");
+ cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changed-registers");
if (argc == 0) /* No args, just do all the regs */
{
@@ -405,6 +358,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
changed = register_changed_p (regnum);
if (changed < 0)
{
+ do_cleanups (cleanup);
xasprintf (&mi_error_message,
"mi_cmd_data_list_changed_registers: Unable to read register contents.");
return MI_CMD_ERROR;
@@ -427,6 +381,7 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
changed = register_changed_p (regnum);
if (changed < 0)
{
+ do_cleanups (cleanup);
xasprintf (&mi_error_message,
"mi_cmd_data_list_register_change: Unable to read register contents.");
return MI_CMD_ERROR;
@@ -436,11 +391,12 @@ mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
}
else
{
+ do_cleanups (cleanup);
xasprintf (&mi_error_message, "bad register number");
return MI_CMD_ERROR;
}
}
- ui_out_list_end (uiout);
+ do_cleanups (cleanup);
return MI_CMD_DONE;
}
@@ -476,6 +432,7 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
{
int regnum, numregs, format, result;
int i;
+ struct cleanup *list_cleanup, *tuple_cleanup;
/* Note that the test for a valid register must include checking the
REGISTER_NAME because NUM_REGS may be allocated for the union of
@@ -501,7 +458,7 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
return MI_CMD_ERROR;
}
- ui_out_list_begin (uiout, "register-values");
+ list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values");
if (argc == 1) /* No args, beside the format: do all the regs */
{
@@ -512,12 +469,15 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
if (REGISTER_NAME (regnum) == NULL
|| *(REGISTER_NAME (regnum)) == '\0')
continue;
- ui_out_tuple_begin (uiout, NULL);
+ tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_int (uiout, "number", regnum);
result = get_register (regnum, format);
if (result == -1)
- return MI_CMD_ERROR;
- ui_out_tuple_end (uiout);
+ {
+ do_cleanups (list_cleanup);
+ return MI_CMD_ERROR;
+ }
+ do_cleanups (tuple_cleanup);
}
}
@@ -531,20 +491,24 @@ mi_cmd_data_list_register_values (char *command, char **argv, int argc)
&& REGISTER_NAME (regnum) != NULL
&& *REGISTER_NAME (regnum) != '\000')
{
- ui_out_tuple_begin (uiout, NULL);
+ tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_int (uiout, "number", regnum);
result = get_register (regnum, format);
if (result == -1)
- return MI_CMD_ERROR;
- ui_out_tuple_end (uiout);
+ {
+ do_cleanups (list_cleanup);
+ return MI_CMD_ERROR;
+ }
+ do_cleanups (tuple_cleanup);
}
else
{
+ do_cleanups (list_cleanup);
xasprintf (&mi_error_message, "bad register number");
return MI_CMD_ERROR;
}
}
- ui_out_list_end (uiout);
+ do_cleanups (list_cleanup);
return MI_CMD_DONE;
}
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 947720bc10c..f7ed7ecfbdc 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -428,6 +428,15 @@ mi_out_put (struct ui_out *uiout,
ui_file_rewind (data->buffer);
}
+/* Current MI version. */
+
+int
+mi_version (struct ui_out *uiout)
+{
+ struct ui_out_data *data = ui_out_data (uiout);
+ return data->mi_version;
+}
+
/* initalize private members at startup */
struct ui_out *
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index 1ae693f4761..817f2eb53b9 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -30,4 +30,7 @@ extern void mi_out_put (struct ui_out *uiout, struct ui_file *stream);
extern void mi_out_rewind (struct ui_out *uiout);
extern void mi_out_buffered (struct ui_out *uiout, char *string);
+/* Return the version number of the current MI. */
+extern int mi_version (struct ui_out *uiout);
+
#endif /* MI_OUT_H */