<div dir="ltr"><div class="gmail_extra">Just found a nasty bug with this patch where it was returning the address of the format string - which means we can't alloc new formats in there. The below should fix this.</div>
<div class="gmail_extra">
<br></div><div class="gmail_extra">This patch allows you to do the following:</div><div class="gmail_extra"><br></div><div class="gmail_extra">settings set prompt "${ansi.bold}${ansi.fg.green}(lldb)${ansi.normal} "<br>
</div><div class="gmail_extra">settings set use-color false</div><div class="gmail_extra"><br></div><div class="gmail_extra">It also adds a command line option (--no-use-colors).</div><div class="gmail_extra" style> -Mike</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">
<div class="gmail_extra">Index: include/lldb/Core/Debugger.h</div><div class="gmail_extra">===================================================================</div><div class="gmail_extra">--- include/lldb/Core/Debugger.h<span style="white-space:pre-wrap"> </span>(revision 182486)</div>
<div class="gmail_extra">+++ include/lldb/Core/Debugger.h<span style="white-space:pre-wrap"> </span>(working copy)</div><div class="gmail_extra">@@ -236,7 +236,6 @@</div><div class="gmail_extra"> const ExecutionContext *exe_ctx,</div>
<div class="gmail_extra"> const Address *addr,</div><div class="gmail_extra"> Stream &s,</div><div class="gmail_extra">- const char **end,</div><div class="gmail_extra">
ValueObject* valobj = NULL);</div><div class="gmail_extra"> </div><div class="gmail_extra"> </div><div class="gmail_extra">@@ -308,6 +307,12 @@</div><div class="gmail_extra"> bool</div><div class="gmail_extra">
SetUseExternalEditor (bool use_external_editor_p);</div><div class="gmail_extra"> </div><div class="gmail_extra">+ bool</div><div class="gmail_extra">+ GetUseColor () const;</div><div class="gmail_extra">+ </div>
<div class="gmail_extra">+ bool</div><div class="gmail_extra">+ SetUseColor (bool use_color);</div><div class="gmail_extra">+ </div><div class="gmail_extra"> uint32_t</div><div class="gmail_extra"> GetStopSourceLineCount (bool before) const;</div>
<div class="gmail_extra"> </div><div class="gmail_extra">Index: include/lldb/Utility/AnsiTerminal.h</div><div class="gmail_extra">===================================================================</div><div class="gmail_extra">
--- include/lldb/Utility/AnsiTerminal.h<span style="white-space:pre-wrap"> </span>(revision 182486)</div><div class="gmail_extra">+++ include/lldb/Utility/AnsiTerminal.h<span style="white-space:pre-wrap"> </span>(working copy)</div>
<div class="gmail_extra">@@ -21,7 +21,7 @@</div><div class="gmail_extra"> #define ANSI_BG_COLOR_BLACK 40</div><div class="gmail_extra"> #define ANSI_BG_COLOR_RED 41<span style="white-space:pre-wrap"> </span></div>
<div class="gmail_extra"> #define ANSI_BG_COLOR_GREEN 42<span style="white-space:pre-wrap"> </span></div><div class="gmail_extra">-#define ANSI_BG_COLOR_YELLOW 44<span style="white-space:pre-wrap"> </span></div>
<div class="gmail_extra">+#define ANSI_BG_COLOR_YELLOW 43<span style="white-space:pre-wrap"> </span></div><div class="gmail_extra"> #define ANSI_BG_COLOR_BLUE 44<span style="white-space:pre-wrap"> </span></div>
<div class="gmail_extra"> #define ANSI_BG_COLOR_PURPLE 45<span style="white-space:pre-wrap"> </span></div><div class="gmail_extra"> #define ANSI_BG_COLOR_CYAN 46<span style="white-space:pre-wrap"> </span></div>
<div class="gmail_extra">@@ -82,5 +82,75 @@</div><div class="gmail_extra"> const char *k_ctrl_conceal<span style="white-space:pre-wrap"> </span> = "8";</div><div class="gmail_extra"> const char *k_ctrl_crossed_out<span style="white-space:pre-wrap"> </span> = "9";</div>
<div class="gmail_extra"> </div><div class="gmail_extra">+ inline std::string</div><div class="gmail_extra">+ FormatAnsiTerminalCodes(const char *format, bool do_color = true)</div><div class="gmail_extra">
+ {</div>
<div class="gmail_extra">+ // Convert "${ansi.XXX}" tokens to ansi values or clear them if do_color is false.</div><div class="gmail_extra">+ static const struct</div><div class="gmail_extra">
+ {</div><div class="gmail_extra">+ const char *name;</div><div class="gmail_extra">+ const char *value;</div><div class="gmail_extra">+ } g_color_tokens[] =</div><div class="gmail_extra">
+ {</div><div class="gmail_extra">+ #define _TO_STR2(_val) #_val</div><div class="gmail_extra">+ #define _TO_STR(_val) _TO_STR2(_val)</div><div class="gmail_extra">+ { "fg.black}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_BLACK) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "fg.red}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_RED) ANSI_ESC_END },</div><div class="gmail_extra">+ { "fg.green}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_GREEN) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "fg.yellow}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_YELLOW) ANSI_ESC_END },</div><div class="gmail_extra">+ { "fg.blue}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_BLUE) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "fg.purple}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_PURPLE) ANSI_ESC_END },</div><div class="gmail_extra">+ { "fg.cyan}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_CYAN) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "fg.white}", ANSI_ESC_START _TO_STR(ANSI_FG_COLOR_WHITE) ANSI_ESC_END },</div><div class="gmail_extra">+ { "bg.black}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_BLACK) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "bg.red}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_RED) ANSI_ESC_END },</div><div class="gmail_extra">+ { "bg.green}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_GREEN) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "bg.yellow}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_YELLOW) ANSI_ESC_END },</div><div class="gmail_extra">+ { "bg.blue}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_BLUE) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "bg.purple}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_PURPLE) ANSI_ESC_END },</div><div class="gmail_extra">+ { "bg.cyan}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_CYAN) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "bg.white}", ANSI_ESC_START _TO_STR(ANSI_BG_COLOR_WHITE) ANSI_ESC_END },</div><div class="gmail_extra">+ { "normal}", ANSI_ESC_START _TO_STR(ANSI_CTRL_NORMAL) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "bold}", ANSI_ESC_START _TO_STR(ANSI_CTRL_BOLD) ANSI_ESC_END },</div><div class="gmail_extra">+ { "faint}", ANSI_ESC_START _TO_STR(ANSI_CTRL_FAINT) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "italic}", ANSI_ESC_START _TO_STR(ANSI_CTRL_ITALIC) ANSI_ESC_END },</div><div class="gmail_extra">+ { "underline}", ANSI_ESC_START _TO_STR(ANSI_CTRL_UNDERLINE) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "slow-blink}", ANSI_ESC_START _TO_STR(ANSI_CTRL_SLOW_BLINK) ANSI_ESC_END },</div><div class="gmail_extra">+ { "fast-blink}", ANSI_ESC_START _TO_STR(ANSI_CTRL_FAST_BLINK) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "negative}", ANSI_ESC_START _TO_STR(ANSI_CTRL_IMAGE_NEGATIVE) ANSI_ESC_END },</div><div class="gmail_extra">+ { "conceal}", ANSI_ESC_START _TO_STR(ANSI_CTRL_CONCEAL) ANSI_ESC_END },</div>
<div class="gmail_extra">+ { "crossed-out}", ANSI_ESC_START _TO_STR(ANSI_CTRL_CROSSED_OUT) ANSI_ESC_END },</div><div class="gmail_extra">+ #undef _TO_STR</div><div class="gmail_extra">
+ #undef _TO_STR2</div><div class="gmail_extra">+ };</div><div class="gmail_extra">+ static const char tok_hdr[] = "${ansi.";</div><div class="gmail_extra">+</div><div class="gmail_extra">
+ std::string fmt;</div><div class="gmail_extra">+ for (const char *p = format; *p; ++p)</div><div class="gmail_extra">+ {</div><div class="gmail_extra">+ const char *tok_start = strstr (p, tok_hdr);</div>
<div class="gmail_extra">+ if (!tok_start)</div><div class="gmail_extra">+ {</div><div class="gmail_extra">+ fmt.append (p, strlen(p));</div><div class="gmail_extra">+ break;</div>
<div class="gmail_extra">+ }</div><div class="gmail_extra">+</div><div class="gmail_extra">+ fmt.append (p, tok_start - p);</div><div class="gmail_extra">+ p = tok_start;</div>
<div class="gmail_extra">+</div><div class="gmail_extra">+ const char *tok_str = tok_start + sizeof(tok_hdr) - 1;</div><div class="gmail_extra">+ for (size_t i = 0; i < sizeof(g_color_tokens) / sizeof(g_color_tokens[0]); ++i)</div>
<div class="gmail_extra">+ {</div><div class="gmail_extra">+ if (!strncmp (tok_str, g_color_tokens[i].name, strlen(g_color_tokens[i].name)))</div><div class="gmail_extra">+ {</div>
<div class="gmail_extra">+ if (do_color)</div><div class="gmail_extra">+ fmt.append (g_color_tokens[i].value);</div><div class="gmail_extra">+ p = tok_str + strlen (g_color_tokens[i].name) - 1;</div>
<div class="gmail_extra">+ break;</div><div class="gmail_extra">+ }</div><div class="gmail_extra">+ }</div><div class="gmail_extra">+ }</div><div class="gmail_extra">
+ return fmt;</div><div class="gmail_extra">+ }</div><div class="gmail_extra"> }</div><div class="gmail_extra"> }</div><div class="gmail_extra">Index: source/Core/Debugger.cpp</div><div class="gmail_extra">
===================================================================</div><div class="gmail_extra">--- source/Core/Debugger.cpp<span style="white-space:pre-wrap"> </span>(revision 182486)</div><div class="gmail_extra">
+++ source/Core/Debugger.cpp<span style="white-space:pre-wrap"> </span>(working copy)</div><div class="gmail_extra">@@ -131,6 +131,7 @@</div><div class="gmail_extra"> { "term-width", OptionValue::eTypeSInt64 , true, 80 , NULL, NULL, "The maximum number of columns to use for displaying text." },</div>
<div class="gmail_extra"> { "thread-format", OptionValue::eTypeString , true, 0 , DEFAULT_THREAD_FORMAT, NULL, "The default thread format string to use when displaying thread information." },</div>
<div class="gmail_extra"> { "use-external-editor", OptionValue::eTypeBoolean, true, false, NULL, NULL, "Whether to use an external editor or not." },</div><div class="gmail_extra">+{ "use-color", OptionValue::eTypeBoolean, true, true , NULL, NULL, "Whether to use Ansi color codes or not." },</div>
<div class="gmail_extra"> </div><div class="gmail_extra"> { NULL, OptionValue::eTypeInvalid, true, 0 , NULL, NULL, NULL }</div><div class="gmail_extra"> };</div><div class="gmail_extra">@@ -148,7 +149,8 @@</div>
<div class="gmail_extra"> ePropertyStopLineCountBefore,</div><div class="gmail_extra"> ePropertyTerminalWidth,</div><div class="gmail_extra"> ePropertyThreadFormat,</div><div class="gmail_extra">- ePropertyUseExternalEditor</div>
<div class="gmail_extra">+ ePropertyUseExternalEditor,</div><div class="gmail_extra">+ ePropertyUseColor,</div><div class="gmail_extra"> };</div><div class="gmail_extra"> </div><div class="gmail_extra"> //</div><div class="gmail_extra">
@@ -186,9 +188,17 @@</div><div class="gmail_extra"> if (strcmp(property_path, g_properties[ePropertyPrompt].name) == 0)</div><div class="gmail_extra"> {</div><div class="gmail_extra"> const char *new_prompt = GetPrompt();</div>
<div class="gmail_extra">+ std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes (new_prompt, GetUseColor());</div><div class="gmail_extra">+ if (str.length())</div><div class="gmail_extra">
+ new_prompt = str.c_str();</div>
<div class="gmail_extra"> EventSP prompt_change_event_sp (new Event(CommandInterpreter::eBroadcastBitResetPrompt, new EventDataBytes (new_prompt)));</div><div class="gmail_extra"> GetCommandInterpreter().BroadcastEvent (prompt_change_event_sp);</div>
<div class="gmail_extra"> }</div><div class="gmail_extra">+ else if (strcmp(property_path, g_properties[ePropertyUseColor].name) == 0)</div><div class="gmail_extra">+ {</div><div class="gmail_extra">
+<span style="white-space:pre-wrap"> </span>// use-color changed. Ping the prompt so it can reset the ansi terminal codes.</div><div class="gmail_extra">+ SetPrompt (GetPrompt());</div><div class="gmail_extra">
+ }</div><div class="gmail_extra"> else if (is_load_script && target_sp && load_script_old_value == eLoadScriptFromSymFileWarn)</div><div class="gmail_extra"> {</div><div class="gmail_extra">
if (target_sp->TargetProperties::GetLoadScriptFromSymbolFile() == eLoadScriptFromSymFileTrue)</div><div class="gmail_extra">@@ -244,6 +254,9 @@</div><div class="gmail_extra"> const uint32_t idx = ePropertyPrompt;</div>
<div class="gmail_extra"> m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);</div><div class="gmail_extra"> const char *new_prompt = GetPrompt();</div><div class="gmail_extra">+ std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes (new_prompt, GetUseColor());</div>
<div class="gmail_extra">+ if (str.length())</div><div class="gmail_extra">+ new_prompt = str.c_str();</div><div class="gmail_extra"> EventSP prompt_change_event_sp (new Event(CommandInterpreter::eBroadcastBitResetPrompt, new EventDataBytes (new_prompt)));;</div>
<div class="gmail_extra"> GetCommandInterpreter().BroadcastEvent (prompt_change_event_sp);</div><div class="gmail_extra"> }</div><div class="gmail_extra">@@ -297,6 +310,22 @@</div><div class="gmail_extra"> return m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);</div>
<div class="gmail_extra"> }</div><div class="gmail_extra"> </div><div class="gmail_extra">+bool</div><div class="gmail_extra">+Debugger::GetUseColor () const</div><div class="gmail_extra">+{</div><div class="gmail_extra">
+ const uint32_t idx = ePropertyUseColor;</div><div class="gmail_extra">+ return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);</div><div class="gmail_extra">
+}</div><div class="gmail_extra">+</div><div class="gmail_extra">+bool</div><div class="gmail_extra">+Debugger::SetUseColor (bool b)</div><div class="gmail_extra">+{</div><div class="gmail_extra">+ const uint32_t idx = ePropertyUseColor;</div>
<div class="gmail_extra">+ bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);</div><div class="gmail_extra">+ SetPrompt (GetPrompt());</div><div class="gmail_extra">+ return ret;</div><div class="gmail_extra">
+}</div><div class="gmail_extra">+</div><div class="gmail_extra"> uint32_t</div><div class="gmail_extra"> Debugger::GetStopSourceLineCount (bool before) const</div><div class="gmail_extra"> {</div><div class="gmail_extra">
@@ -629,6 +658,11 @@</div><div class="gmail_extra"> OptionValueSInt64 *term_width = m_collection_sp->GetPropertyAtIndexAsOptionValueSInt64 (NULL, ePropertyTerminalWidth);</div><div class="gmail_extra"> term_width->SetMinimumValue(10);</div>
<div class="gmail_extra"> term_width->SetMaximumValue(1024);</div><div class="gmail_extra">+</div><div class="gmail_extra">+ // Turn off use-color if this is a dumb terminal.</div><div class="gmail_extra">+ const char *term = getenv ("TERM");</div>
<div class="gmail_extra">+ if (term && !strcmp (term, "dumb"))</div><div class="gmail_extra">+ SetUseColor (false);</div><div class="gmail_extra"> }</div><div class="gmail_extra"> </div><div class="gmail_extra">
Debugger::~Debugger ()</div><div class="gmail_extra">@@ -1140,13 +1174,12 @@</div><div class="gmail_extra"> ExecutionContext exe_ctx;</div><div class="gmail_extra"> frame->CalculateExecutionContext(exe_ctx);</div>
<div class="gmail_extra"> const char *end = NULL;</div><div class="gmail_extra">- if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, &end))</div><div class="gmail_extra">
+ if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s))</div><div class="gmail_extra"> {</div><div class="gmail_extra"> printf("%s\n", s.GetData());</div>
<div class="gmail_extra"> }</div><div class="gmail_extra"> else</div><div class="gmail_extra"> {</div><div class="gmail_extra">- printf ("error: at '%s'\n", end);</div><div class="gmail_extra">
printf ("what we got: %s\n", s.GetData());</div><div class="gmail_extra"> }</div><div class="gmail_extra"> }</div><div class="gmail_extra">@@ -1323,8 +1356,8 @@</div><div class="gmail_extra"> return item;</div>
<div class="gmail_extra"> }</div><div class="gmail_extra"> </div><div class="gmail_extra">-bool</div><div class="gmail_extra">-Debugger::FormatPrompt </div><div class="gmail_extra">+static bool</div><div class="gmail_extra">
+FormatPromptRecurse</div><div class="gmail_extra"> (</div><div class="gmail_extra"> const char *format,</div><div class="gmail_extra"> const SymbolContext *sc,</div><div class="gmail_extra">@@ -1373,8 +1406,8 @@</div>
<div class="gmail_extra"> StreamString sub_strm;</div><div class="gmail_extra"> </div><div class="gmail_extra"> ++p; // Skip the '{'</div><div class="gmail_extra">- </div><div class="gmail_extra">
- if (FormatPrompt (p, sc, exe_ctx, addr, sub_strm, &p, valobj))</div><div class="gmail_extra">+</div><div class="gmail_extra">+ if (FormatPromptRecurse (p, sc, exe_ctx, addr, sub_strm, &p, valobj))</div>
<div class="gmail_extra"> {</div><div class="gmail_extra"> // The stream had all it needed</div><div class="gmail_extra"> s.Write(sub_strm.GetData(), sub_strm.GetSize());</div>
<div class="gmail_extra">
@@ -1712,7 +1745,7 @@</div><div class="gmail_extra"> if (!special_directions)</div><div class="gmail_extra"> var_success &= item->DumpPrintableRepresentation(s,val_obj_display, custom_format);</div>
<div class="gmail_extra"> else</div><div class="gmail_extra">- var_success &= FormatPrompt(special_directions, sc, exe_ctx, addr, s, NULL, item);</div>
<div class="gmail_extra">+ var_success &= FormatPromptRecurse(special_directions, sc, exe_ctx, addr, s, NULL, item);</div><div class="gmail_extra"> </div>
<div class="gmail_extra"> if (--max_num_children == 0)</div><div class="gmail_extra"> {</div><div class="gmail_extra">@@ -1736,214 +1769,6 @@</div>
<div class="gmail_extra"> format_addr = *addr;</div><div class="gmail_extra"> }</div><div class="gmail_extra"> }</div><div class="gmail_extra">
- else if (::strncmp (var_name_begin, "ansi.", strlen("ansi.")) == 0)</div><div class="gmail_extra">- {</div><div class="gmail_extra">- var_success = true;</div>
<div class="gmail_extra">- var_name_begin += strlen("ansi."); // Skip the "ansi."</div><div class="gmail_extra">- if (::strncmp (var_name_begin, "fg.", strlen("fg.")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- var_name_begin += strlen("fg."); // Skip the "fg."</div><div class="gmail_extra">
- if (::strncmp (var_name_begin, "black}", strlen("black}")) == 0)</div><div class="gmail_extra">- {</div><div class="gmail_extra">
- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div><div class="gmail_extra">
- lldb_utility::ansi::k_fg_black,</div>
<div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div><div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "red}", strlen("red}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_fg_red,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "green}", strlen("green}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_fg_green,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "yellow}", strlen("yellow}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_fg_yellow,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "blue}", strlen("blue}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_fg_blue,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "purple}", strlen("purple}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_fg_purple,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "cyan}", strlen("cyan}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_fg_cyan,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "white}", strlen("white}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_fg_white,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else</div><div class="gmail_extra">- {</div><div class="gmail_extra">
- var_success = false;</div><div class="gmail_extra">- }</div><div class="gmail_extra">- }</div><div class="gmail_extra">
- else if (::strncmp (var_name_begin, "bg.", strlen("bg.")) == 0)</div><div class="gmail_extra">- {</div><div class="gmail_extra">- var_name_begin += strlen("bg."); // Skip the "bg."</div>
<div class="gmail_extra">- if (::strncmp (var_name_begin, "black}", strlen("black}")) == 0)</div><div class="gmail_extra">- {</div>
<div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">
- lldb_utility::ansi::k_bg_black,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div><div class="gmail_extra">
- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "red}", strlen("red}")) == 0)</div><div class="gmail_extra">
- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_bg_red,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "green}", strlen("green}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_bg_green,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "yellow}", strlen("yellow}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_bg_yellow,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "blue}", strlen("blue}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_bg_blue,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "purple}", strlen("purple}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_bg_purple,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "cyan}", strlen("cyan}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_bg_cyan,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "white}", strlen("white}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_bg_white,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else</div><div class="gmail_extra">- {</div><div class="gmail_extra">
- var_success = false;</div><div class="gmail_extra">- }</div><div class="gmail_extra">- }</div><div class="gmail_extra">
- else if (::strncmp (var_name_begin, "normal}", strlen ("normal}")) == 0)</div><div class="gmail_extra">- {</div><div class="gmail_extra">
- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div><div class="gmail_extra">- lldb_utility::ansi::k_ctrl_normal,</div>
<div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div><div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "bold}", strlen("bold}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_bold,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "faint}", strlen("faint}")) == 0)</div><div class="gmail_extra">
- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_faint,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "italic}", strlen("italic}")) == 0)</div>
<div class="gmail_extra">
- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_italic,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "underline}", strlen("underline}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_underline,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "slow-blink}", strlen("slow-blink}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_slow_blink,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "fast-blink}", strlen("fast-blink}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_fast_blink,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "negative}", strlen("negative}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_negative,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "conceal}", strlen("conceal}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_conceal,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">-</div><div class="gmail_extra">- }</div><div class="gmail_extra">- else if (::strncmp (var_name_begin, "crossed-out}", strlen("crossed-out}")) == 0)</div>
<div class="gmail_extra">- {</div><div class="gmail_extra">- s.Printf ("%s%s%s", </div><div class="gmail_extra">- lldb_utility::ansi::k_escape_start, </div>
<div class="gmail_extra">- lldb_utility::ansi::k_ctrl_crossed_out,</div><div class="gmail_extra">- lldb_utility::ansi::k_escape_end);</div>
<div class="gmail_extra">- }</div><div class="gmail_extra">- else</div><div class="gmail_extra">- {</div><div class="gmail_extra">
- var_success = false;</div><div class="gmail_extra">- }</div><div class="gmail_extra">- }</div><div class="gmail_extra"> break;</div>
<div class="gmail_extra"> </div><div class="gmail_extra"> case 'p':</div><div class="gmail_extra">@@ -2632,6 +2457,24 @@</div><div class="gmail_extra"> return success;</div><div class="gmail_extra">
}</div><div class="gmail_extra"> </div><div class="gmail_extra">+bool</div><div class="gmail_extra">+Debugger::FormatPrompt</div><div class="gmail_extra">+(</div><div class="gmail_extra">+ const char *format,</div><div class="gmail_extra">
+ const SymbolContext *sc,</div><div class="gmail_extra">+ const ExecutionContext *exe_ctx,</div><div class="gmail_extra">+ const Address *addr,</div><div class="gmail_extra">+ Stream &s,</div><div class="gmail_extra">
+ ValueObject* valobj</div><div class="gmail_extra">+)</div><div class="gmail_extra">+{</div><div class="gmail_extra">+ bool use_color = exe_ctx ? exe_ctx->GetTargetRef().GetDebugger().GetUseColor() : true;</div>
<div class="gmail_extra">+ std::string format_str = lldb_utility::ansi::FormatAnsiTerminalCodes (format, use_color);</div><div class="gmail_extra">+ if (format_str.length())</div><div class="gmail_extra">+ format = format_str.c_str();</div>
<div class="gmail_extra">+ return FormatPromptRecurse (format, sc, exe_ctx, addr, s, NULL, valobj);</div><div class="gmail_extra">+}</div><div class="gmail_extra">+</div><div class="gmail_extra"> void</div><div class="gmail_extra">
Debugger::SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton)</div><div class="gmail_extra"> {</div><div class="gmail_extra">Index: tools/driver/Driver.cpp</div><div class="gmail_extra">===================================================================</div>
<div class="gmail_extra">--- tools/driver/Driver.cpp<span style="white-space:pre-wrap"> </span>(revision 182486)</div><div class="gmail_extra">+++ tools/driver/Driver.cpp<span style="white-space:pre-wrap"> </span>(working copy)</div>
<div class="gmail_extra">@@ -105,7 +105,9 @@</div><div class="gmail_extra"> "Tells the debugger to open source files using the host's \"external editor\" mechanism." },</div><div class="gmail_extra">
{ LLDB_3_TO_5, false, "no-lldbinit" , 'x', no_argument , 0, eArgTypeNone,</div><div class="gmail_extra"> "Do not automatically parse any '.lldbinit' files." },</div>
<div class="gmail_extra">- { LLDB_OPT_SET_6, true , "python-path" , 'P', no_argument , 0, eArgTypeNone,</div><div class="gmail_extra">+ { LLDB_3_TO_5, false, "no-use-colors" , 'o', no_argument , 0, eArgTypeNone,</div>
<div class="gmail_extra">+ "Do not use colors." },</div><div class="gmail_extra">+ { LLDB_OPT_SET_6, true , "python-path" , 'P', no_argument , 0, eArgTypeNone,</div><div class="gmail_extra">
"Prints out the path to the lldb.py file for this version of lldb." },</div><div class="gmail_extra"> { 0, false, NULL , 0 , 0 , 0, eArgTypeNone, NULL }</div>
<div class="gmail_extra"> };</div><div class="gmail_extra">@@ -621,6 +623,10 @@</div><div class="gmail_extra"> m_debugger.SkipAppInitFiles (true);</div><div class="gmail_extra"> break;</div>
<div class="gmail_extra"> </div><div class="gmail_extra">+ case 'o':</div><div class="gmail_extra">+ m_debugger.SetUseColor (false);</div><div class="gmail_extra">+ break;</div>
<div class="gmail_extra">+</div><div class="gmail_extra"> case 'f':</div><div class="gmail_extra"> {</div><div class="gmail_extra"> SBFileSpec file(optarg);</div>
<div class="gmail_extra">Index: include/lldb/API/SBDebugger.h</div><div class="gmail_extra">===================================================================</div><div class="gmail_extra">--- include/lldb/API/SBDebugger.h<span style="white-space:pre-wrap"> </span>(revision 182486)</div>
<div class="gmail_extra">+++ include/lldb/API/SBDebugger.h<span style="white-space:pre-wrap"> </span>(working copy)</div><div class="gmail_extra">@@ -172,6 +172,12 @@</div><div class="gmail_extra"> bool </div><div class="gmail_extra">
GetUseExternalEditor ();</div><div class="gmail_extra"> </div><div class="gmail_extra">+ bool</div><div class="gmail_extra">+ SetUseColor (bool use_color);</div><div class="gmail_extra">+</div><div class="gmail_extra">
+ bool</div><div class="gmail_extra">+ GetUseColor () const;</div><div class="gmail_extra">+</div><div class="gmail_extra"> static bool</div><div class="gmail_extra"> GetDefaultArchitecture (char *arch_name, size_t arch_name_len);</div>
<div class="gmail_extra"> </div><div class="gmail_extra">Index: source/API/SBDebugger.cpp</div><div class="gmail_extra">===================================================================</div><div class="gmail_extra">--- source/API/SBDebugger.cpp<span style="white-space:pre-wrap"> </span>(revision 182486)</div>
<div class="gmail_extra">+++ source/API/SBDebugger.cpp<span style="white-space:pre-wrap"> </span>(working copy)</div><div class="gmail_extra">@@ -1057,6 +1057,22 @@</div><div class="gmail_extra"> }</div><div class="gmail_extra">
</div><div class="gmail_extra"> bool</div><div class="gmail_extra">+SBDebugger::SetUseColor (bool value)</div><div class="gmail_extra">+{</div><div class="gmail_extra">+ if (m_opaque_sp)</div><div class="gmail_extra">
+ return m_opaque_sp->SetUseColor (value);</div><div class="gmail_extra">+ return false;</div><div class="gmail_extra">+}</div><div class="gmail_extra">+</div><div class="gmail_extra">+bool</div><div class="gmail_extra">
+SBDebugger::GetUseColor () const</div><div class="gmail_extra">+{</div><div class="gmail_extra">+ if (m_opaque_sp)</div><div class="gmail_extra">+ return m_opaque_sp->GetUseColor ();</div><div class="gmail_extra">
+ return false;</div><div class="gmail_extra">+}</div><div class="gmail_extra">+</div><div class="gmail_extra">+bool</div><div class="gmail_extra"> SBDebugger::GetDescription (SBStream &description)</div><div class="gmail_extra">
{</div><div class="gmail_extra"> Stream &strm = description.ref();</div><div class="gmail_extra">Index: source/DataFormatters/LibCxx.cpp</div><div class="gmail_extra">===================================================================</div>
<div class="gmail_extra">--- source/DataFormatters/LibCxx.cpp<span style="white-space:pre-wrap"> </span>(revision 182486)</div><div class="gmail_extra">+++ source/DataFormatters/LibCxx.cpp<span style="white-space:pre-wrap"> </span>(working copy)</div>
<div class="gmail_extra">@@ -516,5 +516,5 @@</div><div class="gmail_extra"> return false;</div><div class="gmail_extra"> stream.Printf("0x%016llx ", value);</div><div class="gmail_extra"> }</div>
<div class="gmail_extra">- return Debugger::FormatPrompt("size=${svar%#}", NULL, NULL, NULL, stream, NULL, &valobj);</div><div class="gmail_extra">+ return Debugger::FormatPrompt("size=${svar%#}", NULL, NULL, NULL, stream, &valobj);</div>
<div class="gmail_extra"> }</div><div class="gmail_extra">Index: source/DataFormatters/TypeSummary.cpp</div><div class="gmail_extra">===================================================================</div><div class="gmail_extra">
--- source/DataFormatters/TypeSummary.cpp<span style="white-space:pre-wrap"> </span>(revision 182486)</div><div class="gmail_extra">+++ source/DataFormatters/TypeSummary.cpp<span style="white-space:pre-wrap"> </span>(working copy)</div>
<div class="gmail_extra">@@ -113,7 +113,7 @@</div><div class="gmail_extra"> }</div><div class="gmail_extra"> else</div><div class="gmail_extra"> {</div><div class="gmail_extra">- if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))</div>
<div class="gmail_extra">+ if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, valobj))</div><div class="gmail_extra"> {</div><div class="gmail_extra">
retval.assign(s.GetString());</div><div class="gmail_extra"> return true;</div><div class="gmail_extra">Index: source/Target/StackFrame.cpp</div><div class="gmail_extra">===================================================================</div>
<div class="gmail_extra">--- source/Target/StackFrame.cpp<span style="white-space:pre-wrap"> </span>(revision 182486)</div><div class="gmail_extra">+++ source/Target/StackFrame.cpp<span style="white-space:pre-wrap"> </span>(working copy)</div>
<div class="gmail_extra">@@ -1282,13 +1282,12 @@</div><div class="gmail_extra"> </div><div class="gmail_extra"> GetSymbolContext(eSymbolContextEverything);</div><div class="gmail_extra"> ExecutionContext exe_ctx (shared_from_this());</div>
<div class="gmail_extra">- const char *end = NULL;</div><div class="gmail_extra"> StreamString s;</div><div class="gmail_extra"> const char *frame_format = NULL;</div><div class="gmail_extra"> Target *target = exe_ctx.GetTargetPtr();</div>
<div class="gmail_extra"> if (target)</div><div class="gmail_extra"> frame_format = target->GetDebugger().GetFrameFormat();</div><div class="gmail_extra">- if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end))</div>
<div class="gmail_extra">+ if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s))</div><div class="gmail_extra"> {</div><div class="gmail_extra"> strm->Write(s.GetData(), s.GetSize());</div>
<div class="gmail_extra"> }</div><div class="gmail_extra">Index: source/Target/Thread.cpp</div><div class="gmail_extra">===================================================================</div><div class="gmail_extra">
--- source/Target/Thread.cpp<span style="white-space:pre-wrap"> </span>(revision 182486)</div><div class="gmail_extra">+++ source/Target/Thread.cpp<span style="white-space:pre-wrap"> </span>(working copy)</div><div class="gmail_extra">
@@ -1747,13 +1747,11 @@</div><div class="gmail_extra"> </div><div class="gmail_extra"> const char *thread_format = exe_ctx.GetTargetRef().GetDebugger().GetThreadFormat();</div><div class="gmail_extra"> assert (thread_format);</div>
<div class="gmail_extra">- const char *end = NULL;</div><div class="gmail_extra"> Debugger::FormatPrompt (thread_format, </div><div class="gmail_extra"> frame_sp ? &frame_sc : NULL,</div>
<div class="gmail_extra"> &exe_ctx, </div><div class="gmail_extra"> NULL,</div><div class="gmail_extra">- strm, </div><div class="gmail_extra">
- &end);</div><div class="gmail_extra">+ strm);</div><div class="gmail_extra"> }</div><div class="gmail_extra"> </div><div class="gmail_extra"> void</div><div><br>
</div></div></div>