mirror of
https://github.com/holub/mame
synced 2025-07-01 08:18:59 +03:00
Merge pull request #544 from ajrhacker/master
Allow mame -validate -verbose to capture verbose messages [ajrhacker]
This commit is contained in:
commit
51b30c9d23
@ -1612,7 +1612,7 @@ void cli_frontend::execute_commands(const char *exename)
|
|||||||
validity_checker valid(m_options);
|
validity_checker valid(m_options);
|
||||||
bool result = valid.check_all();
|
bool result = valid.check_all();
|
||||||
if (!result)
|
if (!result)
|
||||||
throw emu_fatalerror(MAMERR_FAILED_VALIDITY, "Validity check failed!\n");
|
throw emu_fatalerror(MAMERR_FAILED_VALIDITY, "Validity check failed (%d errors, %d warnings in total)\n", valid.errors(), valid.warnings());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ int machine_manager::execute()
|
|||||||
if (system != nullptr)
|
if (system != nullptr)
|
||||||
{
|
{
|
||||||
validity_checker valid(m_options);
|
validity_checker valid(m_options);
|
||||||
|
valid.set_verbose(false);
|
||||||
valid.check_shared_source(*system);
|
valid.check_shared_source(*system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ validity_checker::validity_checker(emu_options &options)
|
|||||||
: m_drivlist(options),
|
: m_drivlist(options),
|
||||||
m_errors(0),
|
m_errors(0),
|
||||||
m_warnings(0),
|
m_warnings(0),
|
||||||
|
m_print_verbose(options.verbose()),
|
||||||
m_current_driver(nullptr),
|
m_current_driver(nullptr),
|
||||||
m_current_config(nullptr),
|
m_current_config(nullptr),
|
||||||
m_current_device(nullptr),
|
m_current_device(nullptr),
|
||||||
@ -194,19 +195,15 @@ bool validity_checker::check_all()
|
|||||||
validate_inlines();
|
validate_inlines();
|
||||||
|
|
||||||
// if we had warnings or errors, output
|
// if we had warnings or errors, output
|
||||||
if (m_errors > 0 || m_warnings > 0)
|
if (m_errors > 0 || m_warnings > 0 || !m_verbose_text.empty())
|
||||||
{
|
{
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Core: %d errors, %d warnings\n", m_errors, m_warnings);
|
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Core: %d errors, %d warnings\n", m_errors, m_warnings);
|
||||||
if (m_errors > 0)
|
if (m_errors > 0)
|
||||||
{
|
output_indented_errors(m_error_text, "Errors");
|
||||||
strreplace(m_error_text, "\n", "\n ");
|
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Errors:\n %s", m_error_text.c_str());
|
|
||||||
}
|
|
||||||
if (m_warnings > 0)
|
if (m_warnings > 0)
|
||||||
{
|
output_indented_errors(m_warning_text, "Warnings");
|
||||||
strreplace(m_warning_text, "\n", "\n ");
|
if (!m_verbose_text.empty())
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Warnings:\n %s", m_warning_text.c_str());
|
output_indented_errors(m_verbose_text, "Messages");
|
||||||
}
|
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "\n");
|
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,6 +274,7 @@ void validity_checker::validate_one(const game_driver &driver)
|
|||||||
int start_warnings = m_warnings;
|
int start_warnings = m_warnings;
|
||||||
m_error_text.clear();
|
m_error_text.clear();
|
||||||
m_warning_text.clear();
|
m_warning_text.clear();
|
||||||
|
m_verbose_text.clear();
|
||||||
|
|
||||||
// wrap in try/except to catch fatalerrors
|
// wrap in try/except to catch fatalerrors
|
||||||
try
|
try
|
||||||
@ -295,20 +293,16 @@ void validity_checker::validate_one(const game_driver &driver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we had warnings or errors, output
|
// if we had warnings or errors, output
|
||||||
if (m_errors > start_errors || m_warnings > start_warnings)
|
if (m_errors > start_errors || m_warnings > start_warnings || !m_verbose_text.empty())
|
||||||
{
|
{
|
||||||
std::string tempstr;
|
std::string tempstr;
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Driver %s (file %s): %d errors, %d warnings\n", driver.name, core_filename_extract_base(tempstr, driver.source_file).c_str(), m_errors - start_errors, m_warnings - start_warnings);
|
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Driver %s (file %s): %d errors, %d warnings\n", driver.name, core_filename_extract_base(tempstr, driver.source_file).c_str(), m_errors - start_errors, m_warnings - start_warnings);
|
||||||
if (m_errors > start_errors)
|
if (m_errors > start_errors)
|
||||||
{
|
output_indented_errors(m_error_text, "Errors");
|
||||||
strreplace(m_error_text, "\n", "\n ");
|
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Errors:\n %s", m_error_text.c_str());
|
|
||||||
}
|
|
||||||
if (m_warnings > start_warnings)
|
if (m_warnings > start_warnings)
|
||||||
{
|
output_indented_errors(m_warning_text, "Warnings");
|
||||||
strreplace(m_warning_text, "\n", "\n ");
|
if (!m_verbose_text.empty())
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Warnings:\n %s", m_warning_text.c_str());
|
output_indented_errors(m_verbose_text, "Messages");
|
||||||
}
|
|
||||||
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "\n");
|
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,8 +609,8 @@ void validity_checker::validate_roms()
|
|||||||
device_iterator deviter(m_current_config->root_device());
|
device_iterator deviter(m_current_config->root_device());
|
||||||
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
|
for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
|
||||||
{
|
{
|
||||||
// for non-root devices, track the current device
|
// track the current device
|
||||||
m_current_device = (device->owner() == nullptr) ? nullptr : device;
|
m_current_device = device;
|
||||||
|
|
||||||
// scan the ROM entries for this device
|
// scan the ROM entries for this device
|
||||||
const char *last_region_name = "???";
|
const char *last_region_name = "???";
|
||||||
@ -880,8 +874,8 @@ void validity_checker::validate_inputs()
|
|||||||
if (device->input_ports() == nullptr)
|
if (device->input_ports() == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// for non-root devices, track the current device
|
// track the current device
|
||||||
m_current_device = (device == &m_current_config->root_device()) ? nullptr : device;
|
m_current_device = device;
|
||||||
|
|
||||||
// allocate the input ports
|
// allocate the input ports
|
||||||
ioport_list portlist;
|
ioport_list portlist;
|
||||||
@ -983,8 +977,8 @@ void validity_checker::validate_devices()
|
|||||||
device_iterator iter(m_current_config->root_device());
|
device_iterator iter(m_current_config->root_device());
|
||||||
for (const device_t *device = iter.first(); device != nullptr; device = iter.next())
|
for (const device_t *device = iter.first(); device != nullptr; device = iter.next())
|
||||||
{
|
{
|
||||||
// for non-root devices, track the current device
|
// track the current device
|
||||||
m_current_device = (device == &m_current_config->root_device()) ? nullptr : device;
|
m_current_device = device;
|
||||||
|
|
||||||
// validate the device tag
|
// validate the device tag
|
||||||
validate_tag(device->basetag());
|
validate_tag(device->basetag());
|
||||||
@ -1048,9 +1042,9 @@ void validity_checker::build_output_prefix(std::string &str)
|
|||||||
// start empty
|
// start empty
|
||||||
str.clear();
|
str.clear();
|
||||||
|
|
||||||
// if we have a current device, indicate that
|
// if we have a current (non-root) device, indicate that
|
||||||
if (m_current_device != nullptr)
|
if (m_current_device != nullptr && m_current_device->owner() != nullptr)
|
||||||
str.append(m_current_device->name()).append(" device '").append(m_current_device->tag()).append("': ");
|
str.append(m_current_device->name()).append(" device '").append(m_current_device->tag()+1).append("': ");
|
||||||
|
|
||||||
// if we have a current port, indicate that as well
|
// if we have a current port, indicate that as well
|
||||||
if (m_current_ioport != nullptr)
|
if (m_current_ioport != nullptr)
|
||||||
@ -1089,6 +1083,17 @@ void validity_checker::output_callback(osd_output_channel channel, const char *m
|
|||||||
strcatvprintf(output, msg, args);
|
strcatvprintf(output, msg, args);
|
||||||
m_warning_text.append(output);
|
m_warning_text.append(output);
|
||||||
break;
|
break;
|
||||||
|
case OSD_OUTPUT_CHANNEL_VERBOSE:
|
||||||
|
// if we're not verbose, skip it
|
||||||
|
if (!m_print_verbose) break;
|
||||||
|
|
||||||
|
// output the source(driver) device 'tag'
|
||||||
|
build_output_prefix(output);
|
||||||
|
|
||||||
|
// generate the string and output to the original target
|
||||||
|
strcatvprintf(output, msg, args);
|
||||||
|
m_verbose_text.append(output);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
chain_output(channel, msg, args);
|
chain_output(channel, msg, args);
|
||||||
break;
|
break;
|
||||||
@ -1110,3 +1115,16 @@ void validity_checker::output_via_delegate(osd_output_channel channel, const cha
|
|||||||
this->chain_output(channel, format, argptr);
|
this->chain_output(channel, format, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// output_indented_errors - helper to output error
|
||||||
|
// and warning messages with header and indents
|
||||||
|
//-------------------------------------------------
|
||||||
|
void validity_checker::output_indented_errors(std::string &text, const char *header)
|
||||||
|
{
|
||||||
|
// remove trailing newline
|
||||||
|
if (text[text.size()-1] == '\n')
|
||||||
|
text.erase(text.size()-1, 1);
|
||||||
|
strreplace(text, "\n", "\n ");
|
||||||
|
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "%s:\n %s\n", header, text.c_str());
|
||||||
|
}
|
||||||
|
@ -40,6 +40,9 @@ public:
|
|||||||
int errors() const { return m_errors; }
|
int errors() const { return m_errors; }
|
||||||
int warnings() const { return m_warnings; }
|
int warnings() const { return m_warnings; }
|
||||||
|
|
||||||
|
// setter
|
||||||
|
void set_verbose(bool verbose) { m_print_verbose = verbose; }
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
void check_driver(const game_driver &driver);
|
void check_driver(const game_driver &driver);
|
||||||
void check_shared_source(const game_driver &driver);
|
void check_shared_source(const game_driver &driver);
|
||||||
@ -81,6 +84,7 @@ private:
|
|||||||
// output helpers
|
// output helpers
|
||||||
void build_output_prefix(std::string &str);
|
void build_output_prefix(std::string &str);
|
||||||
void output_via_delegate(osd_output_channel channel, const char *format, ...) ATTR_PRINTF(3,4);
|
void output_via_delegate(osd_output_channel channel, const char *format, ...) ATTR_PRINTF(3,4);
|
||||||
|
void output_indented_errors(std::string &text, const char *header);
|
||||||
|
|
||||||
// internal driver list
|
// internal driver list
|
||||||
driver_enumerator m_drivlist;
|
driver_enumerator m_drivlist;
|
||||||
@ -88,8 +92,10 @@ private:
|
|||||||
// error tracking
|
// error tracking
|
||||||
int m_errors;
|
int m_errors;
|
||||||
int m_warnings;
|
int m_warnings;
|
||||||
|
bool m_print_verbose;
|
||||||
std::string m_error_text;
|
std::string m_error_text;
|
||||||
std::string m_warning_text;
|
std::string m_warning_text;
|
||||||
|
std::string m_verbose_text;
|
||||||
|
|
||||||
// maps for finding duplicates
|
// maps for finding duplicates
|
||||||
game_driver_map m_names_map;
|
game_driver_map m_names_map;
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
#include "osdepend.h"
|
#include "osdepend.h"
|
||||||
#include "modules/lib/osdobj_common.h"
|
#include "modules/lib/osdobj_common.h"
|
||||||
|
|
||||||
extern bool g_print_verbose;
|
|
||||||
|
|
||||||
const options_entry osd_options::s_option_entries[] =
|
const options_entry osd_options::s_option_entries[] =
|
||||||
{
|
{
|
||||||
{ NULL, NULL, OPTION_HEADER, "OSD KEYBOARD MAPPING OPTIONS" },
|
{ NULL, NULL, OPTION_HEADER, "OSD KEYBOARD MAPPING OPTIONS" },
|
||||||
@ -155,6 +153,7 @@ osd_options::osd_options()
|
|||||||
osd_common_t::osd_common_t(osd_options &options)
|
osd_common_t::osd_common_t(osd_options &options)
|
||||||
: osd_output(), m_machine(NULL),
|
: osd_output(), m_machine(NULL),
|
||||||
m_options(options),
|
m_options(options),
|
||||||
|
m_print_verbose(false),
|
||||||
m_sound(NULL),
|
m_sound(NULL),
|
||||||
m_debugger(NULL)
|
m_debugger(NULL)
|
||||||
{
|
{
|
||||||
@ -278,10 +277,12 @@ void osd_common_t::output_callback(osd_output_channel channel, const char *msg,
|
|||||||
vfprintf(stderr, msg, args);
|
vfprintf(stderr, msg, args);
|
||||||
break;
|
break;
|
||||||
case OSD_OUTPUT_CHANNEL_INFO:
|
case OSD_OUTPUT_CHANNEL_INFO:
|
||||||
case OSD_OUTPUT_CHANNEL_VERBOSE:
|
|
||||||
case OSD_OUTPUT_CHANNEL_LOG:
|
case OSD_OUTPUT_CHANNEL_LOG:
|
||||||
vfprintf(stdout, msg, args);
|
vfprintf(stdout, msg, args);
|
||||||
break;
|
break;
|
||||||
|
case OSD_OUTPUT_CHANNEL_VERBOSE:
|
||||||
|
if (verbose()) vfprintf(stdout, msg, args);
|
||||||
|
break;
|
||||||
case OSD_OUTPUT_CHANNEL_DEBUG:
|
case OSD_OUTPUT_CHANNEL_DEBUG:
|
||||||
#ifdef MAME_DEBUG
|
#ifdef MAME_DEBUG
|
||||||
vfprintf(stdout, msg, args);
|
vfprintf(stdout, msg, args);
|
||||||
@ -333,7 +334,7 @@ void osd_common_t::init(running_machine &machine)
|
|||||||
osd_options &options = downcast<osd_options &>(machine.options());
|
osd_options &options = downcast<osd_options &>(machine.options());
|
||||||
// extract the verbose printing option
|
// extract the verbose printing option
|
||||||
if (options.verbose())
|
if (options.verbose())
|
||||||
g_print_verbose = true;
|
set_verbose(true);
|
||||||
|
|
||||||
// ensure we get called on the way out
|
// ensure we get called on the way out
|
||||||
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this));
|
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this));
|
||||||
|
@ -202,7 +202,6 @@ public:
|
|||||||
// getters
|
// getters
|
||||||
running_machine &machine() { assert(m_machine != nullptr); return *m_machine; }
|
running_machine &machine() { assert(m_machine != nullptr); return *m_machine; }
|
||||||
|
|
||||||
|
|
||||||
virtual void debugger_update();
|
virtual void debugger_update();
|
||||||
|
|
||||||
virtual void init_subsystems();
|
virtual void init_subsystems();
|
||||||
@ -228,6 +227,8 @@ public:
|
|||||||
|
|
||||||
// osd_output interface ...
|
// osd_output interface ...
|
||||||
virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override;
|
virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override;
|
||||||
|
bool verbose() const { return m_print_verbose; }
|
||||||
|
void set_verbose(bool print_verbose) { m_print_verbose = print_verbose; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool input_init();
|
virtual bool input_init();
|
||||||
@ -238,6 +239,8 @@ private:
|
|||||||
running_machine * m_machine;
|
running_machine * m_machine;
|
||||||
osd_options& m_options;
|
osd_options& m_options;
|
||||||
|
|
||||||
|
bool m_print_verbose;
|
||||||
|
|
||||||
osd_module_manager m_mod_man;
|
osd_module_manager m_mod_man;
|
||||||
font_module *m_font_module;
|
font_module *m_font_module;
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "osdcore.h"
|
#include "osdcore.h"
|
||||||
|
|
||||||
bool g_print_verbose = false;
|
|
||||||
|
|
||||||
static const int MAXSTACK = 10;
|
static const int MAXSTACK = 10;
|
||||||
static osd_output *m_stack[MAXSTACK];
|
static osd_output *m_stack[MAXSTACK];
|
||||||
static int m_ptr = -1;
|
static int m_ptr = -1;
|
||||||
@ -104,10 +102,6 @@ void CLIB_DECL osd_printf_verbose(const char *format, ...)
|
|||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
|
||||||
/* if we're not verbose, skip it */
|
|
||||||
if (!g_print_verbose)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* do the output */
|
/* do the output */
|
||||||
va_start(argptr, format);
|
va_start(argptr, format);
|
||||||
if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_VERBOSE, format, argptr);
|
if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_VERBOSE, format, argptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user