[Lldb-commits] [PATCH] D25137: [lldbmi] Fix prompt which can get inserted in the middle of lldb-mi output

2016-10-01 Thread Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283031: [lldb-mi] Fix prompt which can get inserted in the 
middle of program output in… (authored by dperchik).

Changed prior to commit:
  https://reviews.llvm.org/D25137?vs=73142&id=73193#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25137

Files:
  lldb/trunk/source/Core/IOHandler.cpp


Index: lldb/trunk/source/Core/IOHandler.cpp
===
--- lldb/trunk/source/Core/IOHandler.cpp
+++ lldb/trunk/source/Core/IOHandler.cpp
@@ -590,8 +590,8 @@
   else
 #endif
   {
-const char *prompt = GetPrompt();
 #ifdef _MSC_VER
+const char *prompt = GetPrompt();
 if (prompt) {
   // Back up over previous prompt using Windows API
   CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
@@ -605,9 +605,11 @@
 }
 #endif
 IOHandler::PrintAsync(stream, s, len);
+#ifdef _MSC_VER
 if (prompt)
   IOHandler::PrintAsync(GetOutputStreamFile().get(), prompt,
 strlen(prompt));
+#endif
   }
 }
 


Index: lldb/trunk/source/Core/IOHandler.cpp
===
--- lldb/trunk/source/Core/IOHandler.cpp
+++ lldb/trunk/source/Core/IOHandler.cpp
@@ -590,8 +590,8 @@
   else
 #endif
   {
-const char *prompt = GetPrompt();
 #ifdef _MSC_VER
+const char *prompt = GetPrompt();
 if (prompt) {
   // Back up over previous prompt using Windows API
   CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
@@ -605,9 +605,11 @@
 }
 #endif
 IOHandler::PrintAsync(stream, s, len);
+#ifdef _MSC_VER
 if (prompt)
   IOHandler::PrintAsync(GetOutputStreamFile().get(), prompt,
 strlen(prompt));
+#endif
   }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r283031 - [lldb-mi] Fix prompt which can get inserted in the middle of program output in lldb-mi

2016-10-01 Thread Dawn Perchik via lldb-commits
Author: dperchik
Date: Sat Oct  1 05:37:56 2016
New Revision: 283031

URL: http://llvm.org/viewvc/llvm-project?rev=283031&view=rev
Log:
[lldb-mi] Fix prompt which can get inserted in the middle of program output in 
lldb-mi

Summary: The code added in svn r264332 causes "(lldb) " to be printed in the
middle of program console output. This fix restores the behavior for non-Windows
platforms to before the patch.

Reviewers: ted, zturner, clayborg
Subscribers: amccarth, lldb-commits
Differential Revision: http://reviews.llvm.org/D25137

Modified:
lldb/trunk/source/Core/IOHandler.cpp

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=283031&r1=283030&r2=283031&view=diff
==
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Sat Oct  1 05:37:56 2016
@@ -590,8 +590,8 @@ void IOHandlerEditline::PrintAsync(Strea
   else
 #endif
   {
-const char *prompt = GetPrompt();
 #ifdef _MSC_VER
+const char *prompt = GetPrompt();
 if (prompt) {
   // Back up over previous prompt using Windows API
   CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
@@ -605,9 +605,11 @@ void IOHandlerEditline::PrintAsync(Strea
 }
 #endif
 IOHandler::PrintAsync(stream, s, len);
+#ifdef _MSC_VER
 if (prompt)
   IOHandler::PrintAsync(GetOutputStreamFile().get(), prompt,
 strlen(prompt));
+#endif
   }
 }
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D25158: Convert some Breakpoint to StringRef

2016-10-01 Thread Zachary Turner via lldb-commits
zturner created this revision.
zturner added a reviewer: jingham.
zturner added a subscriber: lldb-commits.

This is an incremental step towards getting some other code converted.  In any 
case, I believe this makes the breakpoint code significantly easier to 
understand and also removes many string copies in the range id code.


https://reviews.llvm.org/D25158

Files:
  include/lldb/Breakpoint/BreakpointID.h
  include/lldb/Breakpoint/BreakpointIDList.h
  source/Breakpoint/BreakpointID.cpp
  source/Breakpoint/BreakpointIDList.cpp

Index: source/Breakpoint/BreakpointIDList.cpp
===
--- source/Breakpoint/BreakpointIDList.cpp
+++ source/Breakpoint/BreakpointIDList.cpp
@@ -142,34 +142,32 @@
   bool allow_locations,
   CommandReturnObject &result,
   Args &new_args) {
-  std::string range_start;
-  const char *range_end;
-  const char *current_arg;
+  llvm::StringRef range_from;
+  llvm::StringRef range_to;
+  llvm::StringRef current_arg;
   const size_t num_old_args = old_args.GetArgumentCount();
   std::set names_found;
 
   for (size_t i = 0; i < num_old_args; ++i) {
 bool is_range = false;
 
 current_arg = old_args.GetArgumentAtIndex(i);
-if (!allow_locations && strchr(current_arg, '.') != nullptr) {
+if (!allow_locations && current_arg.contains('.')) {
   result.AppendErrorWithFormat(
-  "Breakpoint locations not allowed, saw location: %s.", current_arg);
+  "Breakpoint locations not allowed, saw location: %s.",
+  current_arg.str().c_str());
   new_args.Clear();
   return;
 }
 
-size_t range_start_len = 0;
-size_t range_end_pos = 0;
+llvm::StringRef range_expr;
 Error error;
 
-if (BreakpointIDList::StringContainsIDRangeExpression(
-current_arg, &range_start_len, &range_end_pos)) {
+std::tie(range_from, range_to) =
+BreakpointIDList::SplitIDRangeExpression(current_arg);
+if (!range_from.empty() && !range_to.empty()) {
   is_range = true;
-  range_start.assign(current_arg, range_start_len);
-  range_end = current_arg + range_end_pos;
-} else if (BreakpointID::StringIsBreakpointName(
-   llvm::StringRef(current_arg), error)) {
+} else if (BreakpointID::StringIsBreakpointName(current_arg, error)) {
   if (!error.Success()) {
 new_args.Clear();
 result.AppendError(error.AsCString());
@@ -183,23 +181,22 @@
BreakpointID::IsValidIDExpression(current_arg) &&
BreakpointID::IsValidIDExpression(
old_args.GetArgumentAtIndex(i + 2))) {
-  range_start.assign(current_arg);
-  range_end = old_args.GetArgumentAtIndex(i + 2);
+  range_from = current_arg;
+  range_to = old_args.GetArgumentAtIndex(i + 2);
   is_range = true;
   i = i + 2;
 } else {
   // See if user has specified id.*
-  std::string tmp_str = old_args.GetArgumentAtIndex(i);
+  llvm::StringRef tmp_str = old_args.GetArgumentAtIndex(i);
   size_t pos = tmp_str.find('.');
-  if (pos != std::string::npos) {
-std::string bp_id_str = tmp_str.substr(0, pos);
-if (BreakpointID::IsValidIDExpression(bp_id_str.c_str()) &&
-tmp_str[pos + 1] == '*' && tmp_str.length() == (pos + 2)) {
+  if (pos != llvm::StringRef::npos) {
+llvm::StringRef bp_id_str = tmp_str.substr(0, pos);
+if (BreakpointID::IsValidIDExpression(bp_id_str) &&
+tmp_str[pos + 1] == '*' && tmp_str.size() == (pos + 2)) {
   break_id_t bp_id;
   break_id_t bp_loc_id;
 
-  BreakpointID::ParseCanonicalReference(bp_id_str.c_str(), &bp_id,
-&bp_loc_id);
+  BreakpointID::ParseCanonicalReference(bp_id_str, &bp_id, &bp_loc_id);
   BreakpointSP breakpoint_sp = target->GetBreakpointByID(bp_id);
   if (!breakpoint_sp) {
 new_args.Clear();
@@ -221,119 +218,115 @@
   }
 }
 
-if (is_range) {
-  break_id_t start_bp_id;
-  break_id_t end_bp_id;
-  break_id_t start_loc_id;
-  break_id_t end_loc_id;
+if (!is_range) {
+  new_args.AppendArgument(current_arg);
+  continue;
+}
 
-  BreakpointID::ParseCanonicalReference(range_start.c_str(), &start_bp_id,
-&start_loc_id);
-  BreakpointID::ParseCanonicalReference(range_end, &end_bp_id, &end_loc_id);
+break_id_t start_bp_id;
+break_id_t end_bp_id;
+break_id_t start_loc_id;
+break_id_t end_loc_id;
 
-  if ((start_bp_id == LLDB_INVALID_BREAK_ID) ||
-  (!target->GetBreakpointByID(start_bp_id))) {
-new_args.Clear();
-result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
- range_start.c_str(