I am trying to work out why all the Mac system API calls I have tried calling - here CFStringCreateWithCString - in Lazarus 1.6.4 running in macOS Sierra 10.12.4 with GDB 8.0 and GDB 7.12.1 and all fails with:
"The debugge encountered and error when trying to run/step the application. Cannot find bounds of current function"
and the debugger jumps out of the function (or if the call is surrounded by try/except to the code following the except) - and later afterwards informs debugger unstable
...
Here is example code:
procedure myTest;
var
TestStrUTF8: UTF8String;
TmpStrPr_CSS: ConstCStringPtr;
TmpCFStrRef: CFStringRef;
TmpStrPtr: Pointer;
begin
TestStrUTF8 := 'http://example.com';
TmpStrPtr := Pointer(TestStrUTF8)
TmpStrPtr_CSS := ConstCStringPtr(TmpStrPtr);
TmpCFStrRef := CStringCreateWithCString(nil, TmpStrPtr_CSS, kCFStringEncodinguTF8); // Note1: we are only using ASCII, Note2: We have tried KCFStringEncodingWindowsLatin1 with same problem
// jumps out of routine and reports "Cannot find bounds of current function" here
showmessage('never reaches, crashes first');
end;
- I do not otherwise have problems debugging. I can step through code not calling Mac system API functions fine. I guess Lazarus/LCL/FPC libraries are also calling native Mac API functions, but that code is compiled differently and thus works.
- I am running above code in main thread.
- This issue seems to happen for multiple Mac API calls I have tried, so I think it may be a (GDB) debugger/Lazarus issue of a sorts.
Note: I am aware there might be debugger problems with macOS Sierra 10.12.5 which is why I have not upgraded yet.
Could his be some problem with SIP / address relocation / similar?
- In Debugger_Start_options I have added "--eval-command=set startup-with-shell off".
- I have also signed GDB of course.
- I use home brew for GDB installations