* printing "variable-sized" registers
@ 2005-05-30 15:10 Vladimir Prus
2005-05-30 16:58 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Vladimir Prus @ 2005-05-30 15:10 UTC (permalink / raw)
To: gdb
Hello,
I'm working on a gdb port, and have problems with printing certain registers
of my target. The problem is that those registers are vector buffers that
can hold from 0 to 32 values at any given moment. I would like the 'info
registers' command to print exactly the number of values that are present
in a buffer. That is, on one invocation I might get 4 values printed, and
on another 15, depending on the current processor state.
However, I don't see an easy way to do this. The
'default_print_registers_info' function uses 'val_print' to print the
value, and 'val_print' uses register type (struct type*), which has a fixed
size. Anything I can do? Or I should just write arch-specific
'print_registers_info' function?
Thanks in advance,
Volodya
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: printing "variable-sized" registers
2005-05-30 15:10 printing "variable-sized" registers Vladimir Prus
@ 2005-05-30 16:58 ` Daniel Jacobowitz
2005-06-06 13:52 ` Vladimir Prus
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2005-05-30 16:58 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb
On Mon, May 30, 2005 at 06:22:19PM +0400, Vladimir Prus wrote:
>
> Hello,
> I'm working on a gdb port, and have problems with printing certain registers
> of my target. The problem is that those registers are vector buffers that
> can hold from 0 to 32 values at any given moment. I would like the 'info
> registers' command to print exactly the number of values that are present
> in a buffer. That is, on one invocation I might get 4 values printed, and
> on another 15, depending on the current processor state.
>
> However, I don't see an easy way to do this. The
> 'default_print_registers_info' function uses 'val_print' to print the
> value, and 'val_print' uses register type (struct type*), which has a fixed
> size. Anything I can do? Or I should just write arch-specific
> 'print_registers_info' function?
The last one. The best you can do the rest of the time is going to be
giving them a type containing the maximum number of values and fill in
with dummies - maybe also including the count?
If you want "print $reg" to display them nicely, you're going to need
to teach GDB's type system about it somehow. I have no idea what that
change would look like or how it would work, but it could be generally
useful - it's the same concept as prettyprinting a tagged union, I think.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: printing "variable-sized" registers
2005-05-30 16:58 ` Daniel Jacobowitz
@ 2005-06-06 13:52 ` Vladimir Prus
2005-06-06 13:56 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Vladimir Prus @ 2005-06-06 13:52 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb
[-- Attachment #1: Type: text/plain, Size: 1714 bytes --]
On Monday 30 May 2005 20:58, Daniel Jacobowitz wrote:
> On Mon, May 30, 2005 at 06:22:19PM +0400, Vladimir Prus wrote:
> > Hello,
> > I'm working on a gdb port, and have problems with printing certain
> > registers of my target. The problem is that those registers are vector
> > buffers that can hold from 0 to 32 values at any given moment. I would
> > like the 'info registers' command to print exactly the number of values
> > that are present in a buffer. That is, on one invocation I might get 4
> > values printed, and on another 15, depending on the current processor
> > state.
> >
> > However, I don't see an easy way to do this. The
> > 'default_print_registers_info' function uses 'val_print' to print the
> > value, and 'val_print' uses register type (struct type*), which has a
> > fixed size. Anything I can do? Or I should just write arch-specific
> > 'print_registers_info' function?
>
> The last one. The best you can do the rest of the time is going to be
> giving them a type containing the maximum number of values and fill in
> with dummies - maybe also including the count?
This's what I was doing -- assigning "array of 32 uin64s" type to those
registers and they are printed with "info all-registers", but the dummy
values do no look nice when presented to the user.
> If you want "print $reg" to display them nicely, you're going to need
> to teach GDB's type system about it somehow. I have no idea what that
> change would look like or how it would work, but it could be generally
> useful - it's the same concept as prettyprinting a tagged union, I think.
Ok, understood. With the attached patch I get what I want, but I have no idea
if this patch is good or not.
- Volodya
[-- Attachment #2: variable_sized_array.diff --]
[-- Type: text/x-diff, Size: 1154 bytes --]
diff -u gdb-6.3-orig/gdb/gdbtypes.h gdb-6.3/gdb/gdbtypes.h
--- gdb-6.3-orig/gdb/gdbtypes.h 2004-10-01 14:23:09.000000000 +0400
+++ gdb-6.3/gdb/gdbtypes.h 2005-05-31 10:19:42.000000000 +0400
@@ -304,6 +304,12 @@
#define TYPE_FLAG_FIXED_INSTANCE (1 << 15)
+
+#define TYPE_FLAG_VARIABLE_SIZED_ARRAY (1 << 16)
+#define TYPE_VARIABLE_SIZED_ARRAY(t) (TYPE_INSTANCE_FLAGS(t) \
+ & TYPE_FLAG_VARIABLE_SIZED_ARRAY)
+
+
/* Array bound type. */
enum array_bound_type
{
diff -u gdb-6.3-orig/gdb/valprint.c gdb-6.3/gdb/valprint.c
--- gdb-6.3-orig/gdb/valprint.c 2004-09-12 20:13:04.000000000 +0400
+++ gdb-6.3/gdb/valprint.c 2005-05-31 11:23:09.000000000 +0400
@@ -774,10 +774,15 @@
elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype));
- len = TYPE_LENGTH (type) / eltlen;
annotate_array_section_begin (i, elttype);
+ if (TYPE_VARIABLE_SIZED_ARRAY(type)) {
+ len = *(unsigned int*)valaddr;
+ valaddr += sizeof(unsigned int);
+ } else
+ len = TYPE_LENGTH (type) / eltlen;
+
for (; i < len && things_printed < print_max; i++)
{
if (i != 0)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: printing "variable-sized" registers
2005-06-06 13:52 ` Vladimir Prus
@ 2005-06-06 13:56 ` Daniel Jacobowitz
2005-06-06 14:05 ` Vladimir Prus
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2005-06-06 13:56 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb
On Mon, Jun 06, 2005 at 05:52:07PM +0400, Vladimir Prus wrote:
> > The last one. The best you can do the rest of the time is going to be
> > giving them a type containing the maximum number of values and fill in
> > with dummies - maybe also including the count?
>
> This's what I was doing -- assigning "array of 32 uin64s" type to those
> registers and they are printed with "info all-registers", but the dummy
> values do no look nice when presented to the user.
Right. You can correct how they're printed in info registers and info
all-registers by providing your own print_registers_info.
> > If you want "print $reg" to display them nicely, you're going to need
> > to teach GDB's type system about it somehow. I have no idea what that
> > change would look like or how it would work, but it could be generally
> > useful - it's the same concept as prettyprinting a tagged union, I think.
>
> Ok, understood. With the attached patch I get what I want, but I have no idea
> if this patch is good or not.
No, I don't think this is an acceptable way to do it - too inelegant.
I don't know.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: printing "variable-sized" registers
2005-06-06 13:56 ` Daniel Jacobowitz
@ 2005-06-06 14:05 ` Vladimir Prus
0 siblings, 0 replies; 5+ messages in thread
From: Vladimir Prus @ 2005-06-06 14:05 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb
On Monday 06 June 2005 17:56, Daniel Jacobowitz wrote:
> On Mon, Jun 06, 2005 at 05:52:07PM +0400, Vladimir Prus wrote:
> > > The last one. The best you can do the rest of the time is going to be
> > > giving them a type containing the maximum number of values and fill in
> > > with dummies - maybe also including the count?
> >
> > This's what I was doing -- assigning "array of 32 uin64s" type to those
> > registers and they are printed with "info all-registers", but the dummy
> > values do no look nice when presented to the user.
>
> Right. You can correct how they're printed in info registers and info
> all-registers by providing your own print_registers_info.
But that won't help with the "print" command.
> > > If you want "print $reg" to display them nicely, you're going to need
> > > to teach GDB's type system about it somehow. I have no idea what that
> > > change would look like or how it would work, but it could be generally
> > > useful - it's the same concept as prettyprinting a tagged union, I
> > > think.
> >
> > Ok, understood. With the attached patch I get what I want, but I have no
> > idea if this patch is good or not.
>
> No, I don't think this is an acceptable way to do it - too inelegant.
> I don't know.
Well, to teach gdb type system that array can have variable size, we need to
pass the size as the part of value. I'm not happy with hardcoded 'unsigned
int', but making size type configuration would be a much larger change.
Anyway, since this is rather special case, I can live with local patches.
- Volodya
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-06 14:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-30 15:10 printing "variable-sized" registers Vladimir Prus
2005-05-30 16:58 ` Daniel Jacobowitz
2005-06-06 13:52 ` Vladimir Prus
2005-06-06 13:56 ` Daniel Jacobowitz
2005-06-06 14:05 ` Vladimir Prus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox