View Issue Details

IDProjectCategoryView StatusLast Update
0025277LazarusDebuggerpublic2013-11-03 23:03
ReporteraccSoneAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformdarwin x86_64OSOSXOS Version10.6.8
Product Version1.3 (SVN)Product Build 
Target VersionFixed in Version1.2.0 
Summary0025277: Debugger hangs on startup if host is not a a fpc program
DescriptionProblem: To debug a library one have to assign a host program in Run parameters Host application. If this program is not compiled with lazarus/fpc the debugger hangs on startup

Analysis: In GDBMIDebugger.pp , TGDBMIDebuggerCommandStartDebugging.DoExecute has no timeout set. During initialization the calls

FTheDebugger.FExceptionBreak.SetByAddr(Self);
FTheDebugger.FBreakErrorBreak.SetByAddr(Self);
FTheDebugger.FRunErrorBreak.SetByAddr(Self);

will hang because they are executed in the command context of the TGDBMIDebuggerCommandStartDebugging command that has DefaultTimeOut not set.

Solution: Setting DefaultTimeOut := DebuggerProperties.TimeoutForEval; before calling the functions above solves the problem and host application will be launched.
Steps To ReproduceRun parameters -> Choose host that is not a fpc compiled program.
Start debugger -> hang
Additional InformationDebug Output:

(gdb)
<info address FPC_RAISEEXCEPTION>
&"info address FPC_RAISEEXCEPTION\n"


01.11.13 18:24:48 [0x0-0x7f07f].lazarus.freepascal.ide[10068] >> TCmdLineDebugger.SendCmdLn "info address FPC_RAISEEXCEPTION"
01.11.13 18:24:48 [0x0-0x7f07f].lazarus.freepascal.ide[10068] << TCmdLineDebugger.ReadLn "&"info address FPC_RAISEEXCEPTION\n""

TagsNo tags attached.
Fixed in Revision43362
LazTarget1.2
WidgetsetCarbon
Attached Files
  • fix_0025277.diff (966 bytes)
    Index: /Developer/lazarus_trunc/debugger/gdbmidebugger.pp
    ===================================================================
    --- /Developer/lazarus_trunc/debugger/gdbmidebugger.pp	(revision 43338)
    +++ /Developer/lazarus_trunc/debugger/gdbmidebugger.pp	(working copy)
    @@ -5117,11 +5117,15 @@
     
         DebugLn(DBG_VERBOSE, '[Debugger] Target PID: %u', [TargetInfo^.TargetPID]);
     
    +    DefaultTimeOut := DebuggerProperties.TimeoutForEval;   // Below may hang if host program doesn't have debug info
    +
         // they may still exist from prev run, addr will be checked
         FTheDebugger.FExceptionBreak.SetByAddr(Self);
         FTheDebugger.FBreakErrorBreak.SetByAddr(Self);
         FTheDebugger.FRunErrorBreak.SetByAddr(Self);
     
    +    DefaultTimeOut := -1;
    +
         SetDebuggerState(dsInit); // triggers all breakpoints to be set.
         Application.ProcessMessages; // workaround, allow source-editor to queue line info request (Async call)
         if FTheDebugger.FBreakAtMain <> nil
    
    fix_0025277.diff (966 bytes)

Activities

accSone

2013-11-03 18:21

developer  

fix_0025277.diff (966 bytes)
Index: /Developer/lazarus_trunc/debugger/gdbmidebugger.pp
===================================================================
--- /Developer/lazarus_trunc/debugger/gdbmidebugger.pp	(revision 43338)
+++ /Developer/lazarus_trunc/debugger/gdbmidebugger.pp	(working copy)
@@ -5117,11 +5117,15 @@
 
     DebugLn(DBG_VERBOSE, '[Debugger] Target PID: %u', [TargetInfo^.TargetPID]);
 
+    DefaultTimeOut := DebuggerProperties.TimeoutForEval;   // Below may hang if host program doesn't have debug info
+
     // they may still exist from prev run, addr will be checked
     FTheDebugger.FExceptionBreak.SetByAddr(Self);
     FTheDebugger.FBreakErrorBreak.SetByAddr(Self);
     FTheDebugger.FRunErrorBreak.SetByAddr(Self);
 
+    DefaultTimeOut := -1;
+
     SetDebuggerState(dsInit); // triggers all breakpoints to be set.
     Application.ProcessMessages; // workaround, allow source-editor to queue line info request (Async call)
     if FTheDebugger.FBreakAtMain <> nil
fix_0025277.diff (966 bytes)

accSone

2013-11-03 18:22

developer   ~0071125

See attached fix that solves the problem

accSone

2013-11-03 18:33

developer   ~0071126

gdb version:

GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".

Martin Friebe

2013-11-03 23:03

manager   ~0071129

Applied with modification. Not needed to set it back. Also set it earlier already.
Please test and close if ok.


This means the library will not stop on exceptions. But that was the case anyway.

I added (but not yet tested) some code that may partly address this:
Some gdb allow "b -f funcname" which will set the breakpoint, when the function will be available.
Though if GDB does nto support -f it will not work. And even if it works, it may break, but due to internal differences not show the class and message of the exception.

To test this feature, compile with WITH_GDB_FORCE_EXCEPTBREAK defined e.g. -dWITH_GDB_FORCE_EXCEPTBREAK

To discuss this, please use forum, mail-list, or private email to lazarus#mfriebe.de

Issue History

Date Modified Username Field Change
2013-11-03 18:20 accSone New Issue
2013-11-03 18:20 accSone Status new => assigned
2013-11-03 18:20 accSone Assigned To => Martin Friebe
2013-11-03 18:21 accSone File Added: fix_0025277.diff
2013-11-03 18:22 accSone Note Added: 0071125
2013-11-03 18:33 accSone Note Added: 0071126
2013-11-03 23:03 Martin Friebe Fixed in Revision => 43362
2013-11-03 23:03 Martin Friebe LazTarget => 1.2
2013-11-03 23:03 Martin Friebe Note Added: 0071129
2013-11-03 23:03 Martin Friebe Status assigned => resolved
2013-11-03 23:03 Martin Friebe Fixed in Version => 1.2.0
2013-11-03 23:03 Martin Friebe Resolution open => fixed