How to debug machine code PROCs/FNs with Computer One Monitor (C1MON)?

Anything QL Software or Programming Related.
Post Reply
User avatar
ql_freak
Super Gold Card
Posts: 504
Joined: Sun Jan 18, 2015 1:29 am

How to debug machine code PROCs/FNs with Computer One Monitor (C1MON)?

Post by ql_freak »

I think I have already debugged machine code extensions with Computer One Monitor but can't remember how I did it. I've set the job ID in C1MON to a Minverva MultiBASIC with C1MONs job command and then called the extension (in this case a function) with print funcname (it's a function without parameters) but C1MON doesn't stop at the breakpoint I have set.


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 :-)
Derek_Stewart
Font of All Knowledge
Posts: 4739
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: How to debug machine code PROCs/FNs with Computer One Monitor (C1MON)?

Post by Derek_Stewart »

Hi Peter,

I use QMON to step through code.

Also the debugger in Qemulator is worth looking at.


Regards,

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

Re: How to debug machine code PROCs/FNs with Computer One Monitor (C1MON)?

Post by tofro »

ql_freak wrote: Sun May 04, 2025 5:55 pm I think I have already debugged machine code extensions with Computer One Monitor but can't remember how I did it. I've set the job ID in C1MON to a Minverva MultiBASIC with C1MONs job command and then called the extension (in this case a function) with print funcname (it's a function without parameters) but C1MON doesn't stop at the breakpoint I have set.
How and where did you set the breakpoint? The jobID is relatively irrelevant - Most monitors don't check what job is currently running when the code is running onto a breakpoint - You must have loaded the code to some address - also remember, the first part of an S*basic extension is a table, not code - setting a breakpoint there doesn't help - you must find the offset of he actual code that is called when the extension functions are used, then set the breakpoint there. The listing file (if your assembler produces one) helps to find the offset from the load address.


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

Re: How to debug machine code PROCs/FNs with Computer One Monitor (C1MON)?

Post by ql_freak »

I have finally found the solution:

Load your extension (ideally in a MultiBASIC) with cde=RESPR(size):LBYTES 'filename_cde',cde:CALL cde:JOBS:PRINT HEX$(cde,32)

Switch into C1Mon and enter the command jobs (use a channel with a large window, in my config it is #3)

Find the MultiBASIC job id by comparing with the SuperBASIC JOBS output.

Then enter in C1mon:

job <jobid>

(job 0 for normal SuperBASIC)

Then set a breakpoint (you may dump the memory starting at cde, which we have printed in hex) in the code you have LBYTESed above and in C1MON finally enter:

go

Now you can call the machine code extension from SuperBASIC (e.g. a=REF_GETLNLO%) and C1Mon will stop at the break point (the BASIC job is suspended in this case). Now you can examine the registers, trace, ... finally enter go again so that the code return to BASIC (it should then react normally).

Edith (2025-05-12 Mon): "...shouldn't then..." in last paragraph -> "...should then..."


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
ql_freak
Super Gold Card
Posts: 504
Joined: Sun Jan 18, 2015 1:29 am

Re: How to debug machine code PROCs/FNs with Computer One Monitor (C1MON)?

Post by ql_freak »

 
   I'm (slowly) coming "firm" again with the C1 Monitor :‑D It's IMHO the best monitor for the QL. Is the source code available? If one could add a history device to its channel #0, this would be absolutely great! And even better (Minerva and SMSQ/E) check the ESC key when entering commands (so that this command will not be executed if "executed" with ESC). It's possible with QDOS now (was NOT, when C1Mon has had been written, was the first monitor IMHO).

Unfortunately I have not yet tested symbolic debugging with the Professional C1Mon (only a few people have it, and even less have the documentation which is just an addendum to the original manual).


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
tofro
Font of All Knowledge
Posts: 3116
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: How to debug machine code PROCs/FNs with Computer One Monitor (C1MON)?

Post by tofro »

ql_freak wrote: Wed Jun 11, 2025 11:35 pm Unfortunately I have not yet tested symbolic debugging with the Professional C1Mon (only a few people have it, and even less have the documentation which is just an addendum to the original manual).
If you happen to have it, it would be good to make it available - Its author has, as far as I know, released it into the public.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Post Reply