* [mi] [ada] varobjs for registers 2
@ 2006-12-20 18:38 Vladimir Prus
2006-12-20 19:44 ` Eli Zaretskii
2006-12-21 7:20 ` Joel Brobecker
0 siblings, 2 replies; 9+ messages in thread
From: Vladimir Prus @ 2006-12-20 18:38 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]
This is a second revision of the patch to add MI command that
creates varobjs for registers. The command is renamed to -var-list
and used like:
-var-list --registers
There are now docs and tests. The created variable objects no longer
have 'public' pseudo-fields, no matter what the language of the program is.
Along the way, I've promoted a private function in ada-lang.c to language.c,
so I'd appreciate if Ada maintainers take a quick look.
OK?
- Volodya
Implement the -var-list command, with initial support
for listing registers.
* mi/mi-cmds.h (mi_cmd_var_list): New.
* mi/mi-cmds.c: Register "var-list".
* mi/mi-cmd-var.c (create_varobj_in_frame): New function.
(mi_cmd_var_create): Use the above.
(restore_language_mode): New.
(mi_cmd_var_list): New.
* language.h (restore_language): Declare.
* language.c (restore_language): New function.
* ada-lang.c (restore_language): Remove.
(lookup_symbol_in_language): Adjust.
* Makefile (mi-cmd-var.o): Update dependencies.
doc/
* gdb.texinfo (GDB/MI Variable Objects): Document
-var-list.
testsuite/
* gdb.mi/mi-var-cmd.exp: Test for -var-list.
[-- Attachment #2: varobj_for_registers__gdb_mainline.diff --]
[-- Type: text/x-diff, Size: 11074 bytes --]
--- gdb/ada-lang.c (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/ada-lang.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -4210,13 +4210,7 @@ add_symbols_from_enclosing_procs (struct
{
}
-/* FIXME: The next two routines belong in symtab.c */
-
-static void
-restore_language (void *lang)
-{
- set_language ((enum language) lang);
-}
+/* FIXME: The next routine belongs in symtab.c */
/* As for lookup_symbol, but performed as if the current language
were LANG. */
@@ -4226,10 +4220,10 @@ lookup_symbol_in_language (const char *n
domain_enum domain, enum language lang,
int *is_a_field_of_this, struct symtab **symtab)
{
+ enum language prev_lang = set_language (lang);
struct cleanup *old_chain
- = make_cleanup (restore_language, (void *) current_language->la_language);
+ = make_cleanup (restore_language, &prev_lang);
struct symbol *result;
- set_language (lang);
result = lookup_symbol (name, block, domain, is_a_field_of_this, symtab);
do_cleanups (old_chain);
return result;
--- gdb/doc/gdb.texinfo (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/doc/gdb.texinfo (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -19600,6 +19600,8 @@ access this functionality:
@item @code{-var-create}
@tab create a variable object
+@item @code{-var-list}
+@tab create special kinds of variable objects
@item @code{-var-delete}
@tab delete the variable object and/or its children
@item @code{-var-set-format}
@@ -19678,6 +19680,39 @@ the @value{GDBN} CLI:
@end smallexample
+@subheading The @code{-var-list} Command
+@findex -var-list
+
+@subsubheading Synopsis
+
+@smallexample
+ -var-list --@var{kind} @{@var{frame-addr} | "*"@}
+@end smallexample
+
+Creates and returns all variable objects of the specified kind.
+This command is intended to efficiently create a number of variable
+objects---for example for registers, or for local variables. Using
+the @code{-var-create} command would not be ideal, because it must be
+issued once for every variable object.
+At the moment the only defined kind is ``registers''.
+
+The @var{frame-addr} parameter the same semantics as for
+@code{-var-create}. For registers, any frame but the current must
+be used with caution, as gdb can determine the value in the parent
+frames only for a few registers.
+
+@subsubheading Result
+
+The MI result record includes the @samp{result} field which value is
+a list of tuples. Each tuple describes a single variable object in
+the same was as for the @code{-var-create} command:
+
+@smallexample
+^done,registers=[{name="var1",exp="$eax",numchild="0",value="16",type="int"},....
+@end smallexample
+
+
+
@subheading The @code{-var-delete} Command
@findex -var-delete
--- gdb/testsuite/gdb.mi/mi-var-cmd.exp (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/testsuite/gdb.mi/mi-var-cmd.exp (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -599,5 +599,9 @@ mi_gdb_test "-var-update selected_a" \
"\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
"update selected_a in do_special_tests"
+mi_gdb_test "-var-list --registers *" \
+ "\\^done,result=\\\[{name=\".*\",exp=\".*\",numchild=\".*\",value=\".*\",type=\".*\"},.*" \
+ "create list of registers"
+
mi_gdb_exit
return 0
--- gdb/mi/mi-cmds.h (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/mi/mi-cmds.h (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -105,6 +105,7 @@ extern mi_cmd_argv_ftype mi_cmd_thread_l
extern mi_cmd_argv_ftype mi_cmd_thread_select;
extern mi_cmd_argv_ftype mi_cmd_var_assign;
extern mi_cmd_argv_ftype mi_cmd_var_create;
+extern mi_cmd_argv_ftype mi_cmd_var_list;
extern mi_cmd_argv_ftype mi_cmd_var_delete;
extern mi_cmd_argv_ftype mi_cmd_var_evaluate_expression;
extern mi_cmd_argv_ftype mi_cmd_var_info_expression;
--- gdb/mi/mi-cmds.c (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/mi/mi-cmds.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -153,6 +153,7 @@ struct mi_cmd mi_cmds[] =
{ "trace-stop", { NULL, 0 }, NULL, NULL },
{ "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign},
{ "var-create", { NULL, 0 }, 0, mi_cmd_var_create},
+ { "var-list", { NULL, 0 }, 0, mi_cmd_var_list},
{ "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete},
{ "var-evaluate-expression", { NULL, 0 }, 0, mi_cmd_var_evaluate_expression},
{ "var-info-expression", { NULL, 0 }, 0, mi_cmd_var_info_expression},
--- gdb/mi/mi-cmd-var.c (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/mi/mi-cmd-var.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -29,6 +29,7 @@
#include "value.h"
#include <ctype.h>
#include "gdb_string.h"
+#include "language.h"
const char mi_no_values[] = "--no-values";
const char mi_simple_values[] = "--simple-values";
@@ -68,16 +69,39 @@ print_varobj (struct varobj *var, enum p
/* VAROBJ operations */
+static struct varobj *
+create_varobj_in_frame (char *name, char *expression, char *frame)
+{
+ CORE_ADDR frameaddr = 0;
+ struct cleanup *cleanup;
+ enum varobj_type var_type;
+
+ if (strcmp (frame, "*") == 0)
+ var_type = USE_CURRENT_FRAME;
+ else if (strcmp (frame, "@") == 0)
+ var_type = USE_SELECTED_FRAME;
+ else
+ {
+ var_type = USE_SPECIFIED_FRAME;
+ frameaddr = string_to_core_addr (frame);
+ }
+
+ if (varobjdebug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
+ name, frame, paddr (frameaddr), expression);
+
+ return varobj_create (name, expression, frameaddr, var_type);
+}
+
enum mi_cmd_result
mi_cmd_var_create (char *command, char **argv, int argc)
{
- CORE_ADDR frameaddr = 0;
struct varobj *var;
char *name;
char *frame;
char *expr;
struct cleanup *old_cleanups;
- enum varobj_type var_type;
if (argc != 3)
{
@@ -105,22 +129,7 @@ mi_cmd_var_create (char *command, char *
else if (!isalpha (*name))
error (_("mi_cmd_var_create: name of object must begin with a letter"));
- if (strcmp (frame, "*") == 0)
- var_type = USE_CURRENT_FRAME;
- else if (strcmp (frame, "@") == 0)
- var_type = USE_SELECTED_FRAME;
- else
- {
- var_type = USE_SPECIFIED_FRAME;
- frameaddr = string_to_core_addr (frame);
- }
-
- if (varobjdebug)
- fprintf_unfiltered (gdb_stdlog,
- "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
- name, frame, paddr (frameaddr), expr);
-
- var = varobj_create (name, expr, frameaddr, var_type);
+ var = create_varobj_in_frame (name, expr, frame);
if (var == NULL)
error (_("mi_cmd_var_create: unable to create variable object"));
@@ -131,6 +140,84 @@ mi_cmd_var_create (char *command, char *
return MI_CMD_DONE;
}
+static void restore_language_mode (void *p)
+{
+ enum language_mode *mode = p;
+ language_mode = *mode;
+}
+
+enum mi_cmd_result
+mi_cmd_var_list (char *command, char **argv, int argc)
+{
+ int regnum, numregs;
+ struct cleanup *cleanup;
+ char *what;
+ char *frame;
+ enum language prev_lang;
+ enum language_mode prev_lang_mode;
+
+ if (argc < 2)
+ error (_("mi_cmd_var_list: Usage: --WHAT FRAME."));
+
+ what = argv[0];
+
+ if (strcmp (what, "--registers") != 0)
+ error (_("mi_cmd_var_list: invalid kind of object requested."));
+
+ frame = xstrdup (argv[1]);
+ cleanup = make_cleanup (xfree, frame);
+
+
+ /* Force C language for registers, to avoid 'public' pseudo-fields
+ that make no sense for registers. */
+ prev_lang = set_language (language_c);
+ make_cleanup (restore_language, &prev_lang);
+ /* Also switch the language mode to manual. Otherwise,
+ when varobj_create calls select_frame, the language
+ will be automatically switched. */
+ prev_lang_mode = language_mode;
+ language_mode = language_mode_manual;
+ make_cleanup (restore_language_mode, &prev_lang_mode);
+
+ /* Note that the test for a valid register must include checking the
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = NUM_REGS + NUM_PSEUDO_REGS;
+
+ make_cleanup_ui_out_list_begin_end (uiout, "result");
+
+ for (regnum = 0; regnum < numregs; regnum++)
+ {
+ if (REGISTER_NAME (regnum) != NULL
+ && *(REGISTER_NAME (regnum)) != '\0')
+ {
+ char *name;
+ char *expression;
+ struct varobj *var;
+ struct cleanup *cleanup_child;
+
+ name = varobj_gen_name ();
+ make_cleanup (xfree, name);
+
+ expression = xstrprintf ("$%s", REGISTER_NAME (regnum));
+ make_cleanup (xfree, expression);
+
+ var = create_varobj_in_frame (name, expression, frame);
+
+ cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ print_varobj (var, PRINT_ALL_VALUES, 1 /* print expression */);
+ do_cleanups (cleanup_child);
+ }
+ }
+
+ do_cleanups (cleanup);
+ return MI_CMD_DONE;
+}
+
+
enum mi_cmd_result
mi_cmd_var_delete (char *command, char **argv, int argc)
{
--- gdb/language.c (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/language.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -401,6 +401,14 @@ set_language (enum language lang)
return prev_language;
}
+
+void
+restore_language (void *arg)
+{
+ enum language *lang_p = arg;
+
+ set_language (*lang_p);
+}
\f
/* This page contains functions that update the global vars
language, type and range. */
--- gdb/language.h (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/language.h (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -472,4 +472,10 @@ extern void default_print_array_index (s
int format,
enum val_prettyprint pretty);
+/* Cast 'lang' to 'enum language *', dererence it, and
+ set the current language to the value.
+
+ This function is intended to be used as cleanup function. */
+extern void restore_language (void *lang);
+
#endif /* defined (LANGUAGE_H) */
--- gdb/Makefile.in (/mirrors/gdb_mainline) (revision 2770)
+++ gdb/Makefile.in (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 2770)
@@ -3113,7 +3113,7 @@ mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stac
$(stack_h) $(dictionary_h) $(gdb_string_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
mi-cmd-var.o: $(srcdir)/mi/mi-cmd-var.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
- $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h)
+ $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-var.c
mi-console.o: $(srcdir)/mi/mi-console.c $(defs_h) $(mi_console_h) \
$(gdb_string_h)
Property changes on:
___________________________________________________________________
Name: csl:base
+/all/mirrors/gdb_mainline
Name: svk:merge
+e7755896-6108-0410-9592-8049d3e74e28:/mirrors/gdb/trunk:157978
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [mi] [ada] varobjs for registers 2
2006-12-20 18:38 [mi] [ada] varobjs for registers 2 Vladimir Prus
@ 2006-12-20 19:44 ` Eli Zaretskii
2007-01-05 9:01 ` Vladimir Prus
2006-12-21 7:20 ` Joel Brobecker
1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2006-12-20 19:44 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Wed, 20 Dec 2006 21:37:28 +0300
>
> This is a second revision of the patch to add MI command that
> creates varobjs for registers. The command is renamed to -var-list
> and used like:
>
> -var-list --registers
>
> There are now docs and tests. The created variable objects no longer
> have 'public' pseudo-fields, no matter what the language of the program is.
>
> Along the way, I've promoted a private function in ada-lang.c to language.c,
> so I'd appreciate if Ada maintainers take a quick look.
>
> OK?
Thanks.
The patch for the manual is approved, but please take care of these
minor problems:
> +This command is intended to efficiently create a number of variable
> +objects---for example for registers, or for local variables. Using
> +the @code{-var-create} command would not be ideal, because it must be
> +issued once for every variable object.
Please add a cross-reference to the description of -var-create here.
> +be used with caution, as gdb can determine the value in the parent
^^^
Please use @value{GDBN}.
> +The MI result record includes the @samp{result} field which value is
^^^^^^
"whose value is..."
> +a list of tuples. Each tuple describes a single variable object in
> +the same was as for the @code{-var-create} command:
^^^^^^^^^^^^^^^^^^^
Something's wrong here.
> +@smallexample
> +^done,registers=[{name="var1",exp="$eax",numchild="0",value="16",type="int"},....
> +@end smallexample
This line is too long for @smallexample, please break it into two
lines.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [mi] [ada] varobjs for registers 2
2006-12-20 19:44 ` Eli Zaretskii
@ 2007-01-05 9:01 ` Vladimir Prus
2007-01-05 9:29 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Vladimir Prus @ 2007-01-05 9:01 UTC (permalink / raw)
To: Eli Zaretskii, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1658 bytes --]
Eli Zaretskii wrote:
>> From: Vladimir Prus <vladimir@codesourcery.com>
>> Date: Wed, 20 Dec 2006 21:37:28 +0300
>>
>> This is a second revision of the patch to add MI command that
>> creates varobjs for registers. The command is renamed to -var-list
>> and used like:
>>
>> -var-list --registers
>>
>> There are now docs and tests. The created variable objects no longer
>> have 'public' pseudo-fields, no matter what the language of the program
>> is.
>>
>> Along the way, I've promoted a private function in ada-lang.c to
>> language.c, so I'd appreciate if Ada maintainers take a quick look.
>>
>> OK?
>
> Thanks.
>
> The patch for the manual is approved, but please take care of these
> minor problems:
>
>> +This command is intended to efficiently create a number of variable
>> +objects---for example for registers, or for local variables. Using
>> +the @code{-var-create} command would not be ideal, because it must be
>> +issued once for every variable object.
>
> Please add a cross-reference to the description of -var-create here.
Is
Using the @code{-var-create} (@pxref{-var-list-children}) command
the right texinfo way to do a reference?
>> +a list of tuples. Each tuple describes a single variable object in
>> +the same was as for the @code{-var-create} command:
> ^^^^^^^^^^^^^^^^^^^
> Something's wrong here.
It meant to be:
the same way as for the @code{-var-create} command:
Revised patch attached. In addition to the changes you've suggested, I've
reworded the first paragraph to more explicitly document that -var-list
tries to return previously-created varobjs, as Nick and I discussed.
OK?
- Volodya
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: varobj_for_registers__gdb_mainline.diff --]
[-- Type: text/x-diff; name="varobj_for_registers__gdb_mainline.diff", Size: 11339 bytes --]
--- gdb/ada-lang.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/ada-lang.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -4210,13 +4210,7 @@ add_symbols_from_enclosing_procs (struct
{
}
-/* FIXME: The next two routines belong in symtab.c */
-
-static void
-restore_language (void *lang)
-{
- set_language ((enum language) lang);
-}
+/* FIXME: The next routine belongs in symtab.c */
/* As for lookup_symbol, but performed as if the current language
were LANG. */
@@ -4226,10 +4220,10 @@ lookup_symbol_in_language (const char *n
domain_enum domain, enum language lang,
int *is_a_field_of_this, struct symtab **symtab)
{
+ enum language prev_lang = set_language (lang);
struct cleanup *old_chain
- = make_cleanup (restore_language, (void *) current_language->la_language);
+ = make_cleanup (restore_language, &prev_lang);
struct symbol *result;
- set_language (lang);
result = lookup_symbol (name, block, domain, is_a_field_of_this, symtab);
do_cleanups (old_chain);
return result;
--- gdb/doc/gdb.texinfo (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/doc/gdb.texinfo (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -19600,6 +19600,8 @@ access this functionality:
@item @code{-var-create}
@tab create a variable object
+@item @code{-var-list}
+@tab create special kinds of variable objects
@item @code{-var-delete}
@tab delete the variable object and/or its children
@item @code{-var-set-format}
@@ -19678,6 +19680,45 @@ the @value{GDBN} CLI:
@end smallexample
+@subheading The @code{-var-list} Command
+@findex -var-list
+
+@subsubheading Synopsis
+
+@smallexample
+ -var-list --@var{kind} @{@var{frame-addr} | "*"@}
+@end smallexample
+
+Returns all variable objects of the specified kind, creating them
+if necessary. This command is intended to efficiently obtain a number
+of variable objects---for example for registers, or for local variables. Using
+the @code{-var-create} (@pxref{-var-list-children}) command would
+not be ideal, because it must be issued once for every variable
+object. In addition, subsequent @code{-var-list} invocations generally
+try to return variable objects that were created and returned on
+previous invocation, which additionally improves performance.
+
+At the moment the only defined kind is ``registers''.
+
+The @var{frame-addr} parameter the same semantics as for
+@code{-var-create}. For registers, any frame but the current must
+be used with caution, as @value{GDBN} can determine the value in the parent
+frames only for a few registers.
+
+@subsubheading Result
+
+The MI result record includes the @samp{result} field whose value is
+a list of tuples. Each tuple describes a single variable object in
+the same way as for the @code{-var-create} command:
+
+@smallexample
+^done,registers=[
+ {name="var1",exp="$eax",
+ numchild="0",value="16",type="int"},....
+@end smallexample
+
+
+
@subheading The @code{-var-delete} Command
@findex -var-delete
--- gdb/testsuite/gdb.mi/mi-var-cmd.exp (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/testsuite/gdb.mi/mi-var-cmd.exp (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -599,5 +599,9 @@ mi_gdb_test "-var-update selected_a" \
"\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
"update selected_a in do_special_tests"
+mi_gdb_test "-var-list --registers *" \
+ "\\^done,result=\\\[{name=\".*\",exp=\".*\",numchild=\".*\",value=\".*\",type=\".*\"},.*" \
+ "create list of registers"
+
mi_gdb_exit
return 0
--- gdb/mi/mi-cmds.h (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/mi/mi-cmds.h (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -105,6 +105,7 @@ extern mi_cmd_argv_ftype mi_cmd_thread_l
extern mi_cmd_argv_ftype mi_cmd_thread_select;
extern mi_cmd_argv_ftype mi_cmd_var_assign;
extern mi_cmd_argv_ftype mi_cmd_var_create;
+extern mi_cmd_argv_ftype mi_cmd_var_list;
extern mi_cmd_argv_ftype mi_cmd_var_delete;
extern mi_cmd_argv_ftype mi_cmd_var_evaluate_expression;
extern mi_cmd_argv_ftype mi_cmd_var_info_expression;
--- gdb/mi/mi-cmds.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/mi/mi-cmds.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -153,6 +153,7 @@ struct mi_cmd mi_cmds[] =
{ "trace-stop", { NULL, 0 }, NULL, NULL },
{ "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign},
{ "var-create", { NULL, 0 }, 0, mi_cmd_var_create},
+ { "var-list", { NULL, 0 }, 0, mi_cmd_var_list},
{ "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete},
{ "var-evaluate-expression", { NULL, 0 }, 0, mi_cmd_var_evaluate_expression},
{ "var-info-expression", { NULL, 0 }, 0, mi_cmd_var_info_expression},
--- gdb/mi/mi-cmd-var.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/mi/mi-cmd-var.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -29,6 +29,7 @@
#include "value.h"
#include <ctype.h>
#include "gdb_string.h"
+#include "language.h"
const char mi_no_values[] = "--no-values";
const char mi_simple_values[] = "--simple-values";
@@ -68,16 +69,39 @@ print_varobj (struct varobj *var, enum p
/* VAROBJ operations */
+static struct varobj *
+create_varobj_in_frame (char *name, char *expression, char *frame)
+{
+ CORE_ADDR frameaddr = 0;
+ struct cleanup *cleanup;
+ enum varobj_type var_type;
+
+ if (strcmp (frame, "*") == 0)
+ var_type = USE_CURRENT_FRAME;
+ else if (strcmp (frame, "@") == 0)
+ var_type = USE_SELECTED_FRAME;
+ else
+ {
+ var_type = USE_SPECIFIED_FRAME;
+ frameaddr = string_to_core_addr (frame);
+ }
+
+ if (varobjdebug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
+ name, frame, paddr (frameaddr), expression);
+
+ return varobj_create (name, expression, frameaddr, var_type);
+}
+
enum mi_cmd_result
mi_cmd_var_create (char *command, char **argv, int argc)
{
- CORE_ADDR frameaddr = 0;
struct varobj *var;
char *name;
char *frame;
char *expr;
struct cleanup *old_cleanups;
- enum varobj_type var_type;
if (argc != 3)
{
@@ -105,22 +129,7 @@ mi_cmd_var_create (char *command, char *
else if (!isalpha (*name))
error (_("mi_cmd_var_create: name of object must begin with a letter"));
- if (strcmp (frame, "*") == 0)
- var_type = USE_CURRENT_FRAME;
- else if (strcmp (frame, "@") == 0)
- var_type = USE_SELECTED_FRAME;
- else
- {
- var_type = USE_SPECIFIED_FRAME;
- frameaddr = string_to_core_addr (frame);
- }
-
- if (varobjdebug)
- fprintf_unfiltered (gdb_stdlog,
- "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
- name, frame, paddr (frameaddr), expr);
-
- var = varobj_create (name, expr, frameaddr, var_type);
+ var = create_varobj_in_frame (name, expr, frame);
if (var == NULL)
error (_("mi_cmd_var_create: unable to create variable object"));
@@ -131,6 +140,84 @@ mi_cmd_var_create (char *command, char *
return MI_CMD_DONE;
}
+static void restore_language_mode (void *p)
+{
+ enum language_mode *mode = p;
+ language_mode = *mode;
+}
+
+enum mi_cmd_result
+mi_cmd_var_list (char *command, char **argv, int argc)
+{
+ int regnum, numregs;
+ struct cleanup *cleanup;
+ char *what;
+ char *frame;
+ enum language prev_lang;
+ enum language_mode prev_lang_mode;
+
+ if (argc < 2)
+ error (_("mi_cmd_var_list: Usage: --WHAT FRAME."));
+
+ what = argv[0];
+
+ if (strcmp (what, "--registers") != 0)
+ error (_("mi_cmd_var_list: invalid kind of object requested."));
+
+ frame = xstrdup (argv[1]);
+ cleanup = make_cleanup (xfree, frame);
+
+
+ /* Force C language for registers, to avoid 'public' pseudo-fields
+ that make no sense for registers. */
+ prev_lang = set_language (language_c);
+ make_cleanup (restore_language, &prev_lang);
+ /* Also switch the language mode to manual. Otherwise,
+ when varobj_create calls select_frame, the language
+ will be automatically switched. */
+ prev_lang_mode = language_mode;
+ language_mode = language_mode_manual;
+ make_cleanup (restore_language_mode, &prev_lang_mode);
+
+ /* Note that the test for a valid register must include checking the
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = NUM_REGS + NUM_PSEUDO_REGS;
+
+ make_cleanup_ui_out_list_begin_end (uiout, "result");
+
+ for (regnum = 0; regnum < numregs; regnum++)
+ {
+ if (REGISTER_NAME (regnum) != NULL
+ && *(REGISTER_NAME (regnum)) != '\0')
+ {
+ char *name;
+ char *expression;
+ struct varobj *var;
+ struct cleanup *cleanup_child;
+
+ name = varobj_gen_name ();
+ make_cleanup (xfree, name);
+
+ expression = xstrprintf ("$%s", REGISTER_NAME (regnum));
+ make_cleanup (xfree, expression);
+
+ var = create_varobj_in_frame (name, expression, frame);
+
+ cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ print_varobj (var, PRINT_ALL_VALUES, 1 /* print expression */);
+ do_cleanups (cleanup_child);
+ }
+ }
+
+ do_cleanups (cleanup);
+ return MI_CMD_DONE;
+}
+
+
enum mi_cmd_result
mi_cmd_var_delete (char *command, char **argv, int argc)
{
--- gdb/language.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/language.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -401,6 +401,14 @@ set_language (enum language lang)
return prev_language;
}
+
+void
+restore_language (void *arg)
+{
+ enum language *lang_p = arg;
+
+ set_language (*lang_p);
+}
\f
/* This page contains functions that update the global vars
language, type and range. */
--- gdb/language.h (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/language.h (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -472,4 +472,10 @@ extern void default_print_array_index (s
int format,
enum val_prettyprint pretty);
+/* Cast 'lang' to 'enum language *', dererence it, and
+ set the current language to the value.
+
+ This function is intended to be used as cleanup function. */
+extern void restore_language (void *lang);
+
#endif /* defined (LANGUAGE_H) */
--- gdb/Makefile.in (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/Makefile.in (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -3113,7 +3113,7 @@ mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stac
$(stack_h) $(dictionary_h) $(gdb_string_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
mi-cmd-var.o: $(srcdir)/mi/mi-cmd-var.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
- $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h)
+ $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-var.c
mi-console.o: $(srcdir)/mi/mi-console.c $(defs_h) $(mi_console_h) \
$(gdb_string_h)
Property changes on:
___________________________________________________________________
Name: csl:base
+/all/mirrors/gdb_mainline
Name: svk:merge
+e7755896-6108-0410-9592-8049d3e74e28:/mirrors/gdb/trunk:157978
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [mi] [ada] varobjs for registers 2
2007-01-05 9:01 ` Vladimir Prus
@ 2007-01-05 9:29 ` Eli Zaretskii
0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2007-01-05 9:29 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
> From: Vladimir Prus <ghost@cs.msu.su>
> Date: Fri, 05 Jan 2007 12:00:36 +0300
> >
> > Please add a cross-reference to the description of -var-create here.
>
> Is
>
> Using the @code{-var-create} (@pxref{-var-list-children}) command
>
> the right texinfo way to do a reference?
Yes, one of them.
> Revised patch attached. In addition to the changes you've suggested, I've
> reworded the first paragraph to more explicitly document that -var-list
> tries to return previously-created varobjs, as Nick and I discussed.
>
> OK?
It's okay, but please fix this:
> +if necessary. This command is intended to efficiently obtain a number
^^
Two spaces after the period, please.
> +object. In addition, subsequent @code{-var-list} invocations generally
^^
Ditto.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [mi] [ada] varobjs for registers 2
2006-12-20 18:38 [mi] [ada] varobjs for registers 2 Vladimir Prus
2006-12-20 19:44 ` Eli Zaretskii
@ 2006-12-21 7:20 ` Joel Brobecker
2006-12-30 20:30 ` Daniel Jacobowitz
1 sibling, 1 reply; 9+ messages in thread
From: Joel Brobecker @ 2006-12-21 7:20 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
Volodya, (or should I call you Vladimir?)
> Along the way, I've promoted a private function in ada-lang.c to language.c,
> so I'd appreciate if Ada maintainers take a quick look.
I had a look, and the change looks fine. I also tested it against our
testsuite, and it showed no regression, which should bring us additional
confidence. Please be aware that I am not a maintainer, and thus this
review is only informal, and thus is not an approval.
While scanning the patch, I did notices a couple of minor things:
> @@ -4226,10 +4220,10 @@ lookup_symbol_in_language (const char *n
> domain_enum domain, enum language lang,
> int *is_a_field_of_this, struct symtab **symtab)
> {
> + enum language prev_lang = set_language (lang);
> struct cleanup *old_chain
> - = make_cleanup (restore_language, (void *) current_language->la_language);
> + = make_cleanup (restore_language, &prev_lang);
The two lines can now be joined (ie the make_cleanup call can be joined
with the previous line).
> +static void restore_language_mode (void *p)
> +{
> + enum language_mode *mode = p;
> + language_mode = *mode;
> +}
The formatting is wrong. You need a line break after "static void"
so that "restore_language_mode" is at the begining of the next line.
Also, perhaps this function should be moved to language.c as well?
> +/* Cast 'lang' to 'enum language *', dererence it, and
> + set the current language to the value.
> +
> + This function is intended to be used as cleanup function. */
> +extern void restore_language (void *lang);
I believe the comment describing the function should be placed besides
the function implementation, in language.c. This is the habit we have
at least in the GNU projects I've been involved in. In Ada, we much
prefer to place the documentation besides the declaration, as you did,
but C allows you to put as many declarations of the same entity as you
want, and wherever you want. So this conventions allows us to know
exactly where the documentation is...
--
Joel
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [mi] [ada] varobjs for registers 2
2006-12-21 7:20 ` Joel Brobecker
@ 2006-12-30 20:30 ` Daniel Jacobowitz
2007-01-05 9:06 ` Vladimir Prus
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2006-12-30 20:30 UTC (permalink / raw)
To: Vladimir Prus, Joel Brobecker; +Cc: gdb-patches
On Wed, Dec 20, 2006 at 09:37:28PM +0300, Vladimir Prus wrote:
>
> This is a second revision of the patch to add MI command that
> creates varobjs for registers. The command is renamed to -var-list
> and used like:
>
> -var-list --registers
>
> There are now docs and tests. The created variable objects no longer
> have 'public' pseudo-fields, no matter what the language of the program is.
>
> Along the way, I've promoted a private function in ada-lang.c to language.c,
> so I'd appreciate if Ada maintainers take a quick look.
>
> OK?
Before I look at this, is it the latest version? You and Nick had an
active discussion about this while I was on vacation.
On Thu, Dec 21, 2006 at 11:21:02AM +0400, Joel Brobecker wrote:
> I believe the comment describing the function should be placed besides
> the function implementation, in language.c. This is the habit we have
> at least in the GNU projects I've been involved in. In Ada, we much
> prefer to place the documentation besides the declaration, as you did,
> but C allows you to put as many declarations of the same entity as you
> want, and wherever you want. So this conventions allows us to know
> exactly where the documentation is...
GDB is inconsistent about this, so I don't think it makes much
difference. I've been putting the comments in headers for global
functions and referring to the header from the implementation,
but that's not great either.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [mi] [ada] varobjs for registers 2
2006-12-30 20:30 ` Daniel Jacobowitz
@ 2007-01-05 9:06 ` Vladimir Prus
2007-01-05 10:24 ` Nick Roberts
0 siblings, 1 reply; 9+ messages in thread
From: Vladimir Prus @ 2007-01-05 9:06 UTC (permalink / raw)
To: Daniel Jacobowitz, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1618 bytes --]
Daniel Jacobowitz wrote:
> On Wed, Dec 20, 2006 at 09:37:28PM +0300, Vladimir Prus wrote:
>>
>> This is a second revision of the patch to add MI command that
>> creates varobjs for registers. The command is renamed to -var-list
>> and used like:
>>
>> -var-list --registers
>>
>> There are now docs and tests. The created variable objects no longer
>> have 'public' pseudo-fields, no matter what the language of the program
>> is.
>>
>> Along the way, I've promoted a private function in ada-lang.c to
>> language.c, so I'd appreciate if Ada maintainers take a quick look.
>>
>> OK?
>
> Before I look at this, is it the latest version? You and Nick had an
> active discussion about this while I was on vacation.
I think only manual changes were done, but just in case, the most recent
version I have is attached.
- Volodya
Implement the -var-list command, with initial support
for listing registers.
* mi/mi-cmds.h (mi_cmd_var_list): New.
* mi/mi-cmds.c: Register "var-list".
* mi/mi-cmd-var.c (create_varobj_in_frame): New function.
(mi_cmd_var_create): Use the above.
(restore_language_mode): New.
(mi_cmd_var_list): New.
* language.h (restore_language): Declare.
* language.c (restore_language): New function.
* ada-lang.c (restore_language): Remove.
(lookup_symbol_in_language): Adjust.
* Makefile (mi-cmd-var.o): Update dependencies.
doc/
* gdb.texinfo (GDB/MI Variable Objects): Document
-var-list.
testsuite/
* gdb.mi/mi-var-cmd.exp: Test for -var-list.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: varobj_for_registers__gdb_mainline.diff --]
[-- Type: text/x-diff; name="varobj_for_registers__gdb_mainline.diff", Size: 11339 bytes --]
--- gdb/ada-lang.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/ada-lang.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -4210,13 +4210,7 @@ add_symbols_from_enclosing_procs (struct
{
}
-/* FIXME: The next two routines belong in symtab.c */
-
-static void
-restore_language (void *lang)
-{
- set_language ((enum language) lang);
-}
+/* FIXME: The next routine belongs in symtab.c */
/* As for lookup_symbol, but performed as if the current language
were LANG. */
@@ -4226,10 +4220,10 @@ lookup_symbol_in_language (const char *n
domain_enum domain, enum language lang,
int *is_a_field_of_this, struct symtab **symtab)
{
+ enum language prev_lang = set_language (lang);
struct cleanup *old_chain
- = make_cleanup (restore_language, (void *) current_language->la_language);
+ = make_cleanup (restore_language, &prev_lang);
struct symbol *result;
- set_language (lang);
result = lookup_symbol (name, block, domain, is_a_field_of_this, symtab);
do_cleanups (old_chain);
return result;
--- gdb/doc/gdb.texinfo (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/doc/gdb.texinfo (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -19600,6 +19600,8 @@ access this functionality:
@item @code{-var-create}
@tab create a variable object
+@item @code{-var-list}
+@tab create special kinds of variable objects
@item @code{-var-delete}
@tab delete the variable object and/or its children
@item @code{-var-set-format}
@@ -19678,6 +19680,45 @@ the @value{GDBN} CLI:
@end smallexample
+@subheading The @code{-var-list} Command
+@findex -var-list
+
+@subsubheading Synopsis
+
+@smallexample
+ -var-list --@var{kind} @{@var{frame-addr} | "*"@}
+@end smallexample
+
+Returns all variable objects of the specified kind, creating them
+if necessary. This command is intended to efficiently obtain a number
+of variable objects---for example for registers, or for local variables. Using
+the @code{-var-create} (@pxref{-var-list-children}) command would
+not be ideal, because it must be issued once for every variable
+object. In addition, subsequent @code{-var-list} invocations generally
+try to return variable objects that were created and returned on
+previous invocation, which additionally improves performance.
+
+At the moment the only defined kind is ``registers''.
+
+The @var{frame-addr} parameter the same semantics as for
+@code{-var-create}. For registers, any frame but the current must
+be used with caution, as @value{GDBN} can determine the value in the parent
+frames only for a few registers.
+
+@subsubheading Result
+
+The MI result record includes the @samp{result} field whose value is
+a list of tuples. Each tuple describes a single variable object in
+the same way as for the @code{-var-create} command:
+
+@smallexample
+^done,registers=[
+ {name="var1",exp="$eax",
+ numchild="0",value="16",type="int"},....
+@end smallexample
+
+
+
@subheading The @code{-var-delete} Command
@findex -var-delete
--- gdb/testsuite/gdb.mi/mi-var-cmd.exp (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/testsuite/gdb.mi/mi-var-cmd.exp (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -599,5 +599,9 @@ mi_gdb_test "-var-update selected_a" \
"\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",new_type=\"int\",new_num_children=\"0\"\}\\\]" \
"update selected_a in do_special_tests"
+mi_gdb_test "-var-list --registers *" \
+ "\\^done,result=\\\[{name=\".*\",exp=\".*\",numchild=\".*\",value=\".*\",type=\".*\"},.*" \
+ "create list of registers"
+
mi_gdb_exit
return 0
--- gdb/mi/mi-cmds.h (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/mi/mi-cmds.h (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -105,6 +105,7 @@ extern mi_cmd_argv_ftype mi_cmd_thread_l
extern mi_cmd_argv_ftype mi_cmd_thread_select;
extern mi_cmd_argv_ftype mi_cmd_var_assign;
extern mi_cmd_argv_ftype mi_cmd_var_create;
+extern mi_cmd_argv_ftype mi_cmd_var_list;
extern mi_cmd_argv_ftype mi_cmd_var_delete;
extern mi_cmd_argv_ftype mi_cmd_var_evaluate_expression;
extern mi_cmd_argv_ftype mi_cmd_var_info_expression;
--- gdb/mi/mi-cmds.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/mi/mi-cmds.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -153,6 +153,7 @@ struct mi_cmd mi_cmds[] =
{ "trace-stop", { NULL, 0 }, NULL, NULL },
{ "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign},
{ "var-create", { NULL, 0 }, 0, mi_cmd_var_create},
+ { "var-list", { NULL, 0 }, 0, mi_cmd_var_list},
{ "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete},
{ "var-evaluate-expression", { NULL, 0 }, 0, mi_cmd_var_evaluate_expression},
{ "var-info-expression", { NULL, 0 }, 0, mi_cmd_var_info_expression},
--- gdb/mi/mi-cmd-var.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/mi/mi-cmd-var.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -29,6 +29,7 @@
#include "value.h"
#include <ctype.h>
#include "gdb_string.h"
+#include "language.h"
const char mi_no_values[] = "--no-values";
const char mi_simple_values[] = "--simple-values";
@@ -68,16 +69,39 @@ print_varobj (struct varobj *var, enum p
/* VAROBJ operations */
+static struct varobj *
+create_varobj_in_frame (char *name, char *expression, char *frame)
+{
+ CORE_ADDR frameaddr = 0;
+ struct cleanup *cleanup;
+ enum varobj_type var_type;
+
+ if (strcmp (frame, "*") == 0)
+ var_type = USE_CURRENT_FRAME;
+ else if (strcmp (frame, "@") == 0)
+ var_type = USE_SELECTED_FRAME;
+ else
+ {
+ var_type = USE_SPECIFIED_FRAME;
+ frameaddr = string_to_core_addr (frame);
+ }
+
+ if (varobjdebug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
+ name, frame, paddr (frameaddr), expression);
+
+ return varobj_create (name, expression, frameaddr, var_type);
+}
+
enum mi_cmd_result
mi_cmd_var_create (char *command, char **argv, int argc)
{
- CORE_ADDR frameaddr = 0;
struct varobj *var;
char *name;
char *frame;
char *expr;
struct cleanup *old_cleanups;
- enum varobj_type var_type;
if (argc != 3)
{
@@ -105,22 +129,7 @@ mi_cmd_var_create (char *command, char *
else if (!isalpha (*name))
error (_("mi_cmd_var_create: name of object must begin with a letter"));
- if (strcmp (frame, "*") == 0)
- var_type = USE_CURRENT_FRAME;
- else if (strcmp (frame, "@") == 0)
- var_type = USE_SELECTED_FRAME;
- else
- {
- var_type = USE_SPECIFIED_FRAME;
- frameaddr = string_to_core_addr (frame);
- }
-
- if (varobjdebug)
- fprintf_unfiltered (gdb_stdlog,
- "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n",
- name, frame, paddr (frameaddr), expr);
-
- var = varobj_create (name, expr, frameaddr, var_type);
+ var = create_varobj_in_frame (name, expr, frame);
if (var == NULL)
error (_("mi_cmd_var_create: unable to create variable object"));
@@ -131,6 +140,84 @@ mi_cmd_var_create (char *command, char *
return MI_CMD_DONE;
}
+static void restore_language_mode (void *p)
+{
+ enum language_mode *mode = p;
+ language_mode = *mode;
+}
+
+enum mi_cmd_result
+mi_cmd_var_list (char *command, char **argv, int argc)
+{
+ int regnum, numregs;
+ struct cleanup *cleanup;
+ char *what;
+ char *frame;
+ enum language prev_lang;
+ enum language_mode prev_lang_mode;
+
+ if (argc < 2)
+ error (_("mi_cmd_var_list: Usage: --WHAT FRAME."));
+
+ what = argv[0];
+
+ if (strcmp (what, "--registers") != 0)
+ error (_("mi_cmd_var_list: invalid kind of object requested."));
+
+ frame = xstrdup (argv[1]);
+ cleanup = make_cleanup (xfree, frame);
+
+
+ /* Force C language for registers, to avoid 'public' pseudo-fields
+ that make no sense for registers. */
+ prev_lang = set_language (language_c);
+ make_cleanup (restore_language, &prev_lang);
+ /* Also switch the language mode to manual. Otherwise,
+ when varobj_create calls select_frame, the language
+ will be automatically switched. */
+ prev_lang_mode = language_mode;
+ language_mode = language_mode_manual;
+ make_cleanup (restore_language_mode, &prev_lang_mode);
+
+ /* Note that the test for a valid register must include checking the
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = NUM_REGS + NUM_PSEUDO_REGS;
+
+ make_cleanup_ui_out_list_begin_end (uiout, "result");
+
+ for (regnum = 0; regnum < numregs; regnum++)
+ {
+ if (REGISTER_NAME (regnum) != NULL
+ && *(REGISTER_NAME (regnum)) != '\0')
+ {
+ char *name;
+ char *expression;
+ struct varobj *var;
+ struct cleanup *cleanup_child;
+
+ name = varobj_gen_name ();
+ make_cleanup (xfree, name);
+
+ expression = xstrprintf ("$%s", REGISTER_NAME (regnum));
+ make_cleanup (xfree, expression);
+
+ var = create_varobj_in_frame (name, expression, frame);
+
+ cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ print_varobj (var, PRINT_ALL_VALUES, 1 /* print expression */);
+ do_cleanups (cleanup_child);
+ }
+ }
+
+ do_cleanups (cleanup);
+ return MI_CMD_DONE;
+}
+
+
enum mi_cmd_result
mi_cmd_var_delete (char *command, char **argv, int argc)
{
--- gdb/language.c (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/language.c (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -401,6 +401,14 @@ set_language (enum language lang)
return prev_language;
}
+
+void
+restore_language (void *arg)
+{
+ enum language *lang_p = arg;
+
+ set_language (*lang_p);
+}
\f
/* This page contains functions that update the global vars
language, type and range. */
--- gdb/language.h (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/language.h (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -472,4 +472,10 @@ extern void default_print_array_index (s
int format,
enum val_prettyprint pretty);
+/* Cast 'lang' to 'enum language *', dererence it, and
+ set the current language to the value.
+
+ This function is intended to be used as cleanup function. */
+extern void restore_language (void *lang);
+
#endif /* defined (LANGUAGE_H) */
--- gdb/Makefile.in (/mirrors/gdb_mainline) (revision 3057)
+++ gdb/Makefile.in (/patches/gdb/varobj_for_registers/gdb_mainline) (revision 3057)
@@ -3113,7 +3113,7 @@ mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stac
$(stack_h) $(dictionary_h) $(gdb_string_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
mi-cmd-var.o: $(srcdir)/mi/mi-cmd-var.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
- $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h)
+ $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-var.c
mi-console.o: $(srcdir)/mi/mi-console.c $(defs_h) $(mi_console_h) \
$(gdb_string_h)
Property changes on:
___________________________________________________________________
Name: csl:base
+/all/mirrors/gdb_mainline
Name: svk:merge
+e7755896-6108-0410-9592-8049d3e74e28:/mirrors/gdb/trunk:157978
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [mi] [ada] varobjs for registers 2
2007-01-05 9:06 ` Vladimir Prus
@ 2007-01-05 10:24 ` Nick Roberts
2007-01-05 10:47 ` Vladimir Prus
0 siblings, 1 reply; 9+ messages in thread
From: Nick Roberts @ 2007-01-05 10:24 UTC (permalink / raw)
To: Vladimir Prus; +Cc: Daniel Jacobowitz, gdb-patches
> +@smallexample
> + -var-list --@var{kind} @{@var{frame-addr} | "*"@}
> +@end smallexample
> +
>...
> +
> +At the moment the only defined kind is ``registers''.
Isn't "-var-list --registers" only meaningful with USE_SELECTED_FRAME
i.e "-var-list --registers @"?
Likewise "-var-list --locals" generally would only make seem to make sense
with USE_CURRENT_FRAME i.e "-var-list --locals *".
Also, looking ahead, I wonder what Apple do about deleting variable objects for
locals when the program exits the frame. Perhaps "-var-list --locals" should
delete them.
--
Nick http://www.inet.net.nz/~nickrob
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [mi] [ada] varobjs for registers 2
2007-01-05 10:24 ` Nick Roberts
@ 2007-01-05 10:47 ` Vladimir Prus
0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Prus @ 2007-01-05 10:47 UTC (permalink / raw)
To: Nick Roberts; +Cc: Daniel Jacobowitz, gdb-patches
On Friday 05 January 2007 13:24, Nick Roberts wrote:
> > +@smallexample
> > + -var-list --@var{kind} @{@var{frame-addr} | "*"@}
> > +@end smallexample
> > +
> >...
> > +
> > +At the moment the only defined kind is ``registers''.
>
> Isn't "-var-list --registers" only meaningful with USE_SELECTED_FRAME
> i.e "-var-list --registers @"?
It can be also meanigful with specific frame number.
> Likewise "-var-list --locals" generally would only make seem to make sense
> with USE_CURRENT_FRAME i.e "-var-list --locals *".
For --local, I expect it to be meaningful only with specific frame number. Anyway, such
meaningfullness specific to each kind can be documented separately. I'm not sure
the general syntax need those details.
> Also, looking ahead, I wonder what Apple do about deleting variable objects for
> locals when the program exits the frame. Perhaps "-var-list --locals" should
> delete them.
Oh, I guess I really should post my ideas about this. In on my todo for today.
- Volodya
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-01-05 10:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-20 18:38 [mi] [ada] varobjs for registers 2 Vladimir Prus
2006-12-20 19:44 ` Eli Zaretskii
2007-01-05 9:01 ` Vladimir Prus
2007-01-05 9:29 ` Eli Zaretskii
2006-12-21 7:20 ` Joel Brobecker
2006-12-30 20:30 ` Daniel Jacobowitz
2007-01-05 9:06 ` Vladimir Prus
2007-01-05 10:24 ` Nick Roberts
2007-01-05 10:47 ` Vladimir Prus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox