2

Can't we traverse the array of structs ? I mean for each index by checking the content of structs and print each field accordingly? As we can do for a struct like

s = gdb.parse_and_eval(expr)
for k in s.type.keys():
    v = s[k]
    if is_pointer(v):
          .....
    elif is_array(v):
          .....

How to get access control on elements at each indices of an array?

1 Answer 1

4

You can index an array using the [] notation. Like, if 'v' is a gdb.Value representing an array or a pointer, you can fetch the 5th element with v[5].

The manual has a long section on the Value API that explains all of this.

Sign up to request clarification or add additional context in comments.

8 Comments

One more doubt i have, while doing gdb.execute('thread apply all bt') at particular thread it is showing Cannot access memory at address 0x5effffe500 and getting quit from gdb prompt. if i use try: gdb.execute('thread apply all bt') except gdb.error: gdb.write(',\n') then it is not quiting from gdb prompt but it is skipping all further threads. I want to go in each thread and print bt for all threads one by one. Is there any solotion to this or any other way to get this..? Kindly guide..
Iterate over the threads in Python instead. You can also compute stack traces from Python.
Thanks tromey:-) now i am able to iterate over all threads and printing backtrace of each thread but when exception occurs, i want to print the exact gdb error message like Cannot access memory at address 0x5effffe500 with right address in my exception handler. So how to get gdb error message?
Where is this mythical manual? The only one I can find (at sourceware.org/gdb/onlinedocs/gdb/…) doesn't say anything about arrays.
Yeah, funny, I see that the array syntax isn't documented. That's a bug in the gdb manual.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.