Skip to content

Commit 30fb528

Browse files
committed
source-level debugging feature
(As described at PR #13444)
1 parent 922d60e commit 30fb528

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5794
-287
lines changed

docs/source/commandline/commandline-all.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3896,6 +3896,81 @@ Core Communication Options
38963896
38973897
mame arescue -comm_remotehost 192.168.1.3 -comm_remoteport 30100 -comm_framesync
38983898
3899+
.. _mame-commandline-srcdbginfo:
3900+
3901+
**-src_debug_info** *<path>*
3902+
3903+
Enable :ref:`source-level debugging <srcdbg>`. *<path>* is a path to the :ref:`MAME Debugging Information File <srcdbg_mdi>`
3904+
3905+
By default, source-level debugging is disabled.
3906+
3907+
Example:
3908+
.. code-block:: bash
3909+
3910+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi
3911+
3912+
.. _mame-commandline-srcdbgsearchpath:
3913+
3914+
**-src_debug_search_path** *<path-list>*
3915+
3916+
If :ref:`source-level debugging <srcdbg>` is enabled, and
3917+
relative paths are present in the
3918+
:ref:`MAME Debugging Information File <srcdbg_mdi>`, this
3919+
specifies where MAME should look for those source files.
3920+
3921+
*<path-list>* is a semicolon-separated list of full paths
3922+
to directories on the MAME host system.
3923+
3924+
By default, MAME expects to find full paths to source files in the
3925+
MAME Debugging Information File.
3926+
3927+
Example:
3928+
.. code-block:: bash
3929+
3930+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi -src_debug_search_path c:\MyProject\SourceDir1;c:\MyProject\SourceDir2
3931+
3932+
.. _mame-commandline-srcdbgprefixmap:
3933+
3934+
**-src_debug_prefix_map** *<prefix-map>*
3935+
3936+
If :ref:`source-level debugging <srcdbg>` is enabled, and the sources originally used
3937+
to build the debugged program are in a different location on the MAME
3938+
host system, this specifies how to map path prefixes from the originally
3939+
built source files to the source files currently present on the MAME
3940+
host system. This is useful in cases where the debugged program was
3941+
built on a machine different from the MAME host system, or if the
3942+
build *environment* is different from the MAME run-time environment (such
3943+
as the use of cygwin while running the build tool).
3944+
3945+
*<prefix-map>* is a semicolon-separated list of semicolon-separated pairs of
3946+
paths, where each pair consists of a build environment's path prefix followed
3947+
by the MAME host system's path prefix it should be replaced with, of the form:
3948+
3949+
*build-path-prefix1*\ ;\ *runtime-path-prefix1*\ ;\ *build-path-prefix2*\ ;\ *runtime-path-prefix2*\ ;\ *etc.*
3950+
3951+
By default, source files are expected to be located at the same paths
3952+
present in the :ref:`MAME Debugging Information File <srcdbg_mdi>`
3953+
3954+
Example:
3955+
.. code-block:: bash
3956+
3957+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi -src_debug_prefix_map /cygdrive/c/;c:\;/cygdrive/d/;d:\
3958+
3959+
.. _mame-commandline-srcdbgoffset:
3960+
3961+
**-src_debug_offset** *<offset>*
3962+
3963+
If :ref:`source-level debugging <srcdbg>` is enabled, this causes *<offset>*
3964+
to be applied to all addresses encountered in the
3965+
:ref:`MAME Debugging Information File <srcdbg_mdi>`. For more information,
3966+
see :ref:`srcdbg_offsets`.
3967+
3968+
The default is 0.
3969+
3970+
Example:
3971+
.. code-block:: bash
3972+
3973+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi -src_debug_offset 57344
38993974
39003975
.. _mame-commandline-miscoptions:
39013976

docs/source/debugger/breakpoint.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ Sets a new execution breakpoint at the specified **<address>**. The
2929
**<address>** may optionally be followed by a colon and a tag or
3030
debugger CPU number to set a breakpoint for a specific CPU. If no CPU
3131
is specified, the breakpoint will be set for the CPU currently visible
32-
in the debugger.
32+
in the debugger. When :ref:`source-level debugging <srcdbg>` is
33+
enabled, :ref:`alternatives <srcdbg_bp>` to specifying **<address>**
34+
are allowed.
3335

3436
The optional **<condition>** parameter lets you specify an expression
3537
that will be evaluated each time the breakpoint address is hit. If the

docs/source/debugger/execution.rst

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ Execution Debugger Commands
44
===========================
55

66
:ref:`debugger-command-step`
7-
single step for <count> instructions (F11)
7+
single step for <count> instructions (F11, when disassembly view is active)
8+
:ref:`debugger-command-steps`
9+
single step one source line (F11, when source view is active)
810
:ref:`debugger-command-over`
9-
single step over <count> instructions (F10)
11+
single step over <count> instructions (F10, when disassembly view is active)
12+
:ref:`debugger-command-overs`
13+
single step over one source line (F10, when source view is active)
1014
:ref:`debugger-command-out`
1115
single step until the current subroutine/exception handler returns
1216
(Shift-F11)
@@ -63,6 +67,46 @@ Examples:
6367
Back to :ref:`debugger-execution-list`
6468

6569

70+
.. _debugger-command-steps:
71+
72+
steps
73+
-----
74+
75+
**steps**
76+
77+
When :ref:`source-level debugging <srcdbg>` is enabled, this single-steps
78+
one *source* line on the currently executing CPU. When the original
79+
source is assembly language, ``step`` and ``steps`` generally behave the same.
80+
But when the original source is in a higher level language like C or BASIC,
81+
``steps`` results in executing the remainder of a block of instructions
82+
associated with the current source line.
83+
84+
If the current source line is a
85+
call instruction, ``steps`` stops at the first source line in the called
86+
function, but only if the called function has source associated with it.
87+
If neither the called function nor any of its callees have source associated
88+
with them, ``steps`` will continue execution until the call is complete, and
89+
the first instruction with source associated with it is encountered.
90+
91+
If the current line returns from a recursive function, ``steps`` will stop
92+
at the same line, but in the prior call frame. It will appear as if
93+
no stepping occurred, but the stack register will indicate a return
94+
has occurred. Note that this logic can be fooled when stepping into a function
95+
without associated source, which makes further calls without proper
96+
matching returns (using direct manipulation of the stack pointer instead).
97+
98+
99+
100+
Examples:
101+
102+
``steps``
103+
Steps forward to the next source line on the current CPU.
104+
``sts``
105+
Steps forward to the next source line on the current CPU.
106+
107+
Back to :ref:`debugger-execution-list`
108+
109+
66110
.. _debugger-command-over:
67111

68112
over
@@ -93,6 +137,30 @@ Examples:
93137
Back to :ref:`debugger-execution-list`
94138

95139

140+
.. _debugger-command-overs:
141+
142+
overs
143+
-----
144+
145+
**overs**
146+
147+
When :ref:`source-level debugging <srcdbg>` is enabled, this steps forward
148+
over one *source* line on the currently executing CPU. When the original
149+
source is assembly language, ``over`` and ``overs`` generally behave the same.
150+
But when the original source is in a higher level language like C or BASIC,
151+
``overs`` results in executing the remainder of a block of instructions
152+
associated with the current source line.
153+
154+
Examples:
155+
156+
``overs``
157+
Steps forward over the next source line on the current CPU.
158+
``os``
159+
Steps forward over the next source line on the current CPU.
160+
161+
Back to :ref:`debugger-execution-list`
162+
163+
96164
.. _debugger-command-out:
97165

98166
out
@@ -118,6 +186,33 @@ Example:
118186
Back to :ref:`debugger-execution-list`
119187

120188

189+
.. _debugger-command-outs:
190+
191+
outs
192+
----
193+
194+
**outs**
195+
196+
When :ref:`source-level debugging <srcdbg>` is enabled, this single-steps
197+
until the next return from subroutine or return from exception instruction
198+
lands the currently executing CPU to a *source* line. When the original
199+
source is assembly language and source-level debugging information is provided
200+
for the current and calling subroutine, ``out`` and ``outs`` generally
201+
behave the same. But when layers of functions or subroutines *without*
202+
source-level information exist between the current instruction and the
203+
most recent calling instruction *with* source-level information, ``outs``
204+
will skip over those "non source-level information" layers until it lands on
205+
calling code with source-level information.
206+
207+
Examples:
208+
209+
``outs``
210+
Steps until a subroutine or exception handler returns to code with
211+
source-level information.
212+
213+
Back to :ref:`debugger-execution-list`
214+
215+
121216
.. _debugger-command-go:
122217

123218
go

docs/source/debugger/general.rst

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ General Debugger Commands
4343
read commands from file and executes them one by one
4444
:ref:`debugger-command-time`
4545
prints the current machine time to the console
46+
:ref:`debugger-command-sdoffset`
47+
sets the address offset to be used by source-level debugging
4648
:ref:`debugger-command-quit`
4749
exit the debugger and end the emulation session
4850

@@ -99,15 +101,20 @@ symlist
99101
**symlist [<cpu>]**
100102

101103
Lists registered symbols and their values. If **<cpu>** is not
102-
specified, symbols in the global symbol table are displayed; otherwise,
103-
symbols specific to the device **<cpu>** are displayed. Symbols are
104-
listed alphabetically. Read-only symbols are noted. See
104+
specified, symbols in the global symbol table and the primary
105+
CPU are displayed; otherwise,
106+
symbols specific to the device **<cpu>** are displayed.
107+
If :ref:`Source-Level Debugging <srcdbg>` is enabled, and **<cpu>**
108+
is the primary CPU (or **<cpu>** is not specified),
109+
then :ref:`source-level symbols <srcdbg_symbols>` are listed as well.
110+
Symbols are listed alphabetically. Read-only symbols are noted. See
105111
:ref:`debugger-devicespec` for details on how to specify a CPU.
106112

107113
Examples:
108114

109115
``symlist``
110-
Displays the global symbol table.
116+
Displays the global symbol table, the primary CPU's symbol table,
117+
and, if enabled, source-level symbols.
111118
``symlist 2``
112119
Displays the symbols for the third CPU in the system (zero-based
113120
index).
@@ -568,6 +575,23 @@ Examples:
568575
Back to :ref:`debugger-general-list`
569576

570577

578+
.. _debugger-command-sdoffset:
579+
580+
sdoffset
581+
--------
582+
583+
Sets the :ref:`address offset <srcdbg_offsets>` to be used by
584+
:ref:`source-level debugging <srcdbg>`
585+
586+
Examples:
587+
588+
``sdoffset E000``
589+
Apply an offset of $E000 to all addresses present
590+
in the :ref:`MAME Debugging Information File <srcdbg_mdi>`.
591+
592+
Back to :ref:`debugger-general-list`
593+
594+
571595
.. _debugger-command-quit:
572596

573597
quit

0 commit comments

Comments
 (0)