mirror of
https://github.com/holub/mame
synced 2025-07-05 18:08:04 +03:00
Move debugger command parameter validation helpers into debugger_console
This commit is contained in:
parent
489bf63a89
commit
0747f93602
@ -32,7 +32,6 @@ TODO:
|
||||
|
||||
#include "emu.h"
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debugger.h"
|
||||
#include "arm7.h"
|
||||
#include "arm7core.h" //include arm7 core
|
||||
@ -876,7 +875,7 @@ void arm7_cpu_device::translate_command(const std::vector<std::string_view> &par
|
||||
{
|
||||
uint64_t vaddr;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[0], vaddr)) return;
|
||||
if (!machine().debugger().console().validate_number_parameter(params[0], vaddr)) return;
|
||||
|
||||
vaddr &= 0xffffffff;
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "acorn_memc.h"
|
||||
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#include <functional>
|
||||
@ -54,7 +53,7 @@ device_memory_interface::space_config_vector acorn_memc_device::memory_space_con
|
||||
void acorn_memc_device::memc_map_debug_commands(const std::vector<std::string_view> ¶ms)
|
||||
{
|
||||
uint64_t offset;
|
||||
if (params.size() != 1 || !machine().debugger().commands().validate_number_parameter(params[0], offset))
|
||||
if (params.size() != 1 || !machine().debugger().console().validate_number_parameter(params[0], offset))
|
||||
return;
|
||||
|
||||
// figure out the page number and offset in the page
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "cpu/sparc/sparc.h"
|
||||
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debugger.h"
|
||||
|
||||
DEFINE_DEVICE_TYPE(SUN4_MMU, sun4_mmu_device, "sun4_mmu", "Sun 4 MMU")
|
||||
@ -986,7 +985,7 @@ void sun4_mmu_base_device::l2p_command(const std::vector<std::string_view> ¶
|
||||
{
|
||||
uint64_t addr, offset;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[0], addr)) return;
|
||||
if (!machine().debugger().console().validate_number_parameter(params[0], addr)) return;
|
||||
|
||||
addr &= 0xffffffff;
|
||||
offset = addr >> 2;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,27 +24,6 @@ class debugger_commands
|
||||
public:
|
||||
debugger_commands(running_machine &machine, debugger_cpu &cpu, debugger_console &console);
|
||||
|
||||
// validates a parameter as a boolean value
|
||||
bool validate_boolean_parameter(std::string_view param, bool &result);
|
||||
|
||||
// validates a parameter as a numeric value
|
||||
bool validate_number_parameter(std::string_view param, u64 &result);
|
||||
|
||||
// validates a parameter as a device
|
||||
bool validate_device_parameter(std::string_view param, device_t *&result);
|
||||
|
||||
// validates a parameter as a CPU
|
||||
bool validate_cpu_parameter(std::string_view param, device_t *&result);
|
||||
|
||||
// validates a parameter as an address space identifier
|
||||
bool validate_device_space_parameter(std::string_view param, int spacenum, address_space *&result);
|
||||
|
||||
// validates a parameter as a target address and retrieves the given address space and address
|
||||
bool validate_target_address_parameter(std::string_view param, int spacenum, address_space *&space, u64 &addr);
|
||||
|
||||
// validates a parameter as a memory region name and retrieves the given region
|
||||
bool validate_memory_region_parameter(std::string_view param, memory_region *&result);
|
||||
|
||||
private:
|
||||
struct global_entry
|
||||
{
|
||||
@ -87,11 +66,6 @@ private:
|
||||
u8 disabled = 0U;
|
||||
};
|
||||
|
||||
device_t &get_device_search_base(std::string_view ¶m);
|
||||
device_t *get_cpu_by_index(u64 cpunum);
|
||||
bool debug_command_parameter_expression(std::string_view param, parsed_expression &result);
|
||||
bool debug_command_parameter_command(std::string_view param);
|
||||
|
||||
bool cheat_address_is_valid(address_space &space, offs_t address);
|
||||
|
||||
u64 get_cpunum();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Aaron Giles
|
||||
// copyright-holders:Aaron Giles, Vas Crabb
|
||||
/*********************************************************************
|
||||
|
||||
debugcon.cpp
|
||||
@ -198,7 +198,7 @@ void debugger_console::execute_condump(const std::vector<std::string_view>& para
|
||||
// symbol table
|
||||
//-------------------------------------------------
|
||||
|
||||
symbol_table &debugger_console::visible_symtable()
|
||||
symbol_table &debugger_console::visible_symtable() const
|
||||
{
|
||||
return m_visiblecpu->debug()->symtable();
|
||||
}
|
||||
@ -559,6 +559,494 @@ std::string debugger_console::cmderr_to_string(CMDERR error)
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// PARAMETER VALIDATION HELPERS
|
||||
//**************************************************************************
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
inline std::string_view::size_type find_delimiter(std::string_view str, T &&is_delim)
|
||||
{
|
||||
unsigned parens = 0;
|
||||
for (std::string_view::size_type i = 0; str.length() > i; ++i)
|
||||
{
|
||||
if (str[i] == '(')
|
||||
{
|
||||
++parens;
|
||||
}
|
||||
else if (parens)
|
||||
{
|
||||
if (str[i] == ')')
|
||||
--parens;
|
||||
}
|
||||
else if (is_delim(str[i]))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return std::string_view::npos;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
/// \brief Validate parameter as a Boolean value
|
||||
///
|
||||
/// Validates a parameter as a Boolean value. Fixed strings and
|
||||
/// expressions evaluating to numeric values are recognised. The result
|
||||
/// is unchanged for an empty string.
|
||||
/// \param [in] param The parameter string.
|
||||
/// \param [in,out] result The default value on entry, and the value of
|
||||
/// the parameter interpreted as a Boolean on success. Unchanged if
|
||||
/// the parameter is an empty string.
|
||||
/// \return true if the parameter is a valid Boolean value or an empty
|
||||
/// string, or false otherwise.
|
||||
bool debugger_console::validate_boolean_parameter(std::string_view param, bool &result)
|
||||
{
|
||||
// nullptr parameter does nothing and returns no error
|
||||
if (param.empty())
|
||||
return true;
|
||||
|
||||
// evaluate the expression; success if no error
|
||||
using namespace std::literals;
|
||||
bool const is_true = util::streqlower(param, "true"sv);
|
||||
bool const is_false = util::streqlower(param, "false"sv);
|
||||
|
||||
if (is_true || is_false)
|
||||
{
|
||||
result = is_true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// try to evaluate as a number
|
||||
u64 val;
|
||||
if (!validate_number_parameter(param, val))
|
||||
return false;
|
||||
|
||||
result = val != 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// \brief Validate parameter as a numeric value
|
||||
///
|
||||
/// Parses the parameter as an expression and evaluates it as a number.
|
||||
/// \param [in] param The parameter string.
|
||||
/// \param [out] result The numeric value of the expression on success.
|
||||
/// Unchanged on failure.
|
||||
/// \return true if the parameter is a valid expression that evaluates
|
||||
/// to a numeric value, or false otherwise.
|
||||
bool debugger_console::validate_number_parameter(std::string_view param, u64 &result)
|
||||
{
|
||||
// evaluate the expression; success if no error
|
||||
try
|
||||
{
|
||||
result = parsed_expression(visible_symtable(), param).execute();
|
||||
return true;
|
||||
}
|
||||
catch (expression_error const &error)
|
||||
{
|
||||
// print an error pointing to the character that caused it
|
||||
printf("Error in expression: %s\n", param);
|
||||
printf(" %*s^", error.offset(), "");
|
||||
printf("%s\n", error.code_string());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// \brief Validate parameter as a device
|
||||
///
|
||||
/// Validates a parameter as a device identifier and retrieves the
|
||||
/// device on success. A string corresponding to the tag of a device
|
||||
/// refers to that device; an empty string refers to the current CPU
|
||||
/// with debugger focus; any other string is parsed as an expression
|
||||
/// and treated as an index of a device implementing
|
||||
/// #device_execute_interface and #device_state_interface, and exposing
|
||||
/// a generic PC base value.
|
||||
/// \param [in] param The parameter string.
|
||||
/// \param [out] result A pointer to the device on success, or unchanged
|
||||
/// on failure.
|
||||
/// \return true if the parameter refers to a device in the current
|
||||
/// system, or false otherwise.
|
||||
bool debugger_console::validate_device_parameter(std::string_view param, device_t *&result)
|
||||
{
|
||||
// if no parameter, use the visible CPU
|
||||
if (param.empty())
|
||||
{
|
||||
device_t *const current = m_visiblecpu;
|
||||
if (current)
|
||||
{
|
||||
result = current;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("No valid CPU is currently selected\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// next look for a tag match
|
||||
std::string_view relative = param;
|
||||
device_t &base = get_device_search_base(relative);
|
||||
device_t *device = base.subdevice(strmakelower(relative));
|
||||
if (device)
|
||||
{
|
||||
result = device;
|
||||
return true;
|
||||
}
|
||||
|
||||
// then evaluate as an expression; on an error assume it was a tag
|
||||
u64 cpunum;
|
||||
try
|
||||
{
|
||||
cpunum = parsed_expression(visible_symtable(), param).execute();
|
||||
}
|
||||
catch (expression_error &)
|
||||
{
|
||||
printf("Unable to find device '%s'\n", param);
|
||||
return false;
|
||||
}
|
||||
|
||||
// attempt to find by numerical index
|
||||
device = get_cpu_by_index(cpunum);
|
||||
if (device)
|
||||
{
|
||||
result = device;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if out of range, complain
|
||||
printf("Invalid CPU index %u\n", cpunum);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// \brief Validate a parameter as a CPU
|
||||
///
|
||||
/// Validates a parameter as a CPU identifier. Uses the same rules as
|
||||
/// #validate_device_parameter to identify devices, but additionally
|
||||
/// checks that the device is a "CPU" for the debugger's purposes.
|
||||
/// \param [in] The parameter string.
|
||||
/// \param [out] result The device on success, or unchanged on failure.
|
||||
/// \return true if the parameter refers to a CPU-like device in the
|
||||
/// current system, or false otherwise.
|
||||
bool debugger_console::validate_cpu_parameter(std::string_view param, device_t *&result)
|
||||
{
|
||||
// first do the standard device thing
|
||||
device_t *device;
|
||||
if (!validate_device_parameter(param, device))
|
||||
return false;
|
||||
|
||||
// check that it's a "CPU" for the debugger's purposes
|
||||
device_execute_interface const *execute;
|
||||
if (device->interface(execute))
|
||||
{
|
||||
result = device;
|
||||
return true;
|
||||
}
|
||||
|
||||
printf("Device %s is not a CPU\n", device->name());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// \brief Validate a parameter as an address space identifier
|
||||
///
|
||||
/// Validates a parameter as an address space identifier. Uses the same
|
||||
/// rules as #validate_device_parameter to identify devices. If the
|
||||
/// default address space number is negative, the first address space
|
||||
/// exposed by the device will be used as the default.
|
||||
/// \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
|
||||
/// space with the lowest index) will be used as the default.
|
||||
/// \param [out] result The addresfs space on success, or unchanged on
|
||||
/// failure.
|
||||
/// \return true if the parameter refers to an address space in the
|
||||
/// current system, or false otherwise.
|
||||
bool debugger_console::validate_device_space_parameter(std::string_view param, int spacenum, address_space *&result)
|
||||
{
|
||||
device_t *device;
|
||||
std::string spacename;
|
||||
if (param.empty())
|
||||
{
|
||||
// if no parameter, use the visible CPU
|
||||
device = m_visiblecpu;
|
||||
if (!device)
|
||||
{
|
||||
printf("No valid CPU is currently selected\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// look for a tag match on the whole parameter value
|
||||
std::string_view relative = param;
|
||||
device_t &base = get_device_search_base(relative);
|
||||
device = base.subdevice(strmakelower(relative));
|
||||
|
||||
// if that failed, treat the last component as an address space
|
||||
if (!device)
|
||||
{
|
||||
auto const delimiter = relative.find_last_of(":^");
|
||||
bool const found = std::string_view::npos != delimiter;
|
||||
if (!found || (':' == relative[delimiter]))
|
||||
{
|
||||
spacename = strmakelower(relative.substr(found ? (delimiter + 1) : 0));
|
||||
relative = relative.substr(0, !found ? 0 : !delimiter ? 1 : delimiter);
|
||||
if (!relative.empty())
|
||||
device = base.subdevice(strmakelower(relative));
|
||||
else if (m_visiblecpu)
|
||||
device = m_visiblecpu;
|
||||
else
|
||||
device = &m_machine.root_device();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if still no device found, evaluate as an expression
|
||||
if (!device)
|
||||
{
|
||||
u64 cpunum;
|
||||
try
|
||||
{
|
||||
cpunum = parsed_expression(visible_symtable(), param).execute();
|
||||
}
|
||||
catch (expression_error const &)
|
||||
{
|
||||
// parsing failed - assume it was a tag
|
||||
printf("Unable to find device '%s'\n", param);
|
||||
return false;
|
||||
}
|
||||
|
||||
// attempt to find by numerical index
|
||||
device = get_cpu_by_index(cpunum);
|
||||
if (!device)
|
||||
{
|
||||
// if out of range, complain
|
||||
printf("Invalid CPU index %u\n", cpunum);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ensure the device implements the memory interface
|
||||
device_memory_interface *memory;
|
||||
if (!device->interface(memory))
|
||||
{
|
||||
printf("No memory interface found for device %s\n", device->name());
|
||||
return false;
|
||||
}
|
||||
|
||||
// fall back to supplied default space if appropriate
|
||||
if (spacename.empty() && (0 <= spacenum))
|
||||
{
|
||||
if (memory->has_space(spacenum))
|
||||
{
|
||||
result = &memory->space(spacenum);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("No matching memory space found for device '%s'\n", device->tag());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise find the specified space or fall back to the first populated space
|
||||
for (int i = 0; memory->max_space_count() > i; ++i)
|
||||
{
|
||||
if (memory->has_space(i) && (spacename.empty() || (memory->space(i).name() == spacename)))
|
||||
{
|
||||
result = &memory->space(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// report appropriate error message
|
||||
if (spacename.empty())
|
||||
printf("No memory spaces found for device '%s'\n", device->tag());
|
||||
else
|
||||
printf("Memory space '%s' not found found for device '%s'\n", spacename, device->tag());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// \brief Validate a parameter as a target address
|
||||
///
|
||||
/// Validates a parameter as an numeric expression to use as an address
|
||||
/// 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.
|
||||
/// \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
|
||||
/// space with the lowest index) will be used as the default.
|
||||
/// \param [out] space The address space on success, or unchanged on
|
||||
/// failure.
|
||||
/// \param [out] addr The address on success, or unchanged on failure.
|
||||
/// \return true if the address is a valid expression evaluating to a
|
||||
/// number and the address space is found, or false otherwise.
|
||||
bool debugger_console::validate_target_address_parameter(std::string_view param, int spacenum, address_space *&space, u64 &addr)
|
||||
{
|
||||
// check for the device delimiter
|
||||
std::string_view::size_type const devdelim = find_delimiter(param, [] (char ch) { return ':' == ch; });
|
||||
std::string_view device;
|
||||
if (devdelim != std::string::npos)
|
||||
device = param.substr(devdelim + 1);
|
||||
|
||||
// parse the address first
|
||||
u64 addrval;
|
||||
if (!validate_number_parameter(param.substr(0, devdelim), addrval))
|
||||
return false;
|
||||
|
||||
// find the address space
|
||||
if (!validate_device_space_parameter(device, spacenum, space))
|
||||
return false;
|
||||
|
||||
// set the address now that we have the space
|
||||
addr = addrval;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// \brief Validate a parameter as a memory region
|
||||
///
|
||||
/// Validates a parameter as a memory region tag and retrieves the
|
||||
/// specified memory region.
|
||||
/// \param [in] The parameter string.
|
||||
/// \param [out] result The memory region 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_memory_region_parameter(std::string_view param, memory_region *&result)
|
||||
{
|
||||
auto const ®ions = m_machine.memory().regions();
|
||||
std::string_view relative = param;
|
||||
device_t &base = get_device_search_base(relative);
|
||||
auto const iter = regions.find(base.subtag(strmakelower(relative)));
|
||||
if (regions.end() != iter)
|
||||
{
|
||||
result = iter->second.get();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("No matching memory region 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
|
||||
/// interpreted relative to the selected CPU. Removes the recognised
|
||||
/// prefixes from the parameter value.
|
||||
/// \param [in,out] param The parameter string. Recognised prefixes
|
||||
/// affecting the search base are removed, leaving a tag relative to
|
||||
/// the base device.
|
||||
/// \return A reference to the base device that the tag should be
|
||||
/// interpreted relative to.
|
||||
device_t &debugger_console::get_device_search_base(std::string_view ¶m) const
|
||||
{
|
||||
if (!param.empty())
|
||||
{
|
||||
// handle ".:" or ".^" prefix for tag relative to current CPU if any
|
||||
if (('.' == param[0]) && ((param.size() == 1) || (':' == param[1]) || ('^' == param[1])))
|
||||
{
|
||||
param.remove_prefix(((param.size() > 1) && (':' == param[1])) ? 2 : 1);
|
||||
device_t *const current = m_visiblecpu;
|
||||
return current ? *current : m_machine.root_device();
|
||||
}
|
||||
|
||||
// a sibling path makes most sense relative to current CPU
|
||||
if ('^' == param[0])
|
||||
{
|
||||
device_t *const current = m_visiblecpu;
|
||||
return current ? *current : m_machine.root_device();
|
||||
}
|
||||
}
|
||||
|
||||
// default to root device
|
||||
return m_machine.root_device();
|
||||
}
|
||||
|
||||
|
||||
/// \brief Get CPU by index
|
||||
///
|
||||
/// Looks up a CPU by the number the debugger assigns it based on its
|
||||
/// position in the device tree relative to other CPUs.
|
||||
/// \param [in] cpunum Zero-based index of the CPU to find.
|
||||
/// \return A pointer to the CPU if found, or \c nullptr if no CPU has
|
||||
/// the specified index.
|
||||
device_t *debugger_console::get_cpu_by_index(u64 cpunum) const
|
||||
{
|
||||
unsigned index = 0;
|
||||
for (device_execute_interface &exec : execute_interface_enumerator(m_machine.root_device()))
|
||||
{
|
||||
// real CPUs should have pcbase
|
||||
device_state_interface const *state;
|
||||
if (exec.device().interface(state) && state->state_find_entry(STATE_GENPCBASE))
|
||||
{
|
||||
if (index++ == cpunum)
|
||||
{
|
||||
return &exec.device();
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// validate_expression_parameter - validates
|
||||
// an expression parameter
|
||||
//-----------------------------------------------*/
|
||||
|
||||
bool debugger_console::validate_expression_parameter(std::string_view param, parsed_expression &result)
|
||||
{
|
||||
try
|
||||
{
|
||||
// parse the expression; success if no error
|
||||
result.parse(param);
|
||||
return true;
|
||||
}
|
||||
catch (expression_error const &err)
|
||||
{
|
||||
// output an error
|
||||
printf("Error in expression: %s\n", param);
|
||||
printf(" %*s^", err.offset(), "");
|
||||
printf("%s\n", err.code_string());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// validate_command_parameter - validates a
|
||||
// command parameter
|
||||
//-------------------------------------------------
|
||||
|
||||
bool debugger_console::validate_command_parameter(std::string_view param)
|
||||
{
|
||||
// validate the comment; success if no error
|
||||
CMDERR err = validate_command(param);
|
||||
if (err.error_class() == CMDERR::NONE)
|
||||
return true;
|
||||
|
||||
// output an error
|
||||
printf("Error in command: %s\n", param);
|
||||
printf(" %*s^", err.error_offset(), "");
|
||||
printf("%s\n", cmderr_to_string(err));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
|
@ -110,12 +110,39 @@ public:
|
||||
vprintf_wrap(wrapcol, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
|
||||
}
|
||||
|
||||
device_t *get_visible_cpu() { return m_visiblecpu; }
|
||||
device_t *get_visible_cpu() const { return m_visiblecpu; }
|
||||
void set_visible_cpu(device_t *visiblecpu) { m_visiblecpu = visiblecpu; }
|
||||
symbol_table &visible_symtable();
|
||||
symbol_table &visible_symtable() const;
|
||||
|
||||
static std::string cmderr_to_string(CMDERR error);
|
||||
|
||||
// validates a parameter as a boolean value
|
||||
bool validate_boolean_parameter(std::string_view param, bool &result);
|
||||
|
||||
// validates a parameter as a numeric value
|
||||
bool validate_number_parameter(std::string_view param, u64 &result);
|
||||
|
||||
// validates a parameter as a device
|
||||
bool validate_device_parameter(std::string_view param, device_t *&result);
|
||||
|
||||
// validates a parameter as a CPU
|
||||
bool validate_cpu_parameter(std::string_view param, device_t *&result);
|
||||
|
||||
// validates a parameter as an address space identifier
|
||||
bool validate_device_space_parameter(std::string_view param, int spacenum, address_space *&result);
|
||||
|
||||
// validates a parameter as a target address and retrieves the given address space and address
|
||||
bool validate_target_address_parameter(std::string_view param, int spacenum, address_space *&space, u64 &addr);
|
||||
|
||||
// validates a parameter as a memory region name and retrieves the given region
|
||||
bool validate_memory_region_parameter(std::string_view param, memory_region *&result);
|
||||
|
||||
// validates a parameter as a debugger expression
|
||||
bool validate_expression_parameter(std::string_view param, parsed_expression &result);
|
||||
|
||||
// validates a parameter as a debugger command
|
||||
bool validate_command_parameter(std::string_view param);
|
||||
|
||||
private:
|
||||
void exit();
|
||||
|
||||
@ -129,6 +156,9 @@ private:
|
||||
void print_core(std::string_view text); // core text output
|
||||
void print_core_wrap(std::string_view text, int wrapcol); // core text output
|
||||
|
||||
device_t &get_device_search_base(std::string_view ¶m) const;
|
||||
device_t *get_cpu_by_index(u64 cpunum) const;
|
||||
|
||||
struct debug_command
|
||||
{
|
||||
debug_command(std::string_view _command, u32 _flags, int _minparams, int _maxparams, std::function<void (const std::vector<std::string_view> &)> &&_handler);
|
||||
|
@ -227,7 +227,6 @@ Notes:
|
||||
#include "sound/ymz280b.h"
|
||||
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debugger.h"
|
||||
#include "romload.h"
|
||||
#include "screen.h"
|
||||
@ -1553,7 +1552,7 @@ void konamim2_state::dump_task_command(const std::vector<std::string_view> ¶
|
||||
if (params.size() < 1)
|
||||
return;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
address = (offs_t)addr;
|
||||
|
@ -17,9 +17,6 @@
|
||||
#include "bus/ata/atapicdr.h"
|
||||
#include "bus/ata/idehd.h"
|
||||
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debug/debugcon.h"
|
||||
#include "debugger.h"
|
||||
#include "speaker.h"
|
||||
|
||||
#include "bitmap.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "midtview.ipp"
|
||||
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#include "emuopts.h" // Used by PNG logging
|
||||
@ -115,7 +114,7 @@ void midtunit_video_device::debug_png_dma_command(const std::vector<std::string_
|
||||
|
||||
bool old_state = m_log_png;
|
||||
bool new_state = false;
|
||||
if (!machine().debugger().commands().validate_boolean_parameter(params[1], new_state))
|
||||
if (!con.validate_boolean_parameter(params[1], new_state))
|
||||
return;
|
||||
|
||||
if (!new_state)
|
||||
@ -145,7 +144,7 @@ void midtunit_video_device::debug_png_dma_command(const std::vector<std::string_
|
||||
|
||||
if (params.size() == 4)
|
||||
{
|
||||
if (!machine().debugger().commands().validate_boolean_parameter(params[3], m_log_json))
|
||||
if (!con.validate_boolean_parameter(params[3], m_log_json))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "rmnimbus.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debug/debugcon.h"
|
||||
|
||||
#include <functional>
|
||||
@ -629,7 +628,7 @@ void rmnimbus_state::video_debug(const std::vector<std::string_view> ¶ms)
|
||||
if (params.size() > 0)
|
||||
{
|
||||
uint64_t temp;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[0], temp))
|
||||
if (!machine().debugger().console().validate_number_parameter(params[0], temp))
|
||||
return;
|
||||
m_debug_video = temp;
|
||||
}
|
||||
|
@ -442,7 +442,6 @@ Thanks to Alex, Mr Mudkips, and Philip Burke for this info.
|
||||
#include "machine/jvshost.h"
|
||||
#include "naomigd.h"
|
||||
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debug/debugcon.h"
|
||||
#include "debugger.h"
|
||||
|
||||
@ -787,9 +786,9 @@ void chihiro_state::jamtable_disasm_command(const std::vector<std::string_view>
|
||||
|
||||
if (params.size() < 3)
|
||||
return;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!machine().debugger().console().validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[2], size))
|
||||
if (!machine().debugger().console().validate_number_parameter(params[2], size))
|
||||
return;
|
||||
jamtable_disasm(space, (uint32_t)addr, (uint32_t)size);
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "model2.h"
|
||||
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#include <fstream>
|
||||
|
@ -10,9 +10,8 @@
|
||||
#include "machine/idectrl.h"
|
||||
|
||||
#include "cpu/i386/i386.h"
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
|
||||
#include "debug/debugcon.h"
|
||||
#include "debugger.h"
|
||||
#include "romload.h"
|
||||
#include "screen.h"
|
||||
@ -94,7 +93,7 @@ void xbox_base_state::dump_string_command(const std::vector<std::string_view> &p
|
||||
if (params.size() < 2)
|
||||
return;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
address = (offs_t)addr;
|
||||
@ -136,7 +135,7 @@ void xbox_base_state::dump_process_command(const std::vector<std::string_view> &
|
||||
if (params.size() < 2)
|
||||
return;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
address = (offs_t)addr;
|
||||
@ -166,14 +165,14 @@ void xbox_base_state::dump_list_command(const std::vector<std::string_view> &par
|
||||
if (params.size() < 2)
|
||||
return;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
uint64_t offs = 0;
|
||||
offs_t offset = 0;
|
||||
if (params.size() >= 3)
|
||||
{
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[2], offs))
|
||||
if (!con.validate_number_parameter(params[2], offs))
|
||||
return;
|
||||
offset = (offs_t)offs;
|
||||
}
|
||||
@ -219,7 +218,7 @@ void xbox_base_state::dump_dpc_command(const std::vector<std::string_view> ¶
|
||||
if (params.size() < 2)
|
||||
return;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
address = (offs_t)addr;
|
||||
@ -248,7 +247,7 @@ void xbox_base_state::dump_timer_command(const std::vector<std::string_view> &pa
|
||||
if (params.size() < 2)
|
||||
return;
|
||||
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
address = (offs_t)addr;
|
||||
@ -304,8 +303,8 @@ void xbox_base_state::curthread_command(const std::vector<std::string_view> &par
|
||||
|
||||
void xbox_base_state::threadlist_command(const std::vector<std::string_view> ¶ms)
|
||||
{
|
||||
address_space &space = m_maincpu->space();
|
||||
debugger_console &con = machine().debugger().console();
|
||||
address_space &space = m_maincpu->space();
|
||||
|
||||
con.printf("Pri. _KTHREAD Stack Function\n");
|
||||
con.printf("-------------------------------\n");
|
||||
@ -347,7 +346,7 @@ void xbox_base_state::generate_irq_command(const std::vector<std::string_view> &
|
||||
|
||||
if (params.size() < 2)
|
||||
return;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], irq))
|
||||
if (!machine().debugger().console().validate_number_parameter(params[1], irq))
|
||||
return;
|
||||
if (irq > 15)
|
||||
return;
|
||||
@ -392,7 +391,7 @@ void xbox_base_state::grab_texture_command(const std::vector<std::string_view> &
|
||||
|
||||
if (params.size() < 3)
|
||||
return;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], type))
|
||||
if (!machine().debugger().console().validate_number_parameter(params[1], type))
|
||||
return;
|
||||
if (params[2].empty() || params[2].length() > 127)
|
||||
return;
|
||||
@ -422,22 +421,23 @@ void xbox_base_state::grab_vprog_command(const std::vector<std::string_view> &pa
|
||||
|
||||
void xbox_base_state::vprogdis_command(const std::vector<std::string_view> ¶ms)
|
||||
{
|
||||
debugger_console &con = machine().debugger().console();
|
||||
address_space &space = m_maincpu->space();
|
||||
|
||||
if (params.size() < 3)
|
||||
return;
|
||||
|
||||
uint64_t addr;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
uint64_t length;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[2], length))
|
||||
if (!con.validate_number_parameter(params[2], length))
|
||||
return;
|
||||
|
||||
uint64_t type = 0;
|
||||
if (params.size() > 3)
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[3], type))
|
||||
if (!con.validate_number_parameter(params[3], type))
|
||||
return;
|
||||
|
||||
vertex_program_disassembler vd;
|
||||
@ -461,7 +461,7 @@ void xbox_base_state::vprogdis_command(const std::vector<std::string_view> ¶
|
||||
|
||||
char line[64];
|
||||
while (vd.disassemble(instruction, line) != 0)
|
||||
machine().debugger().console().printf("%s\n", line);
|
||||
con.printf("%s\n", line);
|
||||
|
||||
if (type == 1)
|
||||
addr = addr + 4 * 4;
|
||||
@ -474,16 +474,16 @@ void xbox_base_state::vprogdis_command(const std::vector<std::string_view> ¶
|
||||
|
||||
void xbox_base_state::vdeclaration_command(const std::vector<std::string_view> ¶ms)
|
||||
{
|
||||
debugger_console &con = machine().debugger().console();
|
||||
address_space &space = m_maincpu->space();
|
||||
|
||||
if (params.size() < 1)
|
||||
return;
|
||||
|
||||
uint64_t addr;
|
||||
if (!machine().debugger().commands().validate_number_parameter(params[1], addr))
|
||||
if (!con.validate_number_parameter(params[1], addr))
|
||||
return;
|
||||
|
||||
debugger_console &con = machine().debugger().console();
|
||||
for (int n = 128; n > 0; n--)
|
||||
{
|
||||
offs_t address = (offs_t)addr;
|
||||
|
@ -432,7 +432,6 @@
|
||||
#include "machine/z80scc.h"
|
||||
|
||||
#include "debug/debugcon.h"
|
||||
#include "debug/debugcmd.h"
|
||||
#include "debugger.h"
|
||||
#include "screen.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user