Procedure call tree

Anything QL Software or Programming Related.
Post Reply
User avatar
dilwyn
Mr QL
Posts: 3086
Joined: Wed Dec 01, 2010 10:39 pm

Procedure call tree

Post by dilwyn »

I'm pretty sure I've seen what I'm looking for somewhere, but can't for the life of me remember where! If anyone knows of such a program, it'll save me time writing my own.
What I'd like is a routine to scan a program in memory and in addition to listing procedures and functions (like QREF software) I'd like it to examine the list of routines it calls to be able to see which proc/fn calls which. A bit like a file explorer directory tree type of display, e.g.

Code: Select all

PROC:ABC
 |-calls BCD
 |-calls EFG
   |-calls HIJ
 PROC: BCD
 PROC: EFG
 |- calls HIJ
 PROC: HIJ
I could probably steal code from my BASIC Reporter to do it, but why reinvent the wheel if someone's already written one.

It's needed with a large program I have, which I'm struggling to follow the flow of procedure and function calls to debug a weird issue, so I hoped that a little program to do this might help me.


User avatar
tofro
Font of All Knowledge
Posts: 3108
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Procedure call tree

Post by tofro »

dilwyn wrote: Mon May 26, 2025 1:57 pm I'm pretty sure I've seen what I'm looking for somewhere, but can't for the life of me remember where! If anyone knows of such a program, it'll save me time writing my own.
What I'd like is a routine to scan a program in memory and in addition to listing procedures and functions (like QREF software)
MasterBasic has functions to examine a function's/procedure's call stack at runtime and extensive functions to list procedures and functions.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
martyn_hill
QL Wafer Drive
Posts: 1074
Joined: Sat Oct 25, 2014 9:53 am

Re: Procedure call tree

Post by martyn_hill »

Hi Dilwyn!

Not sure how useful it would be for your use-case, but SNG's DIY 'WHY' Function could be placed within the various functions/procs of interest to display the Return Stack at runtime. I don't recall whether it worked only with GOSUBs or also with 'real' PROCs...


User avatar
dilwyn
Mr QL
Posts: 3086
Joined: Wed Dec 01, 2010 10:39 pm

Re: Procedure call tree

Post by dilwyn »

martyn_hill wrote: Mon May 26, 2025 2:28 pm Hi Dilwyn!

Not sure how useful it would be for your use-case, but SNG's DIY 'WHY' Function could be placed within the various functions/procs of interest to display the Return Stack at runtime. I don't recall whether it worked only with GOSUBs or also with 'real' PROCs...
Ah, thanks Martyn. That might be the one I thought of. Although MasterBasic mentioned by tofro could be handy too. I'll give them a try when I get home.


User avatar
tofro
Font of All Knowledge
Posts: 3108
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Procedure call tree

Post by tofro »

dilwyn wrote: Mon May 26, 2025 2:45 pm
martyn_hill wrote: Mon May 26, 2025 2:28 pm Hi Dilwyn!

Not sure how useful it would be for your use-case, but SNG's DIY 'WHY' Function could be placed within the various functions/procs of interest to display the Return Stack at runtime. I don't recall whether it worked only with GOSUBs or also with 'real' PROCs...
Ah, thanks Martyn. That might be the one I thought of. Although MasterBasic mentioned by tofro could be handy too. I'll give them a try when I get home.
Not everything of Masterbasic seems to work well on SMSQ/E. But I've seen the static analysis (what's called by what) and the stack tracing work on my machine.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
ql_freak
Gold Card
Posts: 498
Joined: Sun Jan 18, 2015 1:29 am

Re: Procedure call tree

Post by ql_freak »

dilwyn wrote: Mon May 26, 2025 1:57 pmWhat I'd like is a routine to scan a program in memory and in addition to listing procedures and functions (like QREF software) I'd like it to examine the list of routines it calls to be able to see which proc/fn calls which. A bit like a file explorer directory tree type of display, e.g.

...
That's the problem with SuperBASIC: There is not really a good IDE for SuperBASIC (not even a good editor). With PyCharm (and Python of course) such things are one of the easier ones... (with MY keyboard shortcut: Ctrl+Alt+F7; I know it blindly).


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
User avatar
Andrew
QL Wafer Drive
Posts: 1035
Joined: Tue Jul 17, 2018 9:10 pm

Re: Procedure call tree

Post by Andrew »

dilwyn wrote: Mon May 26, 2025 1:57 pm I'm pretty sure I've seen what I'm looking for somewhere, but can't for the life of me remember where! If anyone knows of such a program, it'll save me time writing my own.
What I'd like is a routine to scan a program in memory and in addition to listing procedures and functions (like QREF software) I'd like it to examine the list of routines it calls to be able to see which proc/fn calls which.
Dilwyn, your post rang a bell - there was such a program on a QL CLub disk . I searched for it and I think I found it:

TREE_task. The task is designed to produce a hierarchy tree for analysis of the PROCedure & FuNction calls made by the subject SB. programme, being quite fast and simple to use. As the early part of the task reads the tokenised area, and that is liable to shift when jobs demand space , it is advisable to use EXEC_W for the job.
The source code is included in the zip file.
Attachments
tree.zip
(25.09 KiB) Downloaded 12 times


Post Reply