bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stack traces not displaying correctly on macOS


From: Paul Rockwell
Subject: Re: Stack traces not displaying correctly on macOS
Date: Tue, 13 Feb 2024 09:35:00 -0500

Jürgen, 

I’ll download and test SVN 1752 on both macOS and a Fedora Intel system I have hanging around.  I figured you don’t use a Mac, so that’s why I took it upon myself to exercise some dormant coding skills and provide the diffs. 

The macro __APPLE__ is a system defined macro for macOS. I will find which system defined header file it resides in. It was recommended by some research to provide conditional compilation of code for the platform without the need for additional compiler flags. It shouldn't exist on non Apple platforms. 

- Paul

On Feb 13, 2024, at 8:21 AM, Dr. Jürgen Sauermann <mail@jürgen-sauermann.de> wrote:

 Hi Paul,

thanks. I have incorporated your diffs, SVN 1752.
Please check on your Apple since I don't own one (⎕FIO ¯16 
to provoke a stack dump).

I was also wondering where macro _APPLE_ is defined. In a header file
(which ?) or with -D on the command line? In the latter case we could let
./configure set the macro (for that I would need to know the output of
the uname command on your machine).

Best Regards,
Jürgen


On 2/12/24 23:40, Paul Rockwell wrote:
I've found that stack traces don't display correctly with GNU APL on macOS platforms (Intel and Apple Silicon). Examining the source for Backtrace.cc, I've found that function Backtrace::show_item() is expecting the string passed to it to look like this:

  // ./apl(_ZN10APL_parser9nextTokenEv+0x1dc) [0x80778dc]
  // │││││                             │││││   │││││││││
  // ─── program name             │││││   └┴┴┴┴┴┴┴┴───── abs_addr
  //                                   └┴┴┴┴───────────────── asm_offset

The macOS system function backtrace_symbols() - called by Backtrace::show() returns the strings in this format:

  //
  // 14  apl                                 0x00000001000a93f0 _ZN9Workspace19immediate_executionEb + 68
  // ││  ─── program name                 ││││││││││││││││││ ││││││││││││││││││||||||||||||||||||   └┴─── asm_offset
  // └┴─── stack level                       ││││││││││││││││││ └┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴─── function name
  //                                         └┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴───── abs_addr
  //

These strings don't match what the code is looking for, so the stack trace doesn't contain any useful information.

I prototyped some changes to Backtrace::show_item() to be able to recognize that GNU APL is being built on Apple macOS, and parse the macOS backtrace_symbols() string format. The resulting code seems to compile and work correctly on Intel Linux and macOS (both on Intel and Apple Silicon CPUs).

I've attached the diffs between SVN 1745 and my changed code. (I also made some other changes to the code to reflect use of nullptr and '\0' instead of the number 0 to improve the contextual clarity of some of the code. There are also a couple of changes to remove some compiler warnings on macOS for unreachable code)

You're welcome to use them if you find them useful.

- Paul Rockwell



reply via email to

[Prev in Thread] Current Thread [Next in Thread]