Page 24 sur 24

Re: ICE Compiler

Message non luPosté: 19 Sep 2018, 20:29
de PT_
The most important part of the debugger is pretty much ready: stepping through code! It was quite some work, but after all not very hard:

Image

Huge thanks to Runer112 for helping with setting breakpoints and a breakpoint handler!

Re: ICE Compiler

Message non luPosté: 02 Oct 2018, 11:38
de PT_
Welp, I need some help with the debugger, stepping through subprograms and stuff :( Runer and I tried some methods, but they all had huge drawbacks, and I'm not sure if there's a better way to do this:

When the debugger is called, I can get the global number (global = all (sub)programs combined in a large program) using the return address. When the user selects "Step through code", it needs to display the proper program and line. However, global line number != line number in correct program if you have some subprograms, so that's where problems arise. ICE outputs all the (sub)programs during prescanning, as well as the global start line, global end line and the depth of the subprogram (main program = 1, subprogram = 2, subsubprogram = 3 etc..).

My current method to select the right program and line is this: loop through all programs backwards, and the first program that matches startLine <= global line <= endLine is the right program (that is always true). Getting the local line number is quite harder. I have to loop through all subprograms with the depth being equal to inputDepth + 1 (so get all the subprograms from that program), and substract the amount of lines from the input line, as well as the startLine. See this:
Code: Tout sélectionner
                Line:   Line in prog:
A
[i]B            1       (1 - 1) = 0
dbd(0           2       (2 - 1) = 1
3->A            3       (3 - 1) = 2
AsmComp(C       4       (4 - 1) = 3
AsmComp(F       14      (14 - 1) - (13 - 5 + 1) = 4
3->A            18      (18 - 1) - (13 - 5 + 1) - (17 - 15 + 1) = 5

C
[i]B            5       (5 - 5) = 0
9->B            6       (6 - 5) = 1
AsmComp(D       7       (7 - 5) = 2
10->B           13      (13 - 5) - (12 - 8 + 1) = 3

D
[i]B            8       (8 - 8) = 0
AsmComp(E       9       (9 - 8) = 1
5->D            12      (12 - 8) - (11 - 10 + 1) = 2

E
[i]B            10      (10 - 10) = 0
3->F            11      (11 - 10) = 1

F
[i]B            15      (15 - 15) = 0
dbd(0           16      (16 - 15) = 1
5->G            17      (17 - 15) = 2

This method is currently up and running (it was pretty hard though!). However, this is still far from done. When displaying the program it also shows you the breakpoints. Thus, for each line in the program, I have to get the global number and check if a breakpoint is placed at that line. However, this part is almost impossible. I can't get the right global line number where it starts drawing, unless I want to loop through all programs ~25 times when displaying the program and that doesn't seem right to me. If this is already done, I also need to add setting/removing a breakpoint, which is pretty much the same idea, so yeah.

Runer had another idea where the first program gets lines 1-X, the first subprogram X+1-Y, the second Y+1-Z etc. This has the disadvantage that you have to loop through all single lines to see where the call address matched. Also, placing a breakpoint on the next line would be much harder.

Is there anyone with a better idea? ICE can output many things related to subprograms, so that is not the problem. The debugger only gets the call address where it can get the global line number from, but that's it.

Re: ICE Compiler

Message non luPosté: 01 Déc 2018, 21:20
de PT_
I've updated the documentation! Everything can be found on the Github Wiki, and everything will be converted into a single HTML documentation, replacing the old pdf file. Check it out, I'd love to hear feedback! :)

Download ICE Compiler

Re: ICE Compiler

Message non luPosté: 02 Déc 2018, 16:55
de Adriweb
Ah nice - and the wiki being a git repo itself, the doc can be versioned :P