distate: don't try to read unused value() during formatstr

This commit is contained in:
hap 2023-01-02 01:08:01 +01:00
parent 2bfe2358fb
commit 47a484001c
4 changed files with 15 additions and 18 deletions

View File

@ -341,7 +341,7 @@ void tms99xx_device::state_import(const device_state_entry &entry)
break; break;
default: default:
// Workspace registers // Workspace registers
if (index <= TMS9900_R15 && started()) if (index <= TMS9900_R15)
write_workspace_register_debug(index-TMS9900_R0, (uint16_t)m_state_any); write_workspace_register_debug(index-TMS9900_R0, (uint16_t)m_state_any);
break; break;
} }
@ -373,7 +373,7 @@ void tms99xx_device::state_export(const device_state_entry &entry)
default: default:
// Workspace registers // Workspace registers
if (index <= TMS9900_R15) if (index <= TMS9900_R15)
m_state_any = started() ? read_workspace_register_debug(index-TMS9900_R0) : 0; m_state_any = read_workspace_register_debug(index-TMS9900_R0);
break; break;
} }
} }

View File

@ -339,7 +339,7 @@ void tms9995_device::state_import(const device_state_entry &entry)
break; break;
default: default:
// Workspace registers // Workspace registers
if (index <= TMS9995_R15 && started()) if (index <= TMS9995_R15)
write_workspace_register_debug(index-TMS9995_R0, (uint16_t)m_state_any); write_workspace_register_debug(index-TMS9995_R0, (uint16_t)m_state_any);
break; break;
} }
@ -371,7 +371,7 @@ void tms9995_device::state_export(const device_state_entry &entry)
default: default:
// Workspace registers // Workspace registers
if (index <= TMS9995_R15) if (index <= TMS9995_R15)
m_state_any = started() ? read_workspace_register_debug(index-TMS9995_R0) : 0; m_state_any = read_workspace_register_debug(index-TMS9995_R0);
break; break;
} }
} }

View File

@ -101,7 +101,7 @@ device_state_entry &device_state_entry::formatstr(const char *_format)
// set the DSF_CUSTOM_STRING flag by formatting with a nullptr string // set the DSF_CUSTOM_STRING flag by formatting with a nullptr string
m_flags &= ~DSF_CUSTOM_STRING; m_flags &= ~DSF_CUSTOM_STRING;
format(nullptr); format(nullptr, 0);
return *this; return *this;
} }
@ -201,12 +201,10 @@ double device_state_entry::entry_dvalue() const
// pieces of indexed state as a string // pieces of indexed state as a string
//------------------------------------------------- //-------------------------------------------------
std::string device_state_entry::format(const char *string, bool maxout) const std::string device_state_entry::format(const char *string, u64 result, bool maxout) const
{ {
std::string dest;
u64 result = value();
// parse the format // parse the format
std::string dest;
bool leadzero = false; bool leadzero = false;
bool percent = false; bool percent = false;
bool explicitsign = false; bool explicitsign = false;
@ -400,7 +398,7 @@ std::string device_state_entry::to_string() const
custom = string_format("%-12G", entry_dvalue()); custom = string_format("%-12G", entry_dvalue());
// ask the entry to format itself // ask the entry to format itself
return format(custom.c_str()); return format(custom.c_str(), value());
} }
@ -412,7 +410,7 @@ std::string device_state_entry::to_string() const
int device_state_entry::max_length() const int device_state_entry::max_length() const
{ {
// ask the entry to format itself maximally // ask the entry to format itself maximally
return format("", true).length(); return format("", value(), true).length();
} }

View File

@ -104,10 +104,10 @@ protected:
private: private:
// helpers // helpers
void format_from_mask(); void format_from_mask();
std::string format(const char *string, bool maxout = false) const; std::string format(const char *string, u64 result, bool maxout = false) const;
// statics // statics
static const u64 k_decimal_divisor[20]; // divisors for outputting decimal values static const u64 k_decimal_divisor[20]; // divisors for outputting decimal values
// public state description // public state description
device_state_interface *m_device_state; // link to parent device state device_state_interface *m_device_state; // link to parent device state
@ -357,13 +357,12 @@ protected:
virtual void interface_post_start() override; virtual void interface_post_start() override;
// constants // constants
static constexpr int FAST_STATE_MIN = -4; // range for fast state static constexpr int FAST_STATE_MIN = -4; // range for fast state
static constexpr int FAST_STATE_MAX = 256; // lookups static constexpr int FAST_STATE_MAX = 256; // lookups
// state // state
std::vector<std::unique_ptr<device_state_entry>> m_state_list; // head of state list std::vector<std::unique_ptr<device_state_entry>> m_state_list; // head of state list
device_state_entry * m_fast_state[FAST_STATE_MAX + 1 - FAST_STATE_MIN]; device_state_entry *m_fast_state[FAST_STATE_MAX + 1 - FAST_STATE_MIN]; // fast access to common entries
// fast access to common entries
}; };
// iterator // iterator