Skip to content

Commit 4041c39

Browse files
committed
source-level debugging feature
(As described at PR #13444)
1 parent c25a4b8 commit 4041c39

Some content is hidden

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

79 files changed

+6048
-362
lines changed

docs/source/commandline/commandline-all.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,6 +3856,81 @@ Core Communication Options
38563856
38573857
mame arescue -comm_remotehost 192.168.1.3 -comm_remoteport 30100 -comm_framesync
38583858
3859+
.. _mame-commandline-srcdbginfo:
3860+
3861+
**-src_debug_info** *<path>*
3862+
3863+
Enable :ref:`source-level debugging <srcdbg>`. *<path>* is a path to the :ref:`MAME Debugging Information File <srcdbg_mdi>`
3864+
3865+
By default, source-level debugging is disabled.
3866+
3867+
Example:
3868+
.. code-block:: bash
3869+
3870+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi
3871+
3872+
.. _mame-commandline-srcdbgsearchpath:
3873+
3874+
**-src_debug_search_path** *<path-list>*
3875+
3876+
If :ref:`source-level debugging <srcdbg>` is enabled, and
3877+
relative paths are present in the
3878+
:ref:`MAME Debugging Information File <srcdbg_mdi>`, this
3879+
specifies where MAME should look for those source files.
3880+
3881+
*<path-list>* is a semicolon-separated list of full paths
3882+
to directories on the MAME host system.
3883+
3884+
By default, MAME expects to find full paths to source files in the
3885+
MAME Debugging Information File.
3886+
3887+
Example:
3888+
.. code-block:: bash
3889+
3890+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi -src_debug_search_path c:\MyProject\SourceDir1;c:\MyProject\SourceDir2
3891+
3892+
.. _mame-commandline-srcdbgprefixmap:
3893+
3894+
**-src_debug_prefix_map** *<prefix-map>*
3895+
3896+
If :ref:`source-level debugging <srcdbg>` is enabled, and the sources originally used
3897+
to build the debugged program are in a different location on the MAME
3898+
host system, this specifies how to map path prefixes from the originally
3899+
built source files to the source files currently present on the MAME
3900+
host system. This is useful in cases where the debugged program was
3901+
built on a machine different from the MAME host system, or if the
3902+
build *environment* is different from the MAME run-time environment (such
3903+
as the use of cygwin while running the build tool).
3904+
3905+
*<prefix-map>* is a semicolon-separated list of semicolon-separated pairs of
3906+
paths, where each pair consists of a build environment's path prefix followed
3907+
by the MAME host system's path prefix it should be replaced with, of the form:
3908+
3909+
*build-path-prefix1*\ ;\ *runtime-path-prefix1*\ ;\ *build-path-prefix2*\ ;\ *runtime-path-prefix2*\ ;\ *etc.*
3910+
3911+
By default, source files are expected to be located at the same paths
3912+
present in the :ref:`MAME Debugging Information File <srcdbg_mdi>`
3913+
3914+
Example:
3915+
.. code-block:: bash
3916+
3917+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi -src_debug_prefix_map /cygdrive/c/;c:\;/cygdrive/d/;d:\
3918+
3919+
.. _mame-commandline-srcdbgoffset:
3920+
3921+
**-src_debug_offset** *<offset>*
3922+
3923+
If :ref:`source-level debugging <srcdbg>` is enabled, this causes *<offset>*
3924+
to be applied to all addresses encountered in the
3925+
:ref:`MAME Debugging Information File <srcdbg_mdi>`. For more information,
3926+
see :ref:`srcdbg_offsets`.
3927+
3928+
The default is 0.
3929+
3930+
Example:
3931+
.. code-block:: bash
3932+
3933+
mame coco2 -src_debug_info c:\MyProject\MyProject.mdi -src_debug_offset 57344
38593934
38603935
.. _mame-commandline-miscoptions:
38613936

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: 23 additions & 2 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

@@ -100,8 +102,10 @@ symlist
100102

101103
Lists registered symbols and their values. If **<cpu>** is not
102104
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
105+
symbols specific to the device **<cpu>** are displayed. If a **<cpu>**
106+
is specified, and :ref:`Source-Level Debugging <srcdbg>` is enabled on that
107+
CPU, then :ref:`source-level symbols <srcdbg_symbols>` are listed as well.
108+
Symbols are listed alphabetically. Read-only symbols are noted. See
105109
:ref:`debugger-devicespec` for details on how to specify a CPU.
106110

107111
Examples:
@@ -568,6 +572,23 @@ Examples:
568572
Back to :ref:`debugger-general-list`
569573

570574

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

573594
quit

0 commit comments

Comments
 (0)