Debug stacktrace?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
stam
Posts: 3093
Joined: Sun Jun 04, 2006 9:39 pm

Debug stacktrace?

Post by stam » Thu Jun 27, 2024 11:47 am

Hi all,

Just wondering if the stack trace (you know, that long incomprehensible text the OS serves up on a crash) can be accessed with LiveCode?

Many thanks
Stam

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: Debug stacktrace?

Post by richmond62 » Fri Jun 28, 2024 10:00 am

Recently I was merrily crashing an "alternative IDE" during what is called 'beta testing', but more accurately should be termed 'cursing, crying, and clamping one's mouth shut' on both MacOS 12 and MacOS 15 beta: the crash 'thing' was presented in a window that allowed it to be copy-pasted into a text document.

Therefore I would assume, on MacOS at least. that that 'thing' is stored somewhere as a text document (especially as the crash window said it would be sent to Apple) . . .

So: the first thing has to be to work out WHERE that text document is stored and whether you have the necessary user permissions to access it.

After that everything should be all rather easy.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: Debug stacktrace?

Post by richmond62 » Fri Jun 28, 2024 10:07 am

Oh, look: I used my brain and asked Google:

where does MacOS store crash reports?

and I got an answer:
crash log files are stored in the user's ~/Library/Logs/DiagnosticReports/ folder
Rocket Science!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: Debug stacktrace?

Post by richmond62 » Fri Jun 28, 2024 10:51 am

SShot 2024-06-28 at 12.49.28.png
-
Obviously time to learn that 'без кавичките' means 'without quotation marks' in Bulgarian. :)

That's 'bez kavichkiteh' for those of you who cannot cope with non-Latin writing systems. बेवकूफों
-
SShot 2024-06-28 at 12.51.20.png
-

stam
Posts: 3093
Joined: Sun Jun 04, 2006 9:39 pm

Re: Debug stacktrace?

Post by stam » Fri Jun 28, 2024 11:09 am

richmond62 wrote:
Fri Jun 28, 2024 10:07 am
Oh, look: I used my brain and asked Google:

where does MacOS store crash reports?

and I got an answer:
crash log files are stored in the user's ~/Library/Logs/DiagnosticReports/ folder
Rocket Science!
Thanks Richmond, but that's not quite what I need. I am aware of the crash logs - but these are only generated on a hard crash.

As I don't want my apps to actually crash, my scripts of full of try/catch blocks to actually manage the errors without crashing, so such a log entry will not be created. But it would still be useful to have a picture of what's going on in the system.

In other languages this is possible - I was just wondering if anyone has done this in LiveCode.
I'm slowly working on an error-management solution for standalones, but like everything else, progress is slow as my day job is currently using 99% of my time... hopefully I'll post something more about this at some point.

Stam

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: Debug stacktrace?

Post by richmond62 » Fri Jun 28, 2024 12:12 pm

that long incomprehensible text the OS serves up on a crash
Doesn't that mean when the IDE crashes, and NOT something 'baby' like this:
-
SShot 2024-06-28 at 14.11.24.png

stam
Posts: 3093
Joined: Sun Jun 04, 2006 9:39 pm

Re: Debug stacktrace?

Post by stam » Fri Jun 28, 2024 12:25 pm

richmond62 wrote:
Fri Jun 28, 2024 12:12 pm
that long incomprehensible text the OS serves up on a crash
Doesn't that mean when the IDE crashes, and NOT something 'baby' like this:
-
SShot 2024-06-28 at 14.11.24.png
a stack trace is a picture of what is in memory at the time (the stack refers to dynamically allocated memory - nothing to do with LC stacks - as opposed to memory in the heap) - this does not need to related to error/hang/crash although typically the OS will generate a stack trace on crash.

It's not about putting a livecode error into a text box or generating an individual log for that one app running but of course that would be the main thing to address anyway, and there are elegant methods for doing this.

I was hoping there was a way to getting to a stack trace via livecode, but it's not the end of the world if not.
I'll post more about this in the future when I've had more time to work on something I'm doing for this...

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10116
Joined: Fri Feb 19, 2010 10:17 am

Re: Debug stacktrace?

Post by richmond62 » Fri Jun 28, 2024 12:31 pm

https://stackoverflow.com/questions/222 ... -exception

"In program debugging, a stack trace is a report of the computer's internal processing operations. It generally identifies the last routine called in the program before it crashed."

Aha: well, there must be somewhere that stack trace is stored.

viewtopic.php?f=7&t=7950

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Debug stacktrace?

Post by FourthWorld » Fri Jun 28, 2024 5:44 pm

System calls are useful for system programmers, script execution details more useful for scripters.

There are likely low-level system call tracers for macOS, to strace on Linux. But if scripting is your focus:

LC's Message Watcher kind of attempts the latter, but has been largely unchanged since Dr Raney made it decades ago, with an output format that's not very useful.

Many years ago I made 4W Flight Recorder to obtain a list of all handlers triggered in the calling chain while I'm using my apps. The format is indented with initial ystem message from the triggering user action leftmost, everything called from that cascading indented below, allowing easy skimming/reading.

It also allows filters so things like IDE message and the nearly-constant stream of mousemove messages aren't littering the list.

As a bonus it also keeps track of relative time spent in each handler, providing reasonable profiling.

4W Flight Recorder is available in the IDE via LiveNet. See Development -> Plugins -> GoLiveNet, and in the LiveNet window see the Stacks section.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 3093
Joined: Sun Jun 04, 2006 9:39 pm

Re: Debug stacktrace?

Post by stam » Fri Jun 28, 2024 5:47 pm

Thanks Richard -- I am aware and use flight recorder.

But that can't be used with standalone apps to collect data from users in a sensible way.

Working on a solution having been inspired from something I recently came across - if it works will post on the forums...

S.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Debug stacktrace?

Post by FourthWorld » Sat Jun 29, 2024 1:25 am

stam wrote:
Fri Jun 28, 2024 5:47 pm
Thanks Richard -- I am aware and use flight recorder.

But that can't be used with standalone apps to collect data from users in a sensible way.
Why not? It's just a stack with no dependencies. All you need it a way for your stack to open it, no?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 3093
Joined: Sun Jun 04, 2006 9:39 pm

Re: Debug stacktrace?

Post by stam » Sat Jun 29, 2024 3:24 pm

Yeah you’re right - the script of this can be incorporated to derive a trail of livecode events that could be activated from where the user enters the handler, so it reports a list of events up to the crash - not sure how else this could be used.

I’m looking at creating a generalisable error reporting system for standalones, similar to what other platforms have. I’ll go into it in detail if this ever materialises, but an important part of this is viewing errors both at user level but more importantly as collated / grouped data.

The idea being that if the user does something unexpected and causes an error/crash (because users will always break your code), have some way of automating and collating crash data (ie if a particular error is reported 500 times, did 1 user cause 500 crashes or did 500 users experience 1 crash).

As far as I know there is no error management system like this for LC standalones - yes you can report individual errors, but that’s only usable if you have a small number of users and a small number of errors.

It would be very useful to include a breadcrumb trail like what flight recorder provides as well - I’ll see how that goes and might reach out if needed, if that’s OK.

The biggest hurdle is time which just seems to be less and less available :-/

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Debug stacktrace?

Post by FourthWorld » Sun Jun 30, 2024 12:35 am

The engine is the engine. Trace, debug, context details, all available. Sometimes folks make UIs for them and give them away, a window that can be opened like any other,
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply