Forum > Debugger
Problem with "Attach to program..."
korba812:
I am trying to debug shared library running with an external, non-Pascal program using "Attach to program...". I can attach to program however I cannot use the "Step..." (key F7, F8, etc.), tool button and menu items "Run", "Step..." remain inactive, however, I can resume the program with the F9 key and breakpoints works. The GDB backend and FpDebug behave the same way. I'm using lazarus/main and am wondering if this is a problem with my configuration or just a bug?
Martin_fr:
Need a bit more detail...
When you do "attach" and choose the program. Then the program would still be running => so the pause button should be active, but not the run or step buttons.
Though it may be dependent on Lazarus version, maybe the app is paused. In that case run it, and later pause it.
Then when you hit pause => you should be getting the asm view, and should be able to single step asm instructions.
Now if your main app has debug info (in a version readable to the debugger) then you should be able to set breakpoints, and once you reach a breakpoint you should be able to single step.
What I don't know... You have the debug info in a library. And there may be a problem (may or may not be / I am not sure). Because on attach the debugger (at least fpdebug, I don't know the internals of gdb) reads debug info of the main app. But I am not sure if it reads debug info of the library.
At least fpdebug usually reads debug info for libraries when the lib is loaded. But when attaching that may have happened when the debugger was not looking...
So the real question here is, when you pause the app => and you have files for the library open in the IDE editor => do they show little blue dots in the gutter? If not then debug info wasn't loaded, or the filename is not detected correctly.
You can try to set the external app as launch application in "run" > "Run Parameters" => and then it runs in the debugger, and the debugger should see when the lib is loaded.
korba812:
After attaching, program stops, blue dots appear on the gutter but menu items and buttons remain inactive. After setting a breakpoint and resuming the program with the F9 key, debugger stops at the breakpoint, I can preview contents of variables in the hint window (although the "Evaluate/modify" window is unavailable) but still the buttons and menu items are inactive and "Step..." (F7/F8) does not work.
But running through external applications from "Run parameters" works fine!
Martin_fr:
ok, in this case the step buttons should become active.
I will have to see if I can reproduce this somehow...
I noted in your image, the run button looks different (looks like the symbol for "run without debug". Maybe something to do with that. (I have to figure out how to set it to that mode).
Another thing (even I could not get it to fail): How did you start the exe to which you attach?
Did you start it with "Run without debug" from the IDE?
As, I said, it did not fail in my tests right now, but that could IIRC cause issues. Because the IDE is watching for the process to terminate (even without debugger), and when you attach it, the IDE monitors the same process twice => and the the debugger (at least FpDebug) can be hindered by that.
korba812:
Program I attach to is run outside of Lazarus - it is cscript.exe - windows script host run from the command line. Shared library contains COM objects and type library, if that matters.
edit
I attach a sample library and wsh script for testing.
Navigation
[0] Message Index
[#] Next page