Recent

Author Topic: 2.0RCL2 OSX: BackTraceStrFunc returns only address  (Read 1347 times)

bigDan

  • New Member
  • *
  • Posts: 37
2.0RCL2 OSX: BackTraceStrFunc returns only address
« on: November 16, 2018, 06:25:01 am »
I'm porting a Lazarus program from Windows to Macintosh.

One user is experiencing regular exceptions. In the windows version, I generate a list of calls when an exception occurs so I can determine where the error occurs.

In osx, the BackTraceStrFunc returns only an address.

In Windows, BackTraceStrFunc produces a line such as

$004F7708  TCONTROL__CLICK,  line 2736 of ./include/control.inc

When I run it on Mac OS, I only get

$004F7708

I can use lldb at the command line and it works, but explaining to a remote user how to use lldb is an option I am hoping to avoid.

The compiler is Lazarus 2.0RCL2. It is compiling 64bit / cocoa. I have tried it with GDB and LLDB as the debugger.

Note that if I'm running the debugger in lazarus, I can do a Call Stack from the debugger and it works properly. So the information is available.

Enclosed is a simple project that will generate a backtrace. It works fine in windows and linux, but fails in Mac osx.

Does any one know what needs to be done to make this work? Thanks.

bigDan

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5776
    • wiki
Re: 2.0RCL2 OSX: BackTraceStrFunc returns only address
« Reply #1 on: November 16, 2018, 10:02:34 am »
I think it is a known issue, i.e., there is a report on the bugtracker.
Apparently the line info reader in fpc is not implemented for Mac.

Anyway, if you have the exact same exe, then you can take the trace and translate in in lldb (not tested, but should work.

Load the exe in gdb, and then for each address
Code: Pascal  [Select]
  1.  image lookup -v --address 0x1ec4
The output should contain the line. (hopefully)

bigDan

  • New Member
  • *
  • Posts: 37
Re: 2.0RCL2 OSX: BackTraceStrFunc returns only address
« Reply #2 on: November 16, 2018, 07:22:51 pm »
Thanks Martin!

I was able to use image lookup -v --address in lldb and it provided the necessary info.

Do you know the issue number for the bug tracker? I looked all over and never found it.

bigDan

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5776
    • wiki
Re: 2.0RCL2 OSX: BackTraceStrFunc returns only address
« Reply #3 on: November 16, 2018, 07:47:26 pm »
might be this one https://bugs.freepascal.org/view.php?id=32775

if not search for "dwarf"