Cyprian wrote:Could you advise me how to "automatize" my script?
You cannot continue emulation from the script (debugger doesn't run emulation, it's emulation that calls debugger and "continue" command just returns control back to emulation). Scripts just execute debugger commands from within given debugger session, not across multiple debugger sessions.
To chain/automate actions over multiple debugger sessions (triggered by breakpoints), you need to put commands that should be executed on a given breakpoint to a separate file, and give its name to breakpoint with the ":file" option.
Some things you can do without external script (see "lock" command and breakpoint ":lock" option), but setting additional breakpoints isn't one of those things.
Note: Using separate scripts is more flexible. You can have multiple breakpoints in effect at the same time with each of them triggering different actions!
As an example, here are scripts I used to profile Douglas' Quake1 TT port; its CPU usage, XBios calls and GEMDOS allocations:
Code: Select all
$ head *.ini
==> tos-start.ini <==
# when TOS does first Fopen(), it's safe to set breakpoint for TEXT
b GemdosOpcode = 0x3D :once :trace :file program-start.ini
==> program-start.ini <==
# start allocation tracking etc when program starts
b pc = text :once :trace :file alloc-tracking.ini
==> alloc-tracking.ini <==
# load symbols
symbols ../source/bin/quake.sym text data bss
# quit emulator if program terminates to Pterm()
b GemdosOpcode = 0x4C :trace :quiet :file terminate.ini
# show Maxalloc, Malloc, Mfree, Mshrink callers
b GemdosOpcode = 0x44 :noinit :quiet :file showcallers.ini
b GemdosOpcode = 0x48 :noinit :quiet :file showcallers.ini
b GemdosOpcode = 0x49 :noinit :quiet :file showcallers.ini
# all XBios calls except Gettime()
b XbiosOpcode ! 0xFFFF && XbiosOpcode ! 0x17 :noinit :quiet :file showcallers.ini
# save startup profile until demo is started
b pc = _CL_PlayDemo_f :trace :file profile-start.ini
# trace stuff & profile
setopt --bios-intercept --conout 2
==> profile-start.ini <==
# save profile until this moment
profile save quake-start.txt
==> showcallers.ini <==
# show (profile) callstack for breakpoint on a OS call.
# on next instruction it has returned so one can check return value
b pc = "NextPC" :noinit :quiet :once :file showretval.ini
==> showretval.ini <==
# show return value for OS call
==> terminate.ini <==
# program terminated, save profile & quit
profile save quake-end.txt
Attached is script I use to initiate that profiling and post-process the results when Quake terminates.
Btw. Allocation tracking was because 14MB isn't enough for the port, XBios calls are tracked to find out issues in things like resolution setting and OS call tracing is to know a bit better where in the program (startup) execution these thing happen.
Similar stuff is used in Douglas' Doom port to find out where disk accesses happen, but instead of having manually edited debugger scripts, the scripts are written out by a shell script starting BadMood for profiling. This is because shell script has several different tracing options and those affect what happens in debugger scripts.
You do not have the required permissions to view the files attached to this post.