You should open library project, set host application in startup parameters and then run library project with debugging (F9).
It also works (or should work) when you open the main project in the IDE, and it loads the library.
A few more questions:
Both main project and library are fpc projects?
Both have dwarf debug info enabled?
You did not use any special settings for the linker? (static vs dynamic / stripping / ...)
You did not strip any of the exe/so ?
You did not strip any of the dll in /usr/lib... ? (really unlikely)
The reason I am asking...
In order for breakpoint in libraries to work, the debugger must be aware when a lib is loaded. For that there is a "trigger" in one of the system libs.
If FpDebug fails to get that trigger, then breakpoints in libs wont work. (I don't know what the code in gdb is nowadays doing, but google suggests that it at least at some point used the same method, and maybe still does)
Lets do some checks please.
1) I don't know the exact name of your systems shared libs. But they should be something like the examples.
They may just be in /usr/lib or some other lib folder
find the ld lib:
find /usr/ -name 'ld*.so*'
get some info about it (
you need to change the name according to what you found above):
objdump -t /usr/lib64/ld-linux-x86-64.so.2 | grep -i _debug; objdump -T /usr/lib64/ld-linux-x86-64.so.2 | grep -i _debug
copy and paste the result here, please.
2)
Can you apply the patch below please.
Then recompile the IDE (Tools > Build Lazarus).
Open a terminal/console/shell, and run lazarus from that terminal (so you can see what it prints to stdout)
Run your project
Copy and paste anything that Lazarus printed.
Mind the below has a tiny functional change too. With some extreme amount of luck it may even fix the issue. (Though I really doubt it, because then gdb should not have the issue too)
diff --git a/components/fpdebug/fpdbglinuxclasses.pas b/components/fpdebug/fpdbglinuxclasses.pas
index e72c919e7d..5601c9a9cc 100644
--- a/components/fpdebug/fpdbglinuxclasses.pas
+++ b/components/fpdebug/fpdbglinuxclasses.pas
@@ -1564,7 +1564,7 @@ var
begin
inherited LoadInfo;
-
+writeln('####################################################################');
// This would be strange, but you never know.
if Assigned(FSOLibEventBreakpoint) then
Raise Exception.Create('SOLib event-breakpoint already exists.');
@@ -1576,6 +1576,7 @@ begin
InterpSection := LoaderList.Items[i].Section['.interp'];
if assigned(InterpSection) then
begin
+writeln( LoaderList.Items[i].FileName );
// Try to retrieve the inode of the file (library) in the .interp section.
// This is the filename of the library that handles the dynamic loading.
if FpStat(PChar(InterpSection^.RawData), AStat) = 0 then
@@ -1585,10 +1586,16 @@ begin
SynchronizeProcMapsWithLibraryList();
if FLibMap.GetLib(Astat.st_ino, ALib) then
begin
+ writeln('in library : ', ALib.Name );
+
// Set a breakpoint at _dl_debug_state. This procedure is called after
// one or more libraries have been loaded. This breakpoint is used to
// detect the (un)loading of libraries.
FSOLibEventBreakpoint := AddBreak('_dl_debug_state', False, ALib);
+writeln(FSOLibEventBreakpoint<> nil);
+if FSOLibEventBreakpoint<>nil then writeln(' state ', ord(FSOLibEventBreakpoint.State));
+if FSOLibEventBreakpoint.State <> bksOk then FSOLibEventBreakpoint.Free
+else
TFpDbgBreakpoint(FSOLibEventBreakpoint).FreeByDbgProcess := True;
end
end;