diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-07-22 19:27:14 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-07-22 19:32:44 -0700 |
commit | 8c19b906e316ef84149d6cec234d3a467d3a68fe (patch) | |
tree | 474aa193cea4f724842e07c46f332d4845b99957 /subx | |
parent | 7397dc2ad38db16c88344adc18a8b5381b9cd933 (diff) | |
download | mu-8c19b906e316ef84149d6cec234d3a467d3a68fe.tar.gz |
5452
Snapshot while debugging survey.subx by print. I can see the error in 1 minute with this command: subx run apps/survey < a.pack (where a.pack is obtained from `ntranslate 049*.subx 05[0-8]*.subx`) By contrast, using the trace requires 4.5 minutes: subx --trace run apps/survey < a.pack It generates a trace of 4.4GB with almost 83M lines. The trace takes 2 minutes to load.. oops, I forgot to load labels with `--debug`.
Diffstat (limited to 'subx')
-rwxr-xr-x | subx/apps/survey | bin | 43503 -> 43682 bytes | |||
-rw-r--r-- | subx/apps/survey.subx | 281 |
2 files changed, 161 insertions, 120 deletions
diff --git a/subx/apps/survey b/subx/apps/survey index f4f2c695..45d83aa6 100755 --- a/subx/apps/survey +++ b/subx/apps/survey Binary files differdiff --git a/subx/apps/survey.subx b/subx/apps/survey.subx index f45773a5..42c11351 100644 --- a/subx/apps/survey.subx +++ b/subx/apps/survey.subx @@ -203,15 +203,15 @@ convert: # infile : (address buffered-file), out : (address buffered-file) -> < #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP #? # }}} -#? # write(2/stderr, "slurp in\n") {{{ -#? # . . push args -#? 68/push "slurp in\n"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # }}} + # write(2/stderr, "slurp in\n") {{{ + # . . push args + 68/push "slurp in\n"/imm32 + 68/push 2/imm32/stderr + # . . call + e8/call write/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # }}} # slurp(infile, in) # . . push args 56/push-ESI @@ -299,15 +299,15 @@ convert: # infile : (address buffered-file), out : (address buffered-file) -> < #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP #? # }}} -#? # write(2/stderr, "compute-offsets\n") {{{ -#? # . . push args -#? 68/push "compute-offsets\n"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # }}} + # write(2/stderr, "compute-offsets\n") {{{ + # . . push args + 68/push "compute-offsets\n"/imm32 + 68/push 2/imm32/stderr + # . . call + e8/call write/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # }}} # compute-offsets(in, segments, labels) # . . push args 52/push-EDX @@ -317,15 +317,15 @@ convert: # infile : (address buffered-file), out : (address buffered-file) -> < e8/call compute-offsets/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -#? # write(2/stderr, "compute-addresses\n") {{{ -#? # . . push args -#? 68/push "compute-addresses\n"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # }}} + # write(2/stderr, "compute-addresses\n") {{{ + # . . push args + 68/push "compute-addresses\n"/imm32 + 68/push 2/imm32/stderr + # . . call + e8/call write/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # }}} # compute-addresses(segments, labels) # . . push args 52/push-EDX @@ -334,111 +334,111 @@ convert: # infile : (address buffered-file), out : (address buffered-file) -> < e8/call compute-addresses/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x8/imm32 # add to ESP - # rewind-stream(in) - # . . push args - 56/push-ESI - # . . call - e8/call rewind-stream/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # write(2/stderr, "emit-output\n") {{{ -#? # . . push args -#? 68/push "emit-output\n"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # }}} -#? # dump *Trace-stream {{{ -#? # . write(2/stderr, "^") -#? # . . push args -#? 68/push "^"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write-stream(2/stderr, *Trace-stream) -#? # . . push args -#? ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32 # push *Trace-stream -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write-stream/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . write(2/stderr, "$\n") -#? # . . push args -#? 68/push "$\n"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # }}} -#? # dump labels->write {{{ -#? # . write(2/stderr, "labels->write after rewinding input: ") +#? # rewind-stream(in) #? # . . push args -#? 68/push "labels->write after rewinding input: "/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . clear-stream(Stderr+4) -#? # . . save EAX -#? 50/push-EAX -#? # . . push args -#? b8/copy-to-EAX Stderr/imm32 -#? 05/add-to-EAX 4/imm32 -#? 50/push-EAX +#? 56/push-ESI #? # . . call -#? e8/call clear-stream/disp32 +#? e8/call rewind-stream/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . . restore EAX -#? 58/pop-to-EAX -#? # . print-int32-buffered(Stderr, labels) +#? #? # write(2/stderr, "emit-output\n") {{{ +#? #? # . . push args +#? #? 68/push "emit-output\n"/imm32 +#? #? 68/push 2/imm32/stderr +#? #? # . . call +#? #? e8/call write/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? #? # }}} +#? #? # dump *Trace-stream {{{ +#? #? # . write(2/stderr, "^") +#? #? # . . push args +#? #? 68/push "^"/imm32 +#? #? 68/push 2/imm32/stderr +#? #? # . . call +#? #? e8/call write/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? #? # . write-stream(2/stderr, *Trace-stream) +#? #? # . . push args +#? #? ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32 # push *Trace-stream +#? #? 68/push 2/imm32/stderr +#? #? # . . call +#? #? e8/call write-stream/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? #? # . write(2/stderr, "$\n") +#? #? # . . push args +#? #? 68/push "$\n"/imm32 +#? #? 68/push 2/imm32/stderr +#? #? # . . call +#? #? e8/call write/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? #? # }}} +#? #? # dump labels->write {{{ +#? #? # . write(2/stderr, "labels->write after rewinding input: ") +#? #? # . . push args +#? #? 68/push "labels->write after rewinding input: "/imm32 +#? #? 68/push 2/imm32/stderr +#? #? # . . call +#? #? e8/call write/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? #? # . clear-stream(Stderr+4) +#? #? # . . save EAX +#? #? 50/push-EAX +#? #? # . . push args +#? #? b8/copy-to-EAX Stderr/imm32 +#? #? 05/add-to-EAX 4/imm32 +#? #? 50/push-EAX +#? #? # . . call +#? #? e8/call clear-stream/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +#? #? # . . restore EAX +#? #? 58/pop-to-EAX +#? #? # . print-int32-buffered(Stderr, labels) +#? #? # . . push args +#? #? ff 6/subop/push 0/mod/indirect 2/rm32/EDX . . . . . . # push *EDX +#? #? 68/push Stderr/imm32 +#? #? # . . call +#? #? e8/call print-int32-buffered/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? #? # . flush(Stderr) +#? #? # . . push args +#? #? 68/push Stderr/imm32 +#? #? # . . call +#? #? e8/call flush/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +#? #? # . write(2/stderr, "\n") +#? #? # . . push args +#? #? 68/push "\n"/imm32 +#? #? 68/push 2/imm32/stderr +#? #? # . . call +#? #? e8/call write/disp32 +#? #? # . . discard args +#? #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +#? #? # }}} +#? # emit-output(in, out, segments, labels) #? # . . push args -#? ff 6/subop/push 0/mod/indirect 2/rm32/EDX . . . . . . # push *EDX -#? 68/push Stderr/imm32 +#? 52/push-EDX +#? 51/push-ECX +#? ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) +#? 56/push-ESI #? # . . call -#? e8/call print-int32-buffered/disp32 +#? e8/call emit-output/disp32 #? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # . flush(Stderr) +#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP +#? # flush(out) #? # . . push args -#? 68/push Stderr/imm32 +#? ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) #? # . . call #? e8/call flush/disp32 #? # . . discard args #? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -#? # . write(2/stderr, "\n") -#? # . . push args -#? 68/push "\n"/imm32 -#? 68/push 2/imm32/stderr -#? # . . call -#? e8/call write/disp32 -#? # . . discard args -#? 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -#? # }}} - # emit-output(in, out, segments, labels) - # . . push args - 52/push-EDX - 51/push-ECX - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - 56/push-ESI - # . . call - e8/call emit-output/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32 # add to ESP - # flush(out) - # . . push args - ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 . # push *(EBP+12) - # . . call - e8/call flush/disp32 - # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP $convert:end: # . reclaim locals 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x30a0/imm32 # add to ESP @@ -1483,6 +1483,29 @@ $compute-addresses:segment-loop: # . srow->address = EDX | EBX 09/or 3/mod/direct 2/rm32/EDX . . . 3/r32/EBX . . # EDX = bitwise OR with EBX 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 2/r32/EDX 4/disp8 . # copy EDX to *(EAX+4) + # . print-int32-buffered(Stderr, srow->address) + # . . push args + ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 . # push *(EAX+4) + 68/push Stderr/imm32 + # . . call + e8/call print-int32-buffered/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . write-buffered(Stderr, "\n") + # . . push args + 68/push Newline/imm32 + 68/push Stderr/imm32 + # . . call + e8/call write-buffered/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # . flush(Stderr) + # . . push args + 68/push Stderr/imm32 + # . . call + e8/call flush/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP # trace-sssns("segment " srow " starts at address " srow->address ".") # . . push args 68/push "."/imm32 @@ -3365,6 +3388,7 @@ emit-elf-header: # out : (address buffered-file), segments : (address stream {s # *Elf_e_entry = get(labels, "Entry")->address # *Elf_e_phnum = segments->write / 16 # size of a row # emit-hex-array(out, Elf_header) + # write-buffered(out, "\n") # # . prolog 55/push-EBP @@ -3408,6 +3432,14 @@ emit-elf-header: # out : (address buffered-file), segments : (address stream {s e8/call emit-hex-array/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # write-buffered(out, "\n") + # . . push args + 68/push "\n"/imm32 + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) + # . . call + e8/call write-buffered/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP $emit-elf-header:end: # . restore registers 5a/pop-to-EDX @@ -3430,6 +3462,7 @@ emit-elf-program-header-entry: # out : (address buffered-file), curr-segment : # else # *Elf_p_flags = 6 # rw- # emit-hex-array(out, Elf_program_header_entry) + # write-buffered(out, "\n") # # . prolog 55/push-EBP @@ -3487,6 +3520,14 @@ $emit-elf-program-header-entry:really-emit: e8/call emit-hex-array/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # write-buffered(out, "\n") + # . . push args + 68/push "\n"/imm32 + ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) + # . . call + e8/call write-buffered/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP $emit-elf-program-header-entry:end: # . restore registers 5e/pop-to-ESI |