Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing ImageAndSymbols to load several binaries #321

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FlorentVSTM
Copy link

Currently, the "imageAndSymbols" option can be used to load one additional file. To load multiple files you can manually load them via the "initCommands" option.
This PR enhances the ImageAndSymbols property to manage this use case.
It is linked to the PR: eclipse-cdt-cloud/cdt-gdb-vscode#117

@FlorentVSTM FlorentVSTM force-pushed the feat/refactoring-imageAndSymbols branch from 7809dcf to 6de25ed Compare December 11, 2023 08:48
Copy link
Contributor

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - needs to pass builds and then I can publish it and do the same thing for the corresponding vscode part.

Any thoughts on how to test this one?

@jonahgraham
Copy link
Contributor

jonahgraham commented Dec 13, 2023

I haven't been able to come up with a way to test the proper automation of this within our existing test suite in a reasonable way.

Closest I have come is a bunch of extra steps to take a program like this (example.c compiled to example):

#include <stdio.h>

char data[1000]; 

int main(int argc, char *argv[])
{
    puts(data);
    return 0;
}

and then load an srec into the data (srec created from a text file like this: objcopy -I binary -O srec data.txt data.srec). The problem is what the addresses should be, the addresses need to be calculated by gdb (and assume address randomization is off). To give an idea of how, something like this perhaps:

(gdb) # print out the data address
(gdb) p &data # print out the data address
$1 = (char (*)[1000]) 0x555555558040 <data>
(gdb) # print out the PC so we can reset it after the load
(gdb) p $pc
$1 = (void (*)()) 0x7ffff7fe3290 <_start>
(gdb) load data.srec 0x555555558040
Loading section .sec1, size 0x5c lma 0x555555558040
Start address 0x0000000000000000, load size 92
Transfer rate: 736 bits in <1 sec, 92 bytes/write.
(gdb) # reset the PC because the load messed it up
(gdb)  set $pc = 0x7ffff7fe3290
(gdb) # continue and observe that data has the correct value (e.g. read memory, or see the output in the terminal)

For the above, the server side command was:

$ gdbserver --once :1234 example

and gdb was started like this:

gdb -ex 'target remote :1234' example

So we could launch gdb once, print the values of $pc and &data, then construct a new launch configuration with those values to test it out. But for now that seems like too much effort for the value it brings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants