summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/debugcon.cpp
diff options
context:
space:
mode:
author holub <andrei.holub@gmail.com>2025-08-30 10:25:16 -0400
committer GitHub <noreply@github.com>2025-08-30 16:25:16 +0200
commit095418aec533e21727421dbf5a3ab4cedf90c135 (patch)
treee55aa8a6f9245c676f3a52b2cd64a9ab0b392ab0 /src/emu/debug/debugcon.cpp
parentc745d0bce07097aea0659fd10bff3077105efeee (diff)
emu/debug: Extended memory commands for region and space (#13767)
Diffstat (limited to 'src/emu/debug/debugcon.cpp')
-rw-r--r--src/emu/debug/debugcon.cpp65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp
index ec5bc154751..f9076dda523 100644
--- a/src/emu/debug/debugcon.cpp
+++ b/src/emu/debug/debugcon.cpp
@@ -24,6 +24,7 @@
#include <cctype>
#include <fstream>
#include <iterator>
+#include <regex>
/***************************************************************************
@@ -883,7 +884,7 @@ bool debugger_console::validate_device_space_parameter(std::string_view param, i
/// optionally followed by a colon and a device identifier. If the
/// device identifier is not presnt, the current CPU with debugger focus
/// is assumed. See #validate_device_parameter for information on how
-/// device parametersare interpreted.
+/// device parameters are interpreted.
/// \param [in] The parameter string.
/// \param [in] spacenum The default address space index. If negative,
/// the first address space exposed by the device (i.e. the address
@@ -916,6 +917,40 @@ bool debugger_console::validate_target_address_parameter(std::string_view param,
}
+/// \brief Validate a parameter as a address with memory region or share name
+///
+/// Validates a parameter as a address with memory region or share tag. addres
+/// parameters stays unchanged if invalid and requires additional validation on
+/// the caller side.
+/// \param [in] The parameter string.
+/// \param [out] addr The address on success, or unchanged on failure.
+/// \param [out] region The region on success, or unchanged on failure.
+/// \param [out] share The share on success, or unchanged on failure.
+/// \return true if the parameter refers to a memory region in the
+/// current system, or false otherwise.
+bool debugger_console::validate_address_with_memory_parameter(std::string_view param, u64 &addr, memory_region *&region, memory_share *&share)
+{
+ std::string str(param);
+ std::regex re("^([^:]+)(:.+)\\.([ms])$");
+ std::smatch m;
+ if (std::regex_match(str, m, re))
+ {
+ if ('m' == m[3])
+ validate_memory_region_parameter(m.str(2), region);
+ else if ('s' == m[3])
+ validate_memory_share_parameter(m.str(2), share);
+ else
+ return false;
+
+ validate_number_parameter(m.str(1), addr);
+
+ return true;
+ }
+
+ return false;
+}
+
+
/// \brief Validate a parameter as a memory region
///
/// Validates a parameter as a memory region tag and retrieves the
@@ -944,6 +979,34 @@ bool debugger_console::validate_memory_region_parameter(std::string_view param,
}
+/// \brief Validate a parameter as a memory share
+///
+/// Validates a parameter as a memory share tag and retrieves the
+/// specified memory share.
+/// \param [in] The parameter string.
+/// \param [out] result The memory share on success, or unchanged on
+/// failure.
+/// \return true if the parameter refers to a memory share in the
+/// current system, or false otherwise.
+bool debugger_console::validate_memory_share_parameter(std::string_view param, memory_share *&result)
+{
+ auto const &shares = m_machine.memory().shares();
+ std::string_view relative = param;
+ device_t &base = get_device_search_base(relative);
+ auto const iter = shares.find(base.subtag(strmakelower(relative)));
+ if (shares.end() != iter)
+ {
+ result = iter->second.get();
+ return true;
+ }
+ else
+ {
+ printf("No matching memory share found for '%s'\n", param);
+ return false;
+ }
+}
+
+
/// \brief Get search base for device or address space parameter
///
/// Handles prefix prefixes used to indicate that a device tag should be