Profiler --parse

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.1.0

Moderators: simonsunnyboy, thothy, Moderator Team

User avatar
Cyprian
Atari God
Atari God
Posts: 1500
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Profiler --parse

Postby Cyprian » Thu Oct 10, 2013 4:45 pm

Hi Eero,

I'm just trying to learn basic functionality of Hatari's debugger based on DML's ST Doom.
I have listed below script which works as expected, when I type by hand those commands into debbuger's console:

Code: Select all

b pc = TEXT :once
c
symbols stdf.sym TEXT
b PC = _raycast_world :once
c
profile on
b VBL = "VBL+200" :once
c
profile save myprofile.txt
q


But, when I put them into my file profiling.ini, and execute ("hatari --parse profiling.ini /testfile.prg"), those commands are executed one after other immediately, without waiting for breakpoints triggers.
I was also trying your example of automatic "chaining" of debugger from http://hg.tuxfamily.org/mercurialroot/h ... reakpoints but without success.

Could you advise me how to "automatize" my script?

thanks
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

jok
Atari freak
Atari freak
Posts: 72
Joined: Wed Dec 19, 2012 3:06 pm

Re: Profiler --parse

Postby jok » Thu Oct 10, 2013 6:27 pm

Start Hatari with Xbios extensions on. Then you can inject your debugger commands from your ST program via Xbios #254 call (and therefore your ST program triggers the profiling)

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1731
Joined: Sun Jul 31, 2011 1:11 pm

Re: Profiler --parse

Postby Eero Tamminen » Thu Oct 10, 2013 7:06 pm

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
trace gemdos,xbios
profile on

==> 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
profile stack
b pc = "NextPC"  :noinit :quiet :once :file showretval.ini

==> showretval.ini <==
# show return value for OS call
e d0

==> terminate.ini <==
# program terminated, save profile & quit
profile save quake-end.txt
profile off
quit


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.

User avatar
Cyprian
Atari God
Atari God
Posts: 1500
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Profiler --parse

Postby Cyprian » Fri Oct 11, 2013 12:07 pm

thanks Eero, based on your explanation and Douglas' file I prepared working version of chain.
It seems that, my main issue was in that string " :once :trace". Based on section "Chaining breakpoints " in Hatari's manual I was trying with only ":trace", and it doesn't work properly. After adding ":once" everything works as expected.

Profiler_App_Load:

Code: Select all

b GemdosOpcode = 0x3D :once :trace :file Profiler_App_Start.ini

Profiler_App_Start:

Code: Select all

b pc = TEXT :once :trace :file Profiler_Wait.ini

Profiler_Wait:

Code: Select all

symbols stdf.sym text data bss
b PC = _raycast_world :once :trace :file Profiler_Start.ini

Profiler_Start:

Code: Select all

profile on
b VBL = "VBL+200" :trace :file Profiler_End.ini

Profiler_End:

Code: Select all

trace none
b all
profile save myprofile.txt
q
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1731
Joined: Sun Jul 31, 2011 1:11 pm

Re: Profiler --parse

Postby Eero Tamminen » Fri Oct 11, 2013 9:02 pm

Cyprian wrote:thanks Eero, based on your explanation and Douglas' file I prepared working version of chain.
It seems that, my main issue was in that string " :once :trace". Based on section "Chaining breakpoints " in Hatari's manual I was trying with only ":trace", and it doesn't work properly. After adding ":once" everything works as expected.


In the example I knew that the breakpoints won't be hit before they're removed at the end of the chain, so I hadn't used ":once" option in it.

However, it can hit in cases where people apply the examples, so it's best to ":once" option also in examples:
http://hg.tuxfamily.org/mercurialroot/h ... ba54c1dbd5

Thanks for pointing that out! :-)

User avatar
Cyprian
Atari God
Atari God
Posts: 1500
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Profiler --parse

Postby Cyprian » Fri Oct 11, 2013 11:49 pm

Eero Tamminen wrote:Thanks for pointing that out! :-)

welcome :) and thanks for the support
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 4 guests