3

We know, in C language, if there is an array

int data[100];

then ,in gdb, we can print data[4] to data[14] by typing:

print *(data+4)@11

so, the question is: when we program in Pascal language, we may have an array:

var
   data: array[0..100] of Integer;

when we debug it in gdb, how can we print the value from data[4] to data[14]?

Thank you very much.

4
  • I never tried, but what makes you think that would be different? I guess you should be able to use the same syntax. What have you tried? Commented Jan 3, 2018 at 8:38
  • @RudyVelthuis @data[4]^@11 but failed. I had struggled for hours. Commented Jan 3, 2018 at 9:14
  • But that is a different syntax. What happens if you use the original *(data+4)@11? Commented Jan 3, 2018 at 12:08
  • @RudyVelthuis A parse error in expression, near '(data+4)@11' Commented Jan 3, 2018 at 12:13

1 Answer 1

1

There is no way to do this when gdb's language is set to Pascal -- nobody ever implemented this extension in the Pascal expression parser.

One workaround is to print the address of the array, then temporarily switch the language to C and print *(type *)addr @ ....

Another workaround would be to write a new gdb command (either using the CLI or using Python) that does what you like. Or, if you are doing a lot of Pascal debugging, you could implement this extension in gdb -- it isn't hard.

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

Comments

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.