Thanks to the hints of Gopal and Paolo, I added a simple stabs generator for JIT code. As we currently don't have line numbers, the code assumes, there are no comments and no empty lines, just one op per line.

Here is a sample debug session (the important thing happens after build_asm where symbols got built):

$ gdb parrot
GNU gdb 4.18
....
(gdb) b runops_jit
Breakpoint 1 at 0x8049ca7: file interpreter.c, line 227.
(gdb) r -j -d mops.pbc
Starting program: /home/lt/src/parrot-leo/parrot -j mops.pbc

Breakpoint 1, runops_jit (interpreter=0x812eab0, pc=0x81466b0)
at interpreter.c:227
227 code_start = interpreter->code->byte_code;
(gdb) n
228 code_size = interpreter->code->byte_code_size / sizeof(opcode_t);
(gdb)
229 code_end = interpreter->code->byte_code + code_size;
(gdb)
231 jit_code = build_asm(interpreter, pc, code_start, code_end);
(gdb)
232 (jit_code) (interpreter, pc);
(gdb) add-symbol-file mops.o 0
add symbol table from file "mops.o" at text_addr = 0x0?
(y or n) y
Reading symbols from mops.o...done.
(gdb) s
jit_func () at mops.pasm:1
1 set I2, 0
(gdb)
2 set I3, 1
(gdb) l
1 set I2, 0
2 set I3, 1
3 set I4, 100000000
4 print "Iterations: "
5 print I4
6 print "\n"
7 set I1, 2
8 mul I5, I4, I1
9 print "Estimated ops: "
10 print I5
(gdb) l
11 print "\n"
12 time N1
13 REDO: sub I4, I4, I3
14 if I4, REDO
15 DONE: time N5
16 sub N2, N5, N1
17 print "Elapsed time: "
18 print N2
19 print "\n"
20 if I4, BUG
(gdb) b 13
Breakpoint 2 at 0x814ecc6: file mops.pasm, line 13.
(gdb) c
Continuing.
Iterations: 100000000
Estimated ops: 200000000

Breakpoint 2, jit_func () at mops.pasm:13
13 REDO: sub I4, I4, I3
(gdb) n
14 if I4, REDO
(gdb)
14 if I4, REDO
(gdb)
14 if I4, REDO
(gdb) b 15
Breakpoint 3 at 0x814ecdc: file mops.pasm, line 15.
(gdb) c
Continuing.

Breakpoint 3, jit_func () at mops.pasm:15
15 DONE: time N5
(gdb) c
Continuing.
Elapsed time: 9.725663
M op/s: 20.564151

Program exited normally.
(gdb) q

Have fun,
leo

Reply via email to