* Reading a static variable in Python
@ 2010-03-10 3:38 Chris Johns
2010-03-10 17:05 ` Tom Tromey
0 siblings, 1 reply; 7+ messages in thread
From: Chris Johns @ 2010-03-10 3:38 UTC (permalink / raw)
To: gdb
Hello,
I am adding pretty printers for RTEMS to gdb. In the RTEMS operating
system elements such as a semaphore are given an id. I would like to
print the actual semaphore data given a semaphore id. To do this I need
to read a kernel structure from a table indexed via a bit field in the
id. As an example the semaphore's table is declared in RTEMS as:
RTEMS_SEM_EXTERN Objects_Information _Semaphore_Information;
How would I read the 10 element of the _Semaphore_Information in Python ?
I am stuck on how to create a new gdb.Value variable in Python.
Thanks
Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading a static variable in Python
2010-03-10 3:38 Reading a static variable in Python Chris Johns
@ 2010-03-10 17:05 ` Tom Tromey
2010-03-11 1:49 ` Chris Johns
0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2010-03-10 17:05 UTC (permalink / raw)
To: Chris Johns; +Cc: gdb
>>>>> "Chris" == Chris Johns <chris@contemporary.net.au> writes:
Chris> I am adding pretty printers for RTEMS to gdb. In the RTEMS operating
Chris> system elements such as a semaphore are given an id. I would like to
Chris> print the actual semaphore data given a semaphore id. To do this I
Chris> need to read a kernel structure from a table indexed via a bit field
Chris> in the id. As an example the semaphore's table is declared in RTEMS
Chris> as:
Chris> RTEMS_SEM_EXTERN Objects_Information _Semaphore_Information;
This isn't really enough information for us to help you.
What does Objects_Information look like?
Chris> I am stuck on how to create a new gdb.Value variable in Python.
Use gdb.parse_and_eval. This wasn't added until after 7.0.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading a static variable in Python
2010-03-10 17:05 ` Tom Tromey
@ 2010-03-11 1:49 ` Chris Johns
2010-03-11 16:53 ` Tom Tromey
0 siblings, 1 reply; 7+ messages in thread
From: Chris Johns @ 2010-03-11 1:49 UTC (permalink / raw)
To: tromey; +Cc: gdb
On 11/03/2010 4:05 AM, Tom Tromey wrote:
>>>>>> "Chris" == Chris Johns<chris@contemporary.net.au> writes:
>
> Chris> I am adding pretty printers for RTEMS to gdb. In the RTEMS operating
> Chris> system elements such as a semaphore are given an id. I would like to
> Chris> print the actual semaphore data given a semaphore id. To do this I
> Chris> need to read a kernel structure from a table indexed via a bit field
> Chris> in the id. As an example the semaphore's table is declared in RTEMS
> Chris> as:
>
> Chris> RTEMS_SEM_EXTERN Objects_Information _Semaphore_Information;
>
> This isn't really enough information for us to help you.
> What does Objects_Information look like?
>
Yes sorry about that. It is a C struct [1].
> Chris> I am stuck on how to create a new gdb.Value variable in Python.
>
> Use gdb.parse_and_eval.
Nice. This is an excellent solution. I suppose being an expression it
can do the pointer maths as well. I was looking at ways to construct a
gdb.Value with a gdb.Symbol as an argument.
> This wasn't added until after 7.0.
I am using a 7.1 snapshot as it has the 'source' command to load a
Python file. This is also an excellent addition.
Chris
[1]
http://www.rtems.org/onlinedocs/doxygen/cpukit/html/structObjects__Information.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading a static variable in Python
2010-03-11 1:49 ` Chris Johns
@ 2010-03-11 16:53 ` Tom Tromey
2010-03-11 17:15 ` Phil Muldoon
2010-03-11 23:40 ` Chris Johns
0 siblings, 2 replies; 7+ messages in thread
From: Tom Tromey @ 2010-03-11 16:53 UTC (permalink / raw)
To: Chris Johns; +Cc: gdb
>>>>> "Chris" == Chris Johns <chris@contemporary.net.au> writes:
Tom> Use gdb.parse_and_eval.
Chris> Nice. This is an excellent solution. I suppose being an expression it
Chris> can do the pointer maths as well. I was looking at ways to construct a
Chris> gdb.Value with a gdb.Symbol as an argument.
Yes, strangely there doesn't seem to be a way to do that.
If you want this, feel free to file a bug report for it...
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading a static variable in Python
2010-03-11 16:53 ` Tom Tromey
@ 2010-03-11 17:15 ` Phil Muldoon
2010-03-11 17:58 ` Tom Tromey
2010-03-11 23:40 ` Chris Johns
1 sibling, 1 reply; 7+ messages in thread
From: Phil Muldoon @ 2010-03-11 17:15 UTC (permalink / raw)
To: Tom Tromey; +Cc: Chris Johns, gdb
On 03/11/2010 04:53 PM, Tom Tromey wrote:
>>>>>> "Chris" == Chris Johns <chris@contemporary.net.au> writes:
>
> Tom> Use gdb.parse_and_eval.
>
> Chris> Nice. This is an excellent solution. I suppose being an expression it
> Chris> can do the pointer maths as well. I was looking at ways to construct a
> Chris> gdb.Value with a gdb.Symbol as an argument.
>
> Yes, strangely there doesn't seem to be a way to do that.
> If you want this, feel free to file a bug report for it...
Frame's read_var function creates a gdb.Value from a given gdb.Symbol,
but obviously one needs the frame and the symbol for that. There was
a stub in the gdb.Symbol code to do this without a frame, but it was
very limited so I removed it. Frame's function read_var uses
read_var_value which needs a frame (well, for some reads -
symbol_read_needs_frame returns a mixed bag of results). Not sure if
it is possible to construct a value from a symbol without the frame in
all cases?
Cheers,
Phil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading a static variable in Python
2010-03-11 17:15 ` Phil Muldoon
@ 2010-03-11 17:58 ` Tom Tromey
0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2010-03-11 17:58 UTC (permalink / raw)
To: Phil Muldoon; +Cc: Chris Johns, gdb
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
Phil> Not sure if it is possible to construct a value from a symbol
Phil> without the frame in all cases?
Not in all cases, but we could throw an exception if a frame is required.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Reading a static variable in Python
2010-03-11 16:53 ` Tom Tromey
2010-03-11 17:15 ` Phil Muldoon
@ 2010-03-11 23:40 ` Chris Johns
1 sibling, 0 replies; 7+ messages in thread
From: Chris Johns @ 2010-03-11 23:40 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb
On 3/12/2010 3:53 AM, Tom Tromey wrote:
>>>>>> "Chris" == Chris Johns<chris@contemporary.net.au> writes:
>
> Tom> Use gdb.parse_and_eval.
>
> Chris> Nice. This is an excellent solution. I suppose being an expression it
> Chris> can do the pointer maths as well. I was looking at ways to construct a
> Chris> gdb.Value with a gdb.Symbol as an argument.
>
> Yes, strangely there doesn't seem to be a way to do that.
> If you want this, feel free to file a bug report for it...
>
I am happy with the gdb.parse_and_eval solution. If a need arises I will
create a bug report.
Thanks
Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-03-11 23:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-10 3:38 Reading a static variable in Python Chris Johns
2010-03-10 17:05 ` Tom Tromey
2010-03-11 1:49 ` Chris Johns
2010-03-11 16:53 ` Tom Tromey
2010-03-11 17:15 ` Phil Muldoon
2010-03-11 17:58 ` Tom Tromey
2010-03-11 23:40 ` Chris Johns
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox