mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 15:41:35 +08:00
Fixed the way set/show variables were being accessed to being natively
accessed by the objects that own the settings. The previous approach wasn't very usable and made for a lot of unnecessary code just to access variables that were already owned by the objects. While I fixed those things, I saw that CommandObject objects should really have a reference to their command interpreter so they can access the terminal with if they want to output usaage. Fixed up all CommandObjects to take an interpreter and cleaned up the API to not need the interpreter to be passed in. Fixed the disassemble command to output the usage if no options are passed down and arguments are passed (all disassebmle variants take options, there are no "args only"). llvm-svn: 114252
This commit is contained in:
@@ -595,38 +595,27 @@ Debugger::DebuggerSettingsController::CreateNewInstanceSettings (const char *ins
|
||||
bool
|
||||
Debugger::DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err)
|
||||
{
|
||||
bool valid = true;
|
||||
bool valid = false;
|
||||
|
||||
// Verify we have a value string.
|
||||
if (value == NULL
|
||||
|| strlen (value) == 0)
|
||||
if (value == NULL || value[0] == '\0')
|
||||
{
|
||||
valid = false;
|
||||
err.SetErrorString ("Missing value. Can't set terminal width without a value.\n");
|
||||
err.SetErrorString ("Missing value. Can't set terminal width without a value.\n");
|
||||
}
|
||||
|
||||
// Verify the string consists entirely of digits.
|
||||
if (valid)
|
||||
else
|
||||
{
|
||||
int len = strlen (value);
|
||||
for (int i = 0; i < len; ++i)
|
||||
if (! isdigit (value[i]))
|
||||
{
|
||||
valid = false;
|
||||
err.SetErrorStringWithFormat ("'%s' is not a valid representation of an unsigned integer.\n", value);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the term-width is 'reasonable' (e.g. 10 <= width <= 250).
|
||||
if (valid)
|
||||
{
|
||||
int width = atoi (value);
|
||||
if (width < 10
|
||||
|| width > 250)
|
||||
char *end = NULL;
|
||||
const uint32_t width = ::strtoul (value, &end, 0);
|
||||
|
||||
if (end && end == '\0')
|
||||
{
|
||||
valid = false;
|
||||
err.SetErrorString ("Invalid term-width value; value must be between 10 and 250.\n");
|
||||
if (width >= 10 || width <= 1024)
|
||||
valid = true;
|
||||
else
|
||||
err.SetErrorString ("Invalid term-width value; value must be between 10 and 1024.\n");
|
||||
}
|
||||
else
|
||||
err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string.\n", value);
|
||||
}
|
||||
|
||||
return valid;
|
||||
@@ -637,9 +626,14 @@ Debugger::DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Erro
|
||||
// class DebuggerInstanceSettings
|
||||
//--------------------------------------------------
|
||||
|
||||
DebuggerInstanceSettings::DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance,
|
||||
const char *name) :
|
||||
DebuggerInstanceSettings::DebuggerInstanceSettings
|
||||
(
|
||||
UserSettingsController &owner,
|
||||
bool live_instance,
|
||||
const char *name
|
||||
) :
|
||||
InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance),
|
||||
m_term_width (80),
|
||||
m_prompt (),
|
||||
m_script_lang ()
|
||||
{
|
||||
@@ -725,7 +719,7 @@ DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var
|
||||
{
|
||||
if (ValidTermWidthValue (value, err))
|
||||
{
|
||||
m_term_width = atoi (value);
|
||||
m_term_width = ::strtoul (value, NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user