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

how to specify the path to source code of shared labrary ? #375

Open
daif-abde opened this issue Sep 21, 2022 · 6 comments
Open

how to specify the path to source code of shared labrary ? #375

daif-abde opened this issue Sep 21, 2022 · 6 comments
Labels
more info needed Waiting for author to provide more information

Comments

@daif-abde
Copy link

Hi,

is there a way to specify the path to the source code of a library (.so) file ?

I would like to put breakpoints in my library, and see how it runs, the source code is in a different directory than the executable with which I run gdb.

If it's possible would you please show an example.

Thank you!

@GitMensch
Copy link
Collaborator

... have you checked how this works in GDB? Using my favorite search machine the third entry is https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html which explains "it doesn't matter as long as you have the cwd within gdb set identical to the cwd during compile time or compile with full paths" and also mentions the directory and subtitute-path settings.

For this extension it would be the settings cwd, pathSubstitutions and autorun [in the later you may specify gdb commands directly, in this case directory].

... and of course the shared library has the have been compiled and linked with debug info (-g), otherwise disassemble is the only option.

@daif-abde
Copy link
Author

Thank you !!
Yes I have compiled using -g.
This is my current configuration :

~/test/test.c mylib.so test
~/dev/mylib/mylib.c ...

and I run gdb with test.o that calls mylib.so
so in lauch.json I have the following config:

target: "./test"
cwd: "${workspaceRoot}"

with just gdb I can make a break point in mylib.c with : b funtion_name
but how to specify in my lauch.json the code source path (i.e ~/dev/lib/mylib.c) ? is there any option to do this ?

thank you!

@GitMensch
Copy link
Collaborator

You give the "main source code path" via cwd (as you did not specify where this is I don't know - but you can also specify "cwd":"~/dev/mylib" ).

For specifying multiple directories:

				"autorun": [
						"directory ~/dev/mylib",
						"directory ~/test"
				],

@daif-abde
Copy link
Author

Thank you !! it works :)

@GitMensch
Copy link
Collaborator

@WebFreak001 @brownts: Do you think an array setting additionalSourceDirectories would be useful? If not should we add a hint on autorun->directory to the README or see it as "common GDB setting"?
Depending on your answer we should either close the ticket directly or after the appropriate changes.

@brownts
Copy link
Collaborator

brownts commented Sep 22, 2022

Is this a case where full source paths are not being used during the compilation of the shared library? I would think this should work as-is without needing additional paths specified unless full paths are not being used. Additionally, it might be necessary to allow pending breakpoints so that the breakpoint is set in the shared library once it is loaded. I'm not sure I fully understand the cause of this issue.

@brownts brownts added the more info needed Waiting for author to provide more information label Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed Waiting for author to provide more information
Projects
None yet
Development

No branches or pull requests

3 participants