summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/IOHandler.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-02-04 22:00:53 +0000
committerGreg Clayton <gclayton@apple.com>2015-02-04 22:00:53 +0000
commit554f68d385920c45c723d97686fe2fbe257e4e0e (patch)
tree71f037f3a9801d03733dbe048c9081b23b76295f /lldb/source/Core/IOHandler.cpp
parent39b10c2cbb8fb1d4604697c79365c7c582de229b (diff)
downloadbcm5719-llvm-554f68d385920c45c723d97686fe2fbe257e4e0e.tar.gz
bcm5719-llvm-554f68d385920c45c723d97686fe2fbe257e4e0e.zip
Get rid of Debugger::FormatPrompt() and replace it with the new FormatEntity class.
Why? Debugger::FormatPrompt() would run through the format prompt every time and parse it and emit it piece by piece. It also did formatting differently depending on which key/value pair it was parsing. The new code improves on this with the following features: 1 - Allow format strings to be parsed into a FormatEntity::Entry which can contain multiple child FormatEntity::Entry objects. This FormatEntity::Entry is a parsed version of what was previously always done in Debugger::FormatPrompt() so it is more efficient to emit formatted strings using the new parsed FormatEntity::Entry. 2 - Allows errors in format strings to be shown immediately when setting the settings (frame-format, thread-format, disassembly-format 3 - Allows auto completion by implementing a new OptionValueFormatEntity and switching frame-format, thread-format, and disassembly-format settings over to using it. 4 - The FormatEntity::Entry for each of the frame-format, thread-format, disassembly-format settings only replaces the old one if the format parses correctly 5 - Combines all consecutive string values together for efficient output. This means all "${ansi.*}" keys and all desensitized characters like "\n" "\t" "\0721" "\x23" will get combined with their previous strings 6 - ${*.script:} (like "${var.script:mymodule.my_var_function}") have all been switched over to use ${script.*:} "${script.var:mymodule.my_var_function}") to make the format easier to parse as I don't believe anyone was using these format string power user features. 7 - All key values pairs are defined in simple C arrays of entries so it is much easier to add new entries. These changes pave the way for subsequent modifications where we can modify formats to do more (like control the width of value strings can do more and add more functionality more easily like string formatting to control the width, printf formats and more). llvm-svn: 228207
Diffstat (limited to 'lldb/source/Core/IOHandler.cpp')
-rw-r--r--lldb/source/Core/IOHandler.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 21ba965ba21..747fd4411d4 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -3217,6 +3217,8 @@ public:
FrameTreeDelegate () :
TreeDelegate()
{
+ FormatEntity::Parse ("frame #${frame.index}: {${function.name}${function.pc-offset}}}",
+ m_format);
}
virtual ~FrameTreeDelegate()
@@ -3236,9 +3238,7 @@ public:
StreamString strm;
const SymbolContext &sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
ExecutionContext exe_ctx (frame_sp);
- //const char *frame_format = "frame #${frame.index}: ${module.file.basename}{`${function.name}${function.pc-offset}}}";
- const char *frame_format = "frame #${frame.index}: {${function.name}${function.pc-offset}}}";
- if (Debugger::FormatPrompt (frame_format, &sc, &exe_ctx, NULL, strm))
+ if (FormatEntity::Format(m_format, strm, &sc, &exe_ctx, NULL, NULL, false, false))
{
int right_pad = 1;
window.PutCStringTruncated(strm.GetString().c_str(), right_pad);
@@ -3265,6 +3265,8 @@ public:
}
return false;
}
+protected:
+ FormatEntity::Entry m_format;
};
class ThreadTreeDelegate : public TreeDelegate
@@ -3276,6 +3278,8 @@ public:
m_tid (LLDB_INVALID_THREAD_ID),
m_stop_id (UINT32_MAX)
{
+ FormatEntity::Parse ("thread #${thread.index}: tid = ${thread.id}{, stop reason = ${thread.stop-reason}}",
+ m_format);
}
virtual
@@ -3306,8 +3310,7 @@ public:
{
StreamString strm;
ExecutionContext exe_ctx (thread_sp);
- const char *format = "thread #${thread.index}: tid = ${thread.id}{, stop reason = ${thread.stop-reason}}";
- if (Debugger::FormatPrompt (format, NULL, &exe_ctx, NULL, strm))
+ if (FormatEntity::Format (m_format, strm, NULL, &exe_ctx, NULL, NULL, false, false))
{
int right_pad = 1;
window.PutCStringTruncated(strm.GetString().c_str(), right_pad);
@@ -3383,6 +3386,8 @@ protected:
std::shared_ptr<FrameTreeDelegate> m_frame_delegate_sp;
lldb::user_id_t m_tid;
uint32_t m_stop_id;
+ FormatEntity::Entry m_format;
+
};
class ThreadsTreeDelegate : public TreeDelegate
@@ -3394,6 +3399,8 @@ public:
m_debugger (debugger),
m_stop_id (UINT32_MAX)
{
+ FormatEntity::Parse("process ${process.id}{, name = ${process.name}}",
+ m_format);
}
virtual
@@ -3415,8 +3422,7 @@ public:
{
StreamString strm;
ExecutionContext exe_ctx (process_sp);
- const char *format = "process ${process.id}{, name = ${process.name}}";
- if (Debugger::FormatPrompt (format, NULL, &exe_ctx, NULL, strm))
+ if (FormatEntity::Format (m_format, strm, NULL, &exe_ctx, NULL, NULL, false, false))
{
int right_pad = 1;
window.PutCStringTruncated(strm.GetString().c_str(), right_pad);
@@ -3472,6 +3478,8 @@ protected:
std::shared_ptr<ThreadTreeDelegate> m_thread_delegate_sp;
Debugger &m_debugger;
uint32_t m_stop_id;
+ FormatEntity::Entry m_format;
+
};
class ValueObjectListDelegate : public WindowDelegate
@@ -4635,6 +4643,8 @@ public:
StatusBarWindowDelegate (Debugger &debugger) :
m_debugger (debugger)
{
+ FormatEntity::Parse("Thread: ${thread.id%tid}",
+ m_format);
}
virtual
@@ -4659,8 +4669,7 @@ public:
if (StateIsStoppedState(state, true))
{
StreamString strm;
- const char *format = "Thread: ${thread.id%tid}";
- if (thread && Debugger::FormatPrompt (format, NULL, &exe_ctx, NULL, strm))
+ if (thread && FormatEntity::Format (m_format, strm, NULL, &exe_ctx, NULL, NULL, false, false))
{
window.MoveCursor (40, 0);
window.PutCStringTruncated(strm.GetString().c_str(), 1);
@@ -4686,6 +4695,7 @@ public:
protected:
Debugger &m_debugger;
+ FormatEntity::Entry m_format;
};
class SourceFileWindowDelegate : public WindowDelegate
OpenPOWER on IntegriCloud