[Lazarus] Can Lazarus IDE debugger attach to already running process?

Martin lazarus at mfriebe.de
Fri Sep 27 22:12:08 CEST 2013


On 27/09/2013 20:46, Graeme Geldenhuys wrote:
> On 27/09/13 19:33, Martin wrote:
>> Can you send me a log for this?  You use debug info in the exe, not
>> external?
> Yes, debug and line info information is enabled and debug information is
> inside the executable (not external).
>
> See attached screenshot and archive containing the GDB debug output. I
> tried to see the values of 4 variables before I terminated the CGI app.

Very strange. Some values are clearly there. Open the "Locals" window.

^done,stack-args=[frame={level="0",args=[{name="AREQUEST",value="0x1af38d8"},{name="ARESPONSE",value="0x1a8f0e8"},{name="AHANDLED",value="true"},
^done,locals=[{name="AREQUEST",value="0x1af38d8"},{name="ARESPONSE",value="0x1a8f0e8"},{name="SESSIONOID",value="0x0"},{name="LURL",value="0x0"}]

Of course from the log, I can not tell, if they are correct. And they 
are not in the same quality as watches.
Yet GDB refuses to give the "ptype" info.

1) Is that with Dwarf, or Stabs? Did you try changing?

2) In gdbmidebugger

line 5090
function TGDBMIDebuggerCommandAttach.DoExecute: Boolean;

line 5123
   // Attach
   if not ExecuteCommand('attach %s', [FProcessID], R) then
...
line 5145
   // Get PID
   NewPID := 0;

Insert after this
   ExecuteCommand('-gdb-set language pascal', [cfCheckError]);

This is currently done before attach. I dont think it makes a 
difference, but I also do not think gdb cares much what I think.

And if it is, it would explain. The values by GDB, are all uppercase. 
The value for the hint is not. If gdb thinks it should be case sensitive....

3)
Try (in the watch window) to display a value, using all uppercase.

Important, the value must not have been tried before. the iDE uses a 
cache (cleared on every step (F8))

4)
If all else fails, a crude (maybe) workaround
Compile with  DBG_WITH_GDB_WATCHES defined

Then in the watches window, you can enter
>p SessionOid

or
>x foo

in general > gdb command (but do not issue a "run, or step, that will 
loose the debug session)

Again, this means basic gdb display, none of the IDE corrections to the 
display.







More information about the Lazarus mailing list