diff options
author | Greg Clayton <gclayton@apple.com> | 2010-09-19 02:33:57 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-09-19 02:33:57 +0000 |
commit | 1b65488229479ffced81cab3d36b59d6bff46fcd (patch) | |
tree | bf504814b8e547c5cef083b13ed3efb6ca5060ff /lldb/source/Core/UserSettingsController.cpp | |
parent | dd4da82c923e6f71c85e3579b758c775ec02c2aa (diff) | |
download | bcm5719-llvm-1b65488229479ffced81cab3d36b59d6bff46fcd.tar.gz bcm5719-llvm-1b65488229479ffced81cab3d36b59d6bff46fcd.zip |
Added code that will allow completely customizable prompts for use in
replacing the "(lldb)" prompt, the "frame #1..." displays when doing
stack backtracing and the "thread #1....". This will allow you to see
exactly the information that you want to see where you want to see it.
This currently isn't hookup up to the prompts yet, but it will be soon.
So what is the format of the prompts? Prompts can contain variables that
have access to the current program state. Variables are text that appears
in between a prefix of "${" and ends with a "}". Some of the interesting
variables include:
// The frame index (0, 1, 2, 3...)
${frame.index}
// common frame registers with generic names
${frame.pc}
${frame.sp}
${frame.fp}
${frame.ra}
${frame.flags}
// Access to any frame registers by name where REGNAME is any register name:
${frame.reg.REGNAME}
// The current compile unit file where the frame is located
${file.basename}
${file.fullpath}
// Function information
${function.name}
${function.pc-offset}
// Process info
${process.file.basename}
${process.file.fullpath}
${process.id}
${process.name}
// Thread info
${thread.id}
${thread.index}
${thread.name}
${thread.queue}
${thread.stop-reason}
// Target information
${target.arch}
// The current module for the current frame (the shared library or executable
// that contains the current frame PC value):
${module.file.basename}
${module.file.fullpath}
// Access to the line entry for where the current frame is when your thread
// is stopped:
${line.file.basename}
${line.file.fullpath}
${line.number}
${line.start-addr}
${line.end-addr}
Many times the information that you might have in your prompt might not be
available and you won't want it to print out if it isn't valid. To take care
of this you can enclose everything that must resolve into a scope. A scope
is starts with '{' and ends with '}'. For example in order to only display
the current file and line number when the information is available the format
would be:
"{ at {$line.file.basename}:${line.number}}"
Broken down this is:
start the scope: "{"
format whose content will only be displayed if all information is available:
"at {$line.file.basename}:${line.number}"
end the scope: "}"
We currently can represent the infomration we see when stopped at a frame:
frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19
with the following format:
"frame #${frame.index}: ${frame.pc} {${module.file.basename}`}{${function.name}{${function.pc-offset}}{ at ${line.file.basename}:${line.number}}\n"
This breaks down to always print:
"frame #${frame.index}: ${frame.pc} "
only print the module followed by a tick if we have a valid module:
"{${module.file.basename}`}"
print the function name with optional offset:
"{${function.name}{${function.pc-offset}}"
print the line info if it is available:
"{ at ${line.file.basename}:${line.number}}"
then finish off with a newline:
"\n"
Notice you can also put newlines ("\n") and tabs and everything else you
are used to putting in a format string when desensitized with the \ character.
Cleaned up some of the user settings controller subclasses. All of them
do not have any global settings variables and were all implementing stubs
for the get/set global settings variable. Now there is a default version
in UserSettingsController that will do nothing.
llvm-svn: 114306
Diffstat (limited to 'lldb/source/Core/UserSettingsController.cpp')
-rw-r--r-- | lldb/source/Core/UserSettingsController.cpp | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index 4a604cac38b..f6ecc1b22f9 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -39,6 +39,31 @@ UserSettingsController::~UserSettingsController () } bool +UserSettingsController::SetGlobalVariable +( + const ConstString &var_name, + const char *index_value, + const char *value, + const SettingEntry &entry, + const lldb::VarSetOperationType op, + Error &err +) +{ + err.SetErrorString ("UserSettingsController has no global settings"); + return false; +} + +bool +UserSettingsController::GetGlobalVariable +( + const ConstString &var_name, + StringList &value +) +{ + return false; +} + +bool UserSettingsController::InitializeSettingsController (lldb::UserSettingsControllerSP &controller_sp, SettingEntry *global_settings, SettingEntry *instance_settings) @@ -270,7 +295,7 @@ UserSettingsController::SetVariable (const char *full_dot_name, else value = entry->enum_values[0].string_value; } - UpdateGlobalVariable (const_var_name, index_value, value, *entry, op, err); + SetGlobalVariable (const_var_name, index_value, value, *entry, op, err); } else { @@ -472,8 +497,12 @@ UserSettingsController::SetVariable (const char *full_dot_name, } StringList -UserSettingsController::GetVariable (const char *full_dot_name, lldb::SettableVariableType &var_type, - const char *debugger_instance_name) +UserSettingsController::GetVariable +( + const char *full_dot_name, + lldb::SettableVariableType &var_type, + const char *debugger_instance_name +) { Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name); ConstString const_var_name; @@ -589,7 +618,7 @@ UserSettingsController::GetVariable (const char *full_dot_name, lldb::SettableVa else if (global_entry) { var_type = global_entry->var_type; - GetGlobalSettingsValue (const_var_name, value); + GetGlobalVariable (const_var_name, value); } else if (instance_entry) { @@ -720,18 +749,18 @@ UserSettingsController::PendingSettingsForInstance (const ConstString &instance_ pos = m_pending_settings.find (name_str); if (pos != m_pending_settings.end()) - { + { lldb::InstanceSettingsSP settings_sp = pos->second; return settings_sp; - } + } else - { - lldb::InstanceSettingsSP new_settings_sp = CreateNewInstanceSettings (instance_name.AsCString()); + { + lldb::InstanceSettingsSP new_settings_sp = CreateInstanceSettings (instance_name.AsCString()); CopyDefaultSettings (new_settings_sp, instance_name, true); m_pending_settings[name_str] = new_settings_sp; return new_settings_sp; - } - + } + // Should never reach this line. lldb::InstanceSettingsSP dummy; |