[Lldb-commits] [lldb] 91728b9 - [lldb] Don't print IRForTarget errors directly to the console

2020-06-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-06-12T10:27:25+02:00
New Revision: 91728b9172bfd2a2eccc9dc2ef3462f931579aff

URL: 
https://github.com/llvm/llvm-project/commit/91728b9172bfd2a2eccc9dc2ef3462f931579aff
DIFF: 
https://github.com/llvm/llvm-project/commit/91728b9172bfd2a2eccc9dc2ef3462f931579aff.diff

LOG: [lldb] Don't print IRForTarget errors directly to the console

Summary:

When we get an error back from IRForTarget we directly print that error to the
debugger output stream instead of putting it in the result object. The result
object only gets a vague "The expression could not be prepared to run in the
target" error message that doesn't actually tell the user what went wrong.

This patch just puts the IRForTarget errors into the status object that is
returned to the caller instead of directly printing it to the debugger. Also
updates one test that now can actually check for the error message it is
supposed to check for (instead of the default error which is all we had before).

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D81654

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 14dd0656bf82..90dfbe288767 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1323,18 +1323,13 @@ lldb_private::Status 
ClangExpressionParser::PrepareForExecution(
   type_system_helper->DeclMap(); // result can be NULL
 
   if (decl_map) {
-Target *target = exe_ctx.GetTargetPtr();
-auto &error_stream = target->GetDebugger().GetErrorStream();
+StreamString error_stream;
 IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(),
   *execution_unit_sp, error_stream,
   function_name.AsCString());
 
-bool ir_can_run =
-ir_for_target.runOnModule(*execution_unit_sp->GetModule());
-
-if (!ir_can_run) {
-  err.SetErrorString(
-  "The expression could not be prepared to run in the target");
+if (!ir_for_target.runOnModule(*execution_unit_sp->GetModule())) {
+  err.SetErrorString(error_stream.GetString());
   return err;
 }
 

diff  --git 
a/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
 
b/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
index 18283f6d2b33..42d852f5763e 100644
--- 
a/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
+++ 
b/lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
@@ -23,4 +23,4 @@ def test(self):
 # be prepared to run in the target but it should at least not crash 
LLDB.
 self.expect('expr --lang objc -- [NSString stringWithFormat:@"%d", 
1];',
 error=True,
-substrs=["error: The expression could not be prepared to 
run in the target"])
+substrs=["Rewriting an Objective-C constant string 
requires CFStringCreateWithBytes"])



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


[Lldb-commits] [PATCH] D81589: [lldb/SymbolFile] Don't parse the whole line table for the support files

2020-06-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a subscriber: teemperor.
labath accepted this revision.
labath added a comment.

If this didn't show up on the lldb benchmark charts 
(https://teemperor.de/lldb-bench/static.html), it would be nice to add a 
benchmark for this. What exactly were you measuring here?




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:191-192
+LLDB_LOG_ERROR(log, std::move(e),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse "
+   "line table prologue");
+  },

It would be good to also add a `{0}` somewhere to print the actual error we 
received.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81589/new/

https://reviews.llvm.org/D81589



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


[Lldb-commits] [PATCH] D81654: [lldb] Don't print IRForTarget errors directly to the console

2020-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91728b9172bf: [lldb] Don't print IRForTarget errors 
directly to the console (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D81654?vs=270128&id=270323#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81654/new/

https://reviews.llvm.org/D81654

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  
lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py


Index: 
lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
===
--- 
lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
+++ 
lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
@@ -23,4 +23,4 @@
 # be prepared to run in the target but it should at least not crash 
LLDB.
 self.expect('expr --lang objc -- [NSString stringWithFormat:@"%d", 
1];',
 error=True,
-substrs=["error: The expression could not be prepared to 
run in the target"])
+substrs=["Rewriting an Objective-C constant string 
requires CFStringCreateWithBytes"])
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1323,18 +1323,13 @@
   type_system_helper->DeclMap(); // result can be NULL
 
   if (decl_map) {
-Target *target = exe_ctx.GetTargetPtr();
-auto &error_stream = target->GetDebugger().GetErrorStream();
+StreamString error_stream;
 IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(),
   *execution_unit_sp, error_stream,
   function_name.AsCString());
 
-bool ir_can_run =
-ir_for_target.runOnModule(*execution_unit_sp->GetModule());
-
-if (!ir_can_run) {
-  err.SetErrorString(
-  "The expression could not be prepared to run in the target");
+if (!ir_for_target.runOnModule(*execution_unit_sp->GetModule())) {
+  err.SetErrorString(error_stream.GetString());
   return err;
 }
 


Index: lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
===
--- lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
+++ lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
@@ -23,4 +23,4 @@
 # be prepared to run in the target but it should at least not crash LLDB.
 self.expect('expr --lang objc -- [NSString stringWithFormat:@"%d", 1];',
 error=True,
-substrs=["error: The expression could not be prepared to run in the target"])
+substrs=["Rewriting an Objective-C constant string requires CFStringCreateWithBytes"])
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1323,18 +1323,13 @@
   type_system_helper->DeclMap(); // result can be NULL
 
   if (decl_map) {
-Target *target = exe_ctx.GetTargetPtr();
-auto &error_stream = target->GetDebugger().GetErrorStream();
+StreamString error_stream;
 IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(),
   *execution_unit_sp, error_stream,
   function_name.AsCString());
 
-bool ir_can_run =
-ir_for_target.runOnModule(*execution_unit_sp->GetModule());
-
-if (!ir_can_run) {
-  err.SetErrorString(
-  "The expression could not be prepared to run in the target");
+if (!ir_for_target.runOnModule(*execution_unit_sp->GetModule())) {
+  err.SetErrorString(error_stream.GetString());
   return err;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81200: [vscode] set default values for terminateDebuggee for the disconnect request

2020-06-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py:68
+
+self.disconnect_and_check_no_output()

labath wrote:
> I'm confused as to why we're not expecting any output here. I was under the 
> impression that we want to let the inferior continue in the "attach" case.
When I think about this more, I get even more confused. In the attach case, is 
the inferior stdout even flowing through the vscode connection? I would expect 
not..

If that's true, then this test and its description is pretty misleading -- 
there will not be anything in the stdout stream, but not because we 
disconnected early -- the stdout will _never_ be there.

What exactly are you trying to test here? Maybe it would be more worthwhile to 
read the stdout from the popen object to ensure that the inferior does continue 
to print the number correctly?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81200/new/

https://reviews.llvm.org/D81200



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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-06-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Host/common/Editline.cpp:1051-1052
+unsigned char Editline::TypedCharacter(int ch) {
+  std::string typed = std::string(1, ch);
+  typed = typed[0];
+  el_insertstr(m_editline, typed.c_str());

the second line is redundant. `std::string typed(1, ch)` is enough. (Though I 
might also consider `const char typed[] = {ch, 0};`)



Comment at: lldb/source/Host/common/Editline.cpp:1068-1069
+ ansi::FormatAnsiTerminalCodes("${ansi.normal}");
+  fprintf(m_output_file, "%s", typed.c_str());
+  fprintf(m_output_file, "%s", to_add_color.c_str());
+  fflush(m_output_file);

maybe `fputs(typed.c_str(), m_output_file)`



Comment at: lldb/source/Host/common/Editline.cpp:1070
+  fprintf(m_output_file, "%s", to_add_color.c_str());
+  fflush(m_output_file);
+  MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);

Is the flush still necessary after the switch to `m_output_file`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001



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


[Lldb-commits] [PATCH] D81697: Add support for batch-testing to the LLDB testsuite.

2020-06-12 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

it looks like the official python unittest framework has grown support of a 
subtest  feature, 
which seems to be very similar to what we want here. It may make more sense to 
update to a newer framework rather than patching the copy that we have. Even if 
can't update for some reason, it would be good to do something equivalent to 
that so that it is easier to update in the future.

The part I like about the upstream solution is that it provides scoping for the 
failures -- so a single failure terminates a "subtest", but still lets the 
whole test continue. The reason this is important is when you have more complex 
"assertion" functions consisting of multiple smaller assertions. A typical 
example would be something like:

  def check_foo(foo):
assertGreater(len(foo), 2)
assertEquals(foo[0], 47)
assertEquals(foo[1], 42)
...
  
  def test():
with self.batchTest():
  check_foo(get_one_foo())
  check_foo(get_another_foo())
  ...

This patch essentially makes all assertions non-fatal, which means that if a 
first assertion in `check_foo` fails, the function will still continue and spew 
a bunch of uninteresting errors. With subtests, that won't happen -- the first 
assertion will abort the rest of the `check_foo` function, but it will let the 
other call continue (if it's in a different subtest):

  with self.subtest(): check_foo(get_one_foo())
  with self.subtest(): check_foo(get_another_foo())

This can result in a bit more typing, but that can be resolved by adding some 
extra sugar on top of that.For example, since the typical use case for this 
will be to run a bunch of independent expression (or frame var) commands, we 
could make a special version of the `expect_expr` command, which runs the 
expression in a subtest. (Or that might even be the default.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81697/new/

https://reviews.llvm.org/D81697



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


[Lldb-commits] [lldb] f52e412 - [lldb][NFC] Modernize TestPersistentVariables

2020-06-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-06-12T16:06:05+02:00
New Revision: f52e4129a7c748421543d6572806dfec2407bbd3

URL: 
https://github.com/llvm/llvm-project/commit/f52e4129a7c748421543d6572806dfec2407bbd3
DIFF: 
https://github.com/llvm/llvm-project/commit/f52e4129a7c748421543d6572806dfec2407bbd3.diff

LOG: [lldb][NFC] Modernize TestPersistentVariables

Added: 


Modified: 

lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
lldb/test/API/commands/expression/persistent_variables/main.c

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
 
b/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
index 57c04b215e97..af909e95f7fd 100644
--- 
a/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
+++ 
b/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
@@ -15,38 +15,16 @@ class PersistentVariablesTestCase(TestBase):
 def test_persistent_variables(self):
 """Test that lldb persistent variables works correctly."""
 self.build()
-
-self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
-
-self.runCmd("breakpoint set --source-pattern-regexp break")
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-self.runCmd("expression int $i = i")
-
-self.expect("expression $i == i",
-startstr="(bool) $0 = true")
-
-self.expect("expression $i + 1",
-startstr="(int) $1 = 6")
-
-self.expect("expression $i + 3",
-startstr="(int) $2 = 8")
-
-self.expect("expression $2 + $1",
-startstr="(int) $3 = 14")
-
-self.expect("expression $3",
-startstr="(int) $3 = 14")
-
-self.expect("expression $2",
-startstr="(int) $2 = 8")
-
-self.expect("expression (int)-2",
-startstr="(int) $4 = -2")
-
-self.expect("expression $4 > (int)31",
-startstr="(bool) $5 = false")
-
-self.expect("expression (long)$4",
-startstr="(long) $6 = -2")
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.c"))
+
+self.runCmd("expr int $i = i")
+self.expect_expr("$i == i", result_type="bool", result_value="true")
+self.expect_expr("$i + 1", result_type="int", result_value="6")
+self.expect_expr("$i + 3", result_type="int", result_value="8")
+self.expect_expr("$1 + $2", result_type="int", result_value="14")
+self.expect_expr("$3", result_type="int", result_value="14")
+self.expect_expr("$2", result_type="int", result_value="8")
+self.expect_expr("(int)-2", result_type="int", result_value="-2")
+self.expect_expr("$4", result_type="int", result_value="-2")
+self.expect_expr("$4 > (int)31", result_type="bool", 
result_value="false")
+self.expect_expr("(long)$4", result_type="long", result_value="-2")

diff  --git a/lldb/test/API/commands/expression/persistent_variables/main.c 
b/lldb/test/API/commands/expression/persistent_variables/main.c
index 970ee893510c..805df307ee98 100644
--- a/lldb/test/API/commands/expression/persistent_variables/main.c
+++ b/lldb/test/API/commands/expression/persistent_variables/main.c
@@ -1,5 +1,4 @@
-int main (int argc, char const *argv[])
-{
-int i = 5;
-return 0; // Set breakpoint here
+int main(int argc, char const *argv[]) {
+  int i = 5;
+  return 0; // break here
 }



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


[Lldb-commits] [lldb] a8c7555 - [lldb] Test creating persistent variables with $[digit] names

2020-06-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-06-12T16:12:33+02:00
New Revision: a8c755545b0c4ace9a5fff55dc56258204a6b69d

URL: 
https://github.com/llvm/llvm-project/commit/a8c755545b0c4ace9a5fff55dc56258204a6b69d
DIFF: 
https://github.com/llvm/llvm-project/commit/a8c755545b0c4ace9a5fff55dc56258204a6b69d.diff

LOG: [lldb] Test creating persistent variables with $[digit] names

Added: 


Modified: 

lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
 
b/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
index af909e95f7fd..ebe180998c63 100644
--- 
a/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
+++ 
b/lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
@@ -28,3 +28,16 @@ def test_persistent_variables(self):
 self.expect_expr("$4", result_type="int", result_value="-2")
 self.expect_expr("$4 > (int)31", result_type="bool", 
result_value="false")
 self.expect_expr("(long)$4", result_type="long", result_value="-2")
+
+# Try assigning an existing persistent veriable with a numeric name.
+self.expect("expr int $2 = 1234", error=True,
+substrs=["Error [IRForTarget]: Names starting with $0, $1, ... are 
reserved for use as result names"])
+# $2 should still have its original value.
+self.expect_expr("$2", result_type="int", result_value="8")
+
+# Try assigning an non-existing persistent veriable with a numeric 
name.
+self.expect("expr int $200 = 3", error=True,
+substrs=["Error [IRForTarget]: Names starting with $0, $1, ... are 
reserved for use as result names"])
+# Test that $200 wasn't created by the previous expression.
+self.expect("expr $200", error=True,
+substrs=["use of undeclared identifier '$200'"])



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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-06-12 Thread Shu Anzai via Phabricator via lldb-commits
gedatsu217 added inline comments.



Comment at: lldb/source/Core/Debugger.cpp:349
 
+bool Debugger::GetUseAutosuggestion() const {
+  const uint32_t idx = ePropertyShowAutosuggestion;

teemperor wrote:
> You declared the function, but you don't use it anywhere. You should move all 
> the code you added behind `if (GetShowAutosuggestion())` so that it is only 
> active if the user activated the setting (by doing `settings set 
> show-autosuggestion true`).
Sorry, would you tell me more about it?
I understood that I did not use this function, but I do not know how to 
validate it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001



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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-06-12 Thread Shu Anzai via Phabricator via lldb-commits
gedatsu217 added inline comments.



Comment at: lldb/source/Host/common/Editline.cpp:1244
+llvm::StringRef indent_chars =
+"abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY1234567890 ";
+for (char c : indent_chars) {

teemperor wrote:
> `.-/()[]{};\"'\\!@#$%^&*_` are missing here. Maybe we should just iterate 
> over all ASCII characters and add all printables except newline or something 
> like that to the alphabet.
If I add -, \, and ^, an error occurs because these characters  are probably 
used in other forms like -a (ll. 1283), \n (ll.1253), and  ^p (ll.1257). Do you 
know good ways to avoid it?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001



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


[Lldb-commits] [lldb] 2b34632 - [lldb/SymbolFile] Don't parse the whole line table for the support files

2020-06-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-12T09:39:17-07:00
New Revision: 2b34632a5771488ea62a30fdfcfc9d45060a7389

URL: 
https://github.com/llvm/llvm-project/commit/2b34632a5771488ea62a30fdfcfc9d45060a7389
DIFF: 
https://github.com/llvm/llvm-project/commit/2b34632a5771488ea62a30fdfcfc9d45060a7389.diff

LOG: [lldb/SymbolFile] Don't parse the whole line table for the support files

Prior to my patch of using the LLVM line table parsing code,
SymbolFileDWARF::ParseSupportFiles would only parse the line table
prologues to get the file list for any files that could be in the line
table.

With the old behavior, if we found the file that someone is setting the
breakpoint in in the support files list, we would get a valid index. If
we didn't, we would not look any further. So someone sets a breakpoint
one "MyFile.cpp:12" and if we find "MyFile.cpp" in the support file list
for the compile unit, then and only then would we get the entire line
table for that compile unit.

With the current behavior, no matter what, we always fully parse the
line table for all compile units any time any file and line breakpoint
is set. This creates a serious problem when debugging a large DWARF in
.o file project.

This patch re-instates the old behavior. Unfortunately it means we might
end up parsing to prologue twice, but I don't think that outweighs the
cost of trying to cache/reuse it.

Differential revision: https://reviews.llvm.org/D81589

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 6f2444b698ce..d662dcba4cdd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -162,18 +162,46 @@ ParseLLVMLineTable(lldb_private::DWARFContext &context,
   llvm::Expected line_table =
   line.getOrParseLineTable(
   data, line_offset, ctx, nullptr, [&](llvm::Error e) {
-LLDB_LOG_ERROR(log, std::move(e),
-   "SymbolFileDWARF::ParseLineTable failed to parse");
+LLDB_LOG_ERROR(
+log, std::move(e),
+"SymbolFileDWARF::ParseLineTable failed to parse: {0}");
   });
 
   if (!line_table) {
 LLDB_LOG_ERROR(log, line_table.takeError(),
-   "SymbolFileDWARF::ParseLineTable failed to parse");
+   "SymbolFileDWARF::ParseLineTable failed to parse: {0}");
 return nullptr;
   }
   return *line_table;
 }
 
+static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context,
+   llvm::DWARFDebugLine::Prologue 
&prologue,
+   dw_offset_t line_offset,
+   dw_offset_t unit_offset) {
+  Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+  bool success = true;
+  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
+  llvm::DWARFContext &ctx = context.GetAsLLVM();
+  uint64_t offset = line_offset;
+  llvm::Error error = prologue.parse(
+  data, &offset,
+  [&](llvm::Error e) {
+success = false;
+LLDB_LOG_ERROR(log, std::move(e),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse "
+   "line table prologue: {0}");
+  },
+  ctx, nullptr);
+  if (error) {
+LLDB_LOG_ERROR(log, std::move(error),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse line "
+   "table prologue: {0}");
+return false;
+  }
+  return success;
+}
+
 static llvm::Optional
 GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
llvm::StringRef compile_dir, FileSpec::Style style) {
@@ -854,8 +882,24 @@ bool SymbolFileDWARF::ForEachExternalModule(
 
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
-  if (!comp_unit.GetLineTable())
-ParseLineTable(comp_unit);
+  std::lock_guard guard(GetModuleMutex());
+  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
+  if (!dwarf_cu)
+return false;
+
+  dw_offset_t offset = dwarf_cu->GetLineTableOffset();
+  if (offset == DW_INVALID_OFFSET)
+return false;
+
+  llvm::DWARFDebugLine::Prologue prologue;
+  if (!ParseLLVMLineTablePrologue(m_context, prologue, offset,
+  dwarf_cu->GetOffset()))
+return false;
+
+  comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
+  comp_unit.GetModule(), prologue, dwarf_cu->GetPathStyle(),
+  dwarf_cu->GetCompilationDirectory().GetCString()));
+
   return true;
 }
 
@@ -978,18 +1022,13 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit 
&comp_unit) {
   if (!dwarf_cu)
 return false;
 
- 

[Lldb-commits] [PATCH] D81589: [lldb/SymbolFile] Don't parse the whole line table for the support files

2020-06-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b34632a5771: [lldb/SymbolFile] Don't parse the whole 
line table for the support files (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D81589?vs=270184&id=270432#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81589/new/

https://reviews.llvm.org/D81589

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -162,18 +162,46 @@
   llvm::Expected line_table =
   line.getOrParseLineTable(
   data, line_offset, ctx, nullptr, [&](llvm::Error e) {
-LLDB_LOG_ERROR(log, std::move(e),
-   "SymbolFileDWARF::ParseLineTable failed to parse");
+LLDB_LOG_ERROR(
+log, std::move(e),
+"SymbolFileDWARF::ParseLineTable failed to parse: {0}");
   });
 
   if (!line_table) {
 LLDB_LOG_ERROR(log, line_table.takeError(),
-   "SymbolFileDWARF::ParseLineTable failed to parse");
+   "SymbolFileDWARF::ParseLineTable failed to parse: {0}");
 return nullptr;
   }
   return *line_table;
 }
 
+static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context,
+   llvm::DWARFDebugLine::Prologue &prologue,
+   dw_offset_t line_offset,
+   dw_offset_t unit_offset) {
+  Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+  bool success = true;
+  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
+  llvm::DWARFContext &ctx = context.GetAsLLVM();
+  uint64_t offset = line_offset;
+  llvm::Error error = prologue.parse(
+  data, &offset,
+  [&](llvm::Error e) {
+success = false;
+LLDB_LOG_ERROR(log, std::move(e),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse "
+   "line table prologue: {0}");
+  },
+  ctx, nullptr);
+  if (error) {
+LLDB_LOG_ERROR(log, std::move(error),
+   "SymbolFileDWARF::ParseSupportFiles failed to parse line "
+   "table prologue: {0}");
+return false;
+  }
+  return success;
+}
+
 static llvm::Optional
 GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
llvm::StringRef compile_dir, FileSpec::Style style) {
@@ -854,8 +882,24 @@
 
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
-  if (!comp_unit.GetLineTable())
-ParseLineTable(comp_unit);
+  std::lock_guard guard(GetModuleMutex());
+  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
+  if (!dwarf_cu)
+return false;
+
+  dw_offset_t offset = dwarf_cu->GetLineTableOffset();
+  if (offset == DW_INVALID_OFFSET)
+return false;
+
+  llvm::DWARFDebugLine::Prologue prologue;
+  if (!ParseLLVMLineTablePrologue(m_context, prologue, offset,
+  dwarf_cu->GetOffset()))
+return false;
+
+  comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
+  comp_unit.GetModule(), prologue, dwarf_cu->GetPathStyle(),
+  dwarf_cu->GetCompilationDirectory().GetCString()));
+
   return true;
 }
 
@@ -978,18 +1022,13 @@
   if (!dwarf_cu)
 return false;
 
-  const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
-  if (!dwarf_cu_die)
-return false;
-
-  const dw_offset_t cu_line_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(
-  DW_AT_stmt_list, DW_INVALID_OFFSET);
-  if (cu_line_offset == DW_INVALID_OFFSET)
+  dw_offset_t offset = dwarf_cu->GetLineTableOffset();
+  if (offset == DW_INVALID_OFFSET)
 return false;
 
   llvm::DWARFDebugLine line;
-  const llvm::DWARFDebugLine::LineTable *line_table = ParseLLVMLineTable(
-  m_context, line, cu_line_offset, dwarf_cu->GetOffset());
+  const llvm::DWARFDebugLine::LineTable *line_table =
+  ParseLLVMLineTable(m_context, line, offset, dwarf_cu->GetOffset());
 
   if (!line_table)
 return false;
@@ -1024,10 +1063,6 @@
 comp_unit.SetLineTable(line_table_up.release());
   }
 
-  comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
-  comp_unit.GetModule(), line_table->Prologue, dwarf_cu->GetPathStyle(),
-  dwarf_cu->GetCompilationDirectory().GetCString()));
-
   return true;
 }
 
@@ -2387,7 +2422,7 @@
 UpdateExternalModuleListIfNeeded();
 
 for (const auto &pair : m_external_type_modules)
-  if (ModuleSP external_module_sp = pair.second) 
+  if (ModuleSP external_module_sp = pair.second)
 if (SymbolFile *sym_file = external_mod

[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-06-12 Thread Shu Anzai via Phabricator via lldb-commits
gedatsu217 updated this revision to Diff 270454.
gedatsu217 added a comment.

I updated my codes according to your advice:

Add if(GetUseAutosuggestion()) in IOHandlerSuggestion in IOHandler.cpp. (Is 
this not enough?)
Add more keybinds for TypedCharacter.
Return llvm::Optional in HandleSuggestion in 
CommandInterpreter.cpp.

and several minor change...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Host/common/Editline.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp

Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1866,6 +1866,21 @@
   HandleCompletionMatches(request);
 }
 
+llvm::Optional
+CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line,
+std::string &result) {
+  const size_t s = m_command_history.GetSize();
+  for (size_t i = 0; i < s; ++i) {
+llvm::StringRef entry = m_command_history.GetStringAtIndex(i);
+if (entry.startswith(line)) {
+  llvm::StringRef res = entry.substr(line.size());
+  result = res.str();
+  return result;
+}
+  }
+  return llvm::None;
+}
+
 CommandInterpreter::~CommandInterpreter() {}
 
 void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) {
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Host/Editline.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/CompletionRequest.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBAssert.h"
@@ -1040,6 +1041,36 @@
   return CC_REDISPLAY;
 }
 
+unsigned char Editline::ApplyCompleteCommand(int ch) {
+  el_insertstr(m_editline, m_current_autosuggestion.c_str());
+  m_current_autosuggestion = "";
+  return CC_REDISPLAY;
+}
+
+unsigned char Editline::TypedCharacter(int ch) {
+  std::string typed = std::string(1, ch);
+  el_insertstr(m_editline, typed.c_str());
+  const LineInfo *line_info = el_line(m_editline);
+  llvm::StringRef line(line_info->buffer,
+   line_info->lastchar - line_info->buffer);
+
+  std::string to_add;
+  m_suggestion_callback(line, to_add, m_suggestion_callback_baton);
+  m_current_autosuggestion = to_add;
+
+  if (to_add.empty())
+return CC_REDISPLAY;
+
+  std::string to_add_color = ansi::FormatAnsiTerminalCodes("${ansi.faint}") +
+ to_add +
+ ansi::FormatAnsiTerminalCodes("${ansi.normal}");
+  fputs(typed.c_str(), m_output_file);
+  fputs(to_add_color.c_str(), m_output_file);
+  MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt);
+
+  return CC_REFRESH;
+}
+
 void Editline::ConfigureEditor(bool multiline) {
   if (m_editline && m_multiline_enabled == multiline)
 return;
@@ -1159,6 +1190,21 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-apply-complete"),
+  EditLineConstString("Adopt autocompletion"),
+  (EditlineCommandCallbackType)([](EditLine *editline, int ch) {
+return Editline::InstanceFor(editline)->ApplyCompleteCommand(ch);
+  }));
+
+  el_set(m_editline, EL_BIND, "^f", "lldb-apply-complete",
+ NULL); // Apply a part that is suggested automatically
+
+  el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-typed-character"),
+  EditLineConstString("Typed character"),
+  (EditlineCommandCallbackType)([](EditLine *editline, int ch) {
+return Editline::InstanceFor(editline)->TypedCharacter(ch);
+  }));
+
   // Allow ctrl-left-arrow and ctrl-right-arrow for navigation, behave like
   // bash in emacs mode.
   el_set(m_editline, EL_BIND, ESCAPE "[1;5C", "em-next-word", NULL);
@@ -1190,6 +1236,17 @@
 }
   }
 
+  if (true) {
+char bind_key[2] = {0, 0};
+llvm::StringRef indent_chars =
+"abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY1234567890!\"#$%&'"
+"()*+,./:;<=>?@[]_`{|}~ ";
+for (char c : indent_chars) {
+  bind_key[0] = c;
+  el_set(m_editline, EL_BIND, bind_key, "lldb-typed-character", NULL);
+}
+  }
+
   // Multi-line editor bindings
   if (multiline) {
 el_set(m_editline, EL_BIND, "\n", "lldb-end-or-add-line", NULL);
@@ -1364,6 +1421,12 @@
   return result;
 }
 
+void Editline::Se

[Lldb-commits] [PATCH] D80112: Check if thread was suspended during previous stop added.

2020-06-12 Thread Ilya Bukonkin via Phabricator via lldb-commits
fallkrum added a comment.

Guys help me figure out what may be wrong. Executed below listed command and 
can't find my newly added unit tests ThreadTest, ProcessEventDataTest.

  Ilyas-Mac-mini:Ninja ilya$ ./bin/llvm-lit --show-tests -sv 
../../lldb/test/Unit
  -- Available Tests --
lldb-unit :: API/./APITests/SBCommandInterpreterTest.MultiWordCommand
lldb-unit :: API/./APITests/SBCommandInterpreterTest.SingleWordCommand
lldb-unit :: 
Breakpoint/./LLDBBreakpointTests/BreakpointIDTest.StringIsBreakpointName
lldb-unit :: Core/./LLDBCoreTests/CommunicationTest.SynchronizeWhileClosing
lldb-unit :: Core/./LLDBCoreTests/MangledTest.EmptyForInvalidName
lldb-unit :: 
Core/./LLDBCoreTests/MangledTest.NameIndexes_FindFunctionSymbols
lldb-unit :: Core/./LLDBCoreTests/MangledTest.ResultForBlockInvocation
lldb-unit :: Core/./LLDBCoreTests/MangledTest.ResultForValidName
lldb-unit :: Core/./LLDBCoreTests/RichManglingContextTest.Basic
lldb-unit :: Core/./LLDBCoreTests/RichManglingContextTest.FromCxxMethodName
lldb-unit :: Core/./LLDBCoreTests/RichManglingContextTest.IPDRealloc
lldb-unit :: Core/./LLDBCoreTests/RichManglingContextTest.SwitchProvider
lldb-unit :: Core/./LLDBCoreTests/SourceFileCache.FindSourceFileFound
lldb-unit :: Core/./LLDBCoreTests/SourceFileCache.FindSourceFileNotFound
lldb-unit :: Core/./LLDBCoreTests/StreamCallbackTest.Callback
lldb-unit :: Core/./LLDBCoreTests/UniqueCStringMap.NoDefaultConstructor
lldb-unit :: 
DataFormatter/./LLDBFormatterTests/FormatManagerTests.CompatibleLangs
lldb-unit :: DataFormatter/./LLDBFormatterTests/StringPrinterTests.CxxASCII
lldb-unit :: DataFormatter/./LLDBFormatterTests/StringPrinterTests.CxxUTF8
lldb-unit :: DataFormatter/./LLDBFormatterTests/StringPrinterTests.SwiftUTF8
lldb-unit :: 
Disassembler/./DisassemblerTests/TestArm64Disassembly.TestArmv81Instruction
lldb-unit :: 
Disassembler/./DisassemblerTests/TestArmv7Disassembly.TestCortexFPDisass
lldb-unit :: 
Editline/./EditlineTests/EditlineTestFixture.EditlineReceivesMultiLineText
lldb-unit :: 
Editline/./EditlineTests/EditlineTestFixture.EditlineReceivesSingleLineText
lldb-unit :: 
Expression/./ExpressionTests/ClangExpressionDeclMapTest.TestPersistentDeclLookup
lldb-unit :: 
Expression/./ExpressionTests/ClangExpressionDeclMapTest.TestUnknownIdentifierLookup
lldb-unit :: 
Expression/./ExpressionTests/ClangHostTest.ComputeClangResourceDirectory
lldb-unit :: Expression/./ExpressionTests/ClangHostTest.MacOSX
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.AmbiguousCLib
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.AmbiguousLibCpp
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.IgnoreLibStdCpp
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.LibCppV2
lldb-unit :: Expression/./ExpressionTests/CppModuleConfigurationTest.Linux
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.LinuxLocalLibCpp
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.MissingLibCpp
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.MissingUsrInclude
lldb-unit :: Expression/./ExpressionTests/CppModuleConfigurationTest.Sysroot
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.UnknownLibCppFile
lldb-unit :: 
Expression/./ExpressionTests/CppModuleConfigurationTest.UnrelatedLibrary
lldb-unit :: Expression/./ExpressionTests/CppModuleConfigurationTest.Xcode
lldb-unit :: Expression/./ExpressionTests/DWARFExpression.DW_OP_convert
lldb-unit :: Expression/./ExpressionTests/DWARFExpression.DW_OP_pick
lldb-unit :: Expression/./ExpressionTests/DWARFExpression.DW_OP_piece
lldb-unit :: Expression/./ExpressionTests/DWARFExpression.DW_OP_stack_value
lldb-unit :: Expression/./ExpressionTests/DWARFExpression.DW_OP_unknown
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.AddDiagnostic
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.AppendMessageAttachToLastDiag
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.AppendMessageNoDiag
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.AppendMessageSubsequentDiags
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.FixedExpression
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.GetStringBasic
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.GetStringMultiline
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.GetStringMultipleDiags
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.GetStringNoDiags
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.GetStringPreserveOrder
lldb-unit :: 
Expression/./ExpressionTests/DiagnosticManagerTest.GetStringSeverityLabels
lldb-unit :: Expression/./Expres

[Lldb-commits] [lldb] bfea1df - [lldb/Test] Fix unittest name

2020-06-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-12T14:01:14-07:00
New Revision: bfea1df9f01393bac6d2ce6a45d3b764b01e9e9e

URL: 
https://github.com/llvm/llvm-project/commit/bfea1df9f01393bac6d2ce6a45d3b764b01e9e9e
DIFF: 
https://github.com/llvm/llvm-project/commit/bfea1df9f01393bac6d2ce6a45d3b764b01e9e9e.diff

LOG: [lldb/Test] Fix unittest name

Lit looks for the Tests prefix in the unit test name.

Added: 


Modified: 
lldb/unittests/Process/CMakeLists.txt
lldb/unittests/Thread/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/Process/CMakeLists.txt 
b/lldb/unittests/Process/CMakeLists.txt
index 50d0e75167ea..e068908d09fb 100644
--- a/lldb/unittests/Process/CMakeLists.txt
+++ b/lldb/unittests/Process/CMakeLists.txt
@@ -5,7 +5,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
 endif()
 add_subdirectory(minidump)
 
-add_lldb_unittest(ProcessEventDataTest
+add_lldb_unittest(ProcessEventDataTests
   ProcessEventDataTest.cpp
 
   LINK_LIBS

diff  --git a/lldb/unittests/Thread/CMakeLists.txt 
b/lldb/unittests/Thread/CMakeLists.txt
index aa5b777f4b2e..d6e365adac5d 100644
--- a/lldb/unittests/Thread/CMakeLists.txt
+++ b/lldb/unittests/Thread/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_lldb_unittest(ThreadTest
+add_lldb_unittest(ThreadTests
   ThreadTest.cpp
 
   LINK_LIBS



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


[Lldb-commits] [PATCH] D81612: [lldb/Test] Assert that no targets or global modules remain after a test completes.

2020-06-12 Thread Vedant Kumar via Phabricator via lldb-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Lgtm.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81612/new/

https://reviews.llvm.org/D81612



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


[Lldb-commits] [PATCH] D80112: Check if thread was suspended during previous stop added.

2020-06-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D80112#2090723 , @fallkrum wrote:

> Guys help me figure out what may be wrong. Executed below listed command and 
> can't find my newly added unit tests ThreadTest, ProcessEventDataTest.


Fixed in `bfea1df9f01393bac6d2ce6a45d3b764b01e9e9e`. Lit filters on the `Tests` 
suffix (note the trailings). I'll add a warning to `add_lldb_unittest` to 
prevent this from happening in the future.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80112/new/

https://reviews.llvm.org/D80112



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


[Lldb-commits] [lldb] 8f9eb70 - [lldb/Test] Fix unit test suffixes and add a CMake error.

2020-06-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-12T14:18:27-07:00
New Revision: 8f9eb7035344715194d73272b2f15205ea362f58

URL: 
https://github.com/llvm/llvm-project/commit/8f9eb7035344715194d73272b2f15205ea362f58
DIFF: 
https://github.com/llvm/llvm-project/commit/8f9eb7035344715194d73272b2f15205ea362f58.diff

LOG: [lldb/Test] Fix unit test suffixes and add a CMake error.

Lit will only look for unittest targets ending in `Tests`. Add an error
when the target doesn't have the `Tests` suffix.

Added: 


Modified: 
lldb/unittests/CMakeLists.txt
lldb/unittests/Platform/Android/CMakeLists.txt
lldb/unittests/Process/Linux/CMakeLists.txt
lldb/unittests/Process/POSIX/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index 52f5c964fcee..6422b726ca69 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -33,6 +33,10 @@ function(add_lldb_unittest test_name)
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN})
 
+  if (NOT ${test_name} MATCHES "Tests$")
+message(FATAL_ERROR "Unit test name must end with 'Tests' for lit to find 
it.")
+  endif()
+
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
 
   add_unittest(LLDBUnitTests

diff  --git a/lldb/unittests/Platform/Android/CMakeLists.txt 
b/lldb/unittests/Platform/Android/CMakeLists.txt
index 3de2a2d12016..489fdab7036c 100644
--- a/lldb/unittests/Platform/Android/CMakeLists.txt
+++ b/lldb/unittests/Platform/Android/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${LLDB_SOURCE_DIR}/source/Plugins/Platform/Android)
 
-add_lldb_unittest(AdbClientTest
+add_lldb_unittest(AdbClientTests
   AdbClientTest.cpp
 
   LINK_LIBS

diff  --git a/lldb/unittests/Process/Linux/CMakeLists.txt 
b/lldb/unittests/Process/Linux/CMakeLists.txt
index 3b55b5c84305..31e9a57a4e46 100644
--- a/lldb/unittests/Process/Linux/CMakeLists.txt
+++ b/lldb/unittests/Process/Linux/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${LLDB_SOURCE_DIR}/source/Plugins/Process/Linux)
 
-add_lldb_unittest(ProcessorTraceTest
+add_lldb_unittest(ProcessorTraceTests
   ProcessorTraceTest.cpp
 
   LINK_LIBS

diff  --git a/lldb/unittests/Process/POSIX/CMakeLists.txt 
b/lldb/unittests/Process/POSIX/CMakeLists.txt
index 53318d908da7..eabfb58d46fc 100644
--- a/lldb/unittests/Process/POSIX/CMakeLists.txt
+++ b/lldb/unittests/Process/POSIX/CMakeLists.txt
@@ -1,6 +1,6 @@
 include_directories(${LLDB_SOURCE_DIR}/source/Plugins/Process/POSIX)
 
-add_lldb_unittest(ProcessPOSIXTest
+add_lldb_unittest(ProcessPOSIXTests
   NativeProcessELFTest.cpp
 
   LINK_LIBS



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


[Lldb-commits] [PATCH] D80112: Check if thread was suspended during previous stop added.

2020-06-12 Thread Ilya Bukonkin via Phabricator via lldb-commits
fallkrum added a comment.

In D80112#2090767 , @JDevlieghere 
wrote:

> In D80112#2090723 , @fallkrum wrote:
>
> > Guys help me figure out what may be wrong. Executed below listed command 
> > and can't find my newly added unit tests ThreadTest, ProcessEventDataTest.
>
>
> Fixed in `bfea1df9f01393bac6d2ce6a45d3b764b01e9e9e`. Lit filters on the 
> `Tests` suffix (note the trailings). I'll add a warning to 
> `add_lldb_unittest` to prevent this from happening in the future.


Thanks, I’v already started to think we forgot to add something in somewhere :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80112/new/

https://reviews.llvm.org/D80112



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


[Lldb-commits] [lldb] da601ea - [lldb/Test] Assert that no targets or modules remain after a test completes.

2020-06-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-12T15:17:44-07:00
New Revision: da601ea731ece45d8e4d283942f90dce5b2d386a

URL: 
https://github.com/llvm/llvm-project/commit/da601ea731ece45d8e4d283942f90dce5b2d386a
DIFF: 
https://github.com/llvm/llvm-project/commit/da601ea731ece45d8e4d283942f90dce5b2d386a.diff

LOG: [lldb/Test] Assert that no targets or modules remain after a test 
completes.

The reproducer intentionally leak every object allocated during replay,
which means that modules never get orphaned. If this were to happen for
another reason, we might not be testing what we think we are. Assert
that there are no targets left at the end of a test and that the global
module cache is empty in the non-reproducer scenario.

Differential revision: https://reviews.llvm.org/D81612

Added: 


Modified: 
lldb/bindings/interface/SBModule.i
lldb/include/lldb/API/SBModule.h
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBModule.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBModule.i 
b/lldb/bindings/interface/SBModule.i
index a9d9480cd7cf..e902af0c49ce 100644
--- a/lldb/bindings/interface/SBModule.i
+++ b/lldb/bindings/interface/SBModule.i
@@ -344,6 +344,15 @@ public:
 lldb::SBAddress
 GetObjectFileEntryPointAddress() const;
 
+%feature("docstring", "
+Returns the number of modules in the module cache. This is an
+implementation detail exposed for testing and should not be relied upon.
+
+@return
+The number of modules in the module cache.") GetNumberAllocatedModules;
+static uint32_t
+GetNumberAllocatedModules();
+
 STRING_EXTENSION(SBModule)
 
 #ifdef SWIGPYTHON

diff  --git a/lldb/include/lldb/API/SBModule.h 
b/lldb/include/lldb/API/SBModule.h
index 183e451662eb..859eaffe89a0 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -288,6 +288,9 @@ class LLDB_API SBModule {
   lldb::SBAddress GetObjectFileHeaderAddress() const;
   lldb::SBAddress GetObjectFileEntryPointAddress() const;
 
+  /// Get the number of global modules.
+  static uint32_t GetNumberAllocatedModules();
+
 private:
   friend class SBAddress;
   friend class SBFrame;

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index cad7a127e752..7190be6be9b3 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2018,10 +2018,18 @@ def tearDown(self):
 process = target.GetProcess()
 if process:
 rc = self.invoke(process, "Kill")
-self.assertTrue(rc.Success(), PROCESS_KILLED)
+assert rc.Success()
 for target in targets:
 self.dbg.DeleteTarget(target)
 
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that all targets are deleted.
+assert self.dbg.GetNumTargets() == 0
+# Assert that the global module cache is empty.
+assert lldb.SBModule.GetNumberAllocatedModules() == 0
+
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
 

diff  --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 0811a3a9b234..c30529b37eb1 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -683,6 +683,13 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() 
const {
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+uint32_t SBModule::GetNumberAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+GetNumberAllocatedModules);
+
+  return Module::GetNumberAllocatedModules();
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -757,6 +764,8 @@ void RegisterMethods(Registry &R) {
  GetObjectFileHeaderAddress, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
  GetObjectFileEntryPointAddress, ());
+  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+  ());
 }
 
 }



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


[Lldb-commits] [PATCH] D81612: [lldb/Test] Assert that no targets or global modules remain after a test completes.

2020-06-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda601ea731ec: [lldb/Test] Assert that no targets or modules 
remain after a test completes. (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D81612?vs=270017&id=270530#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81612/new/

https://reviews.llvm.org/D81612

Files:
  lldb/bindings/interface/SBModule.i
  lldb/include/lldb/API/SBModule.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBModule.cpp


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -683,6 +683,13 @@
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+uint32_t SBModule::GetNumberAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+GetNumberAllocatedModules);
+
+  return Module::GetNumberAllocatedModules();
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -757,6 +764,8 @@
  GetObjectFileHeaderAddress, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
  GetObjectFileEntryPointAddress, ());
+  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+  ());
 }
 
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2018,10 +2018,18 @@
 process = target.GetProcess()
 if process:
 rc = self.invoke(process, "Kill")
-self.assertTrue(rc.Success(), PROCESS_KILLED)
+assert rc.Success()
 for target in targets:
 self.dbg.DeleteTarget(target)
 
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that all targets are deleted.
+assert self.dbg.GetNumTargets() == 0
+# Assert that the global module cache is empty.
+assert lldb.SBModule.GetNumberAllocatedModules() == 0
+
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
 
Index: lldb/include/lldb/API/SBModule.h
===
--- lldb/include/lldb/API/SBModule.h
+++ lldb/include/lldb/API/SBModule.h
@@ -288,6 +288,9 @@
   lldb::SBAddress GetObjectFileHeaderAddress() const;
   lldb::SBAddress GetObjectFileEntryPointAddress() const;
 
+  /// Get the number of global modules.
+  static uint32_t GetNumberAllocatedModules();
+
 private:
   friend class SBAddress;
   friend class SBFrame;
Index: lldb/bindings/interface/SBModule.i
===
--- lldb/bindings/interface/SBModule.i
+++ lldb/bindings/interface/SBModule.i
@@ -344,6 +344,15 @@
 lldb::SBAddress
 GetObjectFileEntryPointAddress() const;
 
+%feature("docstring", "
+Returns the number of modules in the module cache. This is an
+implementation detail exposed for testing and should not be relied upon.
+
+@return
+The number of modules in the module cache.") GetNumberAllocatedModules;
+static uint32_t
+GetNumberAllocatedModules();
+
 STRING_EXTENSION(SBModule)
 
 #ifdef SWIGPYTHON


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -683,6 +683,13 @@
   return LLDB_RECORD_RESULT(sb_addr);
 }
 
+uint32_t SBModule::GetNumberAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+GetNumberAllocatedModules);
+
+  return Module::GetNumberAllocatedModules();
+}
+
 namespace lldb_private {
 namespace repro {
 
@@ -757,6 +764,8 @@
  GetObjectFileHeaderAddress, ());
   LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
  GetObjectFileEntryPointAddress, ());
+  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+  ());
 }
 
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2018,10 +2018,18 @@
 process = target.GetProcess()
 if process:
 rc = self.invoke(process, "Kill")
-self.assertTrue(rc.Success(), PROCESS_KILLED)
+assert rc.Success()
 for t

[Lldb-commits] [PATCH] D81697: Add support for batch-testing to the LLDB testsuite.

2020-06-12 Thread Benson Li via Phabricator via lldb-commits
bbli added a comment.

- Ohh ok, guess I should have gotten the point about catching all exceptions 
recursively clarified before I began.

- From looking at the code for `subTest`, the error catching functionality 
comes from `Outcome_object.testPartExecutor` context manager, and the rest 
seems to be subTest specific. The repo's version of unittest2 has not defined 
the `Outcome` class, however. Should I port over just this class then? In 
regards to updating to the newer framework, I personally am not confident in 
myself doing so as I do not know the exact specifics of why the fork was made, 
and from what I have been told, the version of unittest2 we have in the repo is 
about 10 years old.

- Also, `testPartExecutor` will catch all exceptions, but I believe we want to 
exit early and propagate non `self.failureException` errors all the way up for 
`runMethod` to handle, correct?

- Finally, by `expect_expr`, are you referring to the "expect*" methods that 
are defined in lldbtest.py? And are you suggesting to have the error handling 
context manager to be called inside these functions? Because wouldn't that lead 
to the same problem of having a function continue in the situation where the 
function has multiple `expect_expr` commands?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81697/new/

https://reviews.llvm.org/D81697



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


[Lldb-commits] [lldb] 58e34ed - [lldb] Small improvements in ValueObjectPrinter::PrintDecl (NFC)

2020-06-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-12T21:05:05-07:00
New Revision: 58e34ede5bf741cfc47b3ebd573ae7dfdf9e9c02

URL: 
https://github.com/llvm/llvm-project/commit/58e34ede5bf741cfc47b3ebd573ae7dfdf9e9c02
DIFF: 
https://github.com/llvm/llvm-project/commit/58e34ede5bf741cfc47b3ebd573ae7dfdf9e9c02.diff

LOG: [lldb] Small improvements in ValueObjectPrinter::PrintDecl (NFC)

Remove unused argument, simply code and reformat.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
lldb/source/DataFormatters/ValueObjectPrinter.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h 
b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
index dda91e4178e6..f1301d8595b1 100644
--- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -57,7 +57,7 @@ class ValueObjectPrinter {
 
   const char *GetDescriptionForDisplay();
 
-  const char *GetRootNameForDisplay(const char *if_fail = nullptr);
+  const char *GetRootNameForDisplay();
 
   bool ShouldPrintValueObject();
 

diff  --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 350d6cde5191..c8a306334cf5 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -151,11 +151,11 @@ const char 
*ValueObjectPrinter::GetDescriptionForDisplay() {
   return str;
 }
 
-const char *ValueObjectPrinter::GetRootNameForDisplay(const char *if_fail) {
+const char *ValueObjectPrinter::GetRootNameForDisplay() {
   const char *root_valobj_name = m_options.m_root_valobj_name.empty()
  ? m_valobj->GetName().AsCString()
  : m_options.m_root_valobj_name.c_str();
-  return root_valobj_name ? root_valobj_name : if_fail;
+  return root_valobj_name ? root_valobj_name : "";
 }
 
 bool ValueObjectPrinter::ShouldPrintValueObject() {
@@ -239,17 +239,14 @@ void ValueObjectPrinter::PrintDecl() {
 // type if there is one to print
 ConstString type_name;
 if (m_compiler_type.IsValid()) {
-  if (m_options.m_use_type_display_name)
-type_name = m_valobj->GetDisplayTypeName();
-  else
-type_name = m_valobj->GetQualifiedTypeName();
+  type_name = m_options.m_use_type_display_name
+  ? m_valobj->GetDisplayTypeName()
+  : m_valobj->GetQualifiedTypeName();
 } else {
   // only show an invalid type name if the user explicitly triggered
   // show_type
   if (m_options.m_show_types)
 type_name = ConstString("");
-  else
-type_name.Clear();
 }
 
 if (type_name) {
@@ -260,7 +257,7 @@ void ValueObjectPrinter::PrintDecl() {
   type_name_str.erase(iter, 2);
 }
   }
-  typeName.Printf("%s", type_name_str.c_str());
+  typeName << type_name_str.c_str();
 }
   }
 
@@ -269,10 +266,8 @@ void ValueObjectPrinter::PrintDecl() {
   if (!m_options.m_hide_name) {
 if (m_options.m_flat_output)
   m_valobj->GetExpressionPath(varName);
-else {
-  const char *name_cstr = GetRootNameForDisplay("");
-  varName.Printf("%s", name_cstr);
-}
+else
+  varName << GetRootNameForDisplay();
   }
 
   bool decl_printed = false;
@@ -448,9 +443,9 @@ bool 
ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
 // If the description already ends with a \n don't add another one.
 size_t object_end = strlen(object_desc) - 1;
 if (object_desc[object_end] == '\n')
-m_stream->Printf("%s", object_desc);
+  m_stream->Printf("%s", object_desc);
 else
-m_stream->Printf("%s\n", object_desc);
+  m_stream->Printf("%s\n", object_desc);
 return true;
   } else if (!value_printed && !summary_printed)
 return true;



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


[Lldb-commits] [lldb] ff058e7 - [lldb] Remove unnecessary c_str() in OutputFormattedHelpText calls (NFC)

2020-06-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-12T21:13:21-07:00
New Revision: ff058e7331afb16108a8f888dff671ae0240268f

URL: 
https://github.com/llvm/llvm-project/commit/ff058e7331afb16108a8f888dff671ae0240268f
DIFF: 
https://github.com/llvm/llvm-project/commit/ff058e7331afb16108a8f888dff671ae0240268f.diff

LOG: [lldb] Remove unnecessary c_str() in OutputFormattedHelpText calls (NFC)

Added: 


Modified: 
lldb/source/Commands/CommandObjectMultiword.cpp
lldb/source/Interpreter/CommandObject.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index ca0e058430bc..9033cfebf46b 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -167,13 +167,12 @@ void CommandObjectMultiword::GenerateHelpText(Stream 
&output_stream) {
 if (pos->second->WantsRawCommandString()) {
   std::string help_text(std::string(pos->second->GetHelp()));
   help_text.append("  Expects 'raw' input (see 'help raw-input'.)");
-  m_interpreter.OutputFormattedHelpText(output_stream,
-indented_command.c_str(), "--",
-help_text.c_str(), max_len);
+  m_interpreter.OutputFormattedHelpText(output_stream, indented_command,
+"--", help_text, max_len);
 } else
-  m_interpreter.OutputFormattedHelpText(output_stream,
-indented_command.c_str(), "--",
-pos->second->GetHelp(), max_len);
+  m_interpreter.OutputFormattedHelpText(output_stream, indented_command,
+"--", pos->second->GetHelp(),
+max_len);
   }
 
   output_stream.PutCString("\nFor more help on any particular subcommand, type 
"

diff  --git a/lldb/source/Interpreter/CommandObject.cpp 
b/lldb/source/Interpreter/CommandObject.cpp
index dfae7bec64f7..64a46e3f14f0 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -836,8 +836,8 @@ void CommandObject::FormatLongHelpText(Stream &output_strm,
 }
 std::string whitespace_prefix = line.substr(0, result);
 std::string remainder = line.substr(result);
-interpreter.OutputFormattedHelpText(output_strm, whitespace_prefix.c_str(),
-remainder.c_str());
+interpreter.OutputFormattedHelpText(output_strm, whitespace_prefix,
+remainder);
   }
 }
 
@@ -852,8 +852,7 @@ void CommandObject::GenerateHelpText(Stream &output_strm) {
   if (WantsRawCommandString()) {
 std::string help_text(GetHelp());
 help_text.append("  Expects 'raw' input (see 'help raw-input'.)");
-interpreter.OutputFormattedHelpText(output_strm, "", "", help_text.c_str(),
-1);
+interpreter.OutputFormattedHelpText(output_strm, "", "", help_text, 1);
   } else
 interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1);
   output_strm << "\nSyntax: " << GetSyntax() << "\n";



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


[Lldb-commits] [PATCH] D81783: [lldb] Remove indentation before help output.

2020-06-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 270564.
JDevlieghere added a comment.

Explicit `llvm::StringRef` -> `std::string` conversion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81783/new/

https://reviews.llvm.org/D81783

Files:
  lldb/source/Interpreter/CommandObject.cpp


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -849,12 +849,11 @@
 
 void CommandObject::GenerateHelpText(Stream &output_strm) {
   CommandInterpreter &interpreter = GetCommandInterpreter();
+  std::string help_text(GetHelp());
   if (WantsRawCommandString()) {
-std::string help_text(GetHelp());
 help_text.append("  Expects 'raw' input (see 'help raw-input'.)");
-interpreter.OutputFormattedHelpText(output_strm, "", "", help_text, 1);
-  } else
-interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1);
+  }
+  interpreter.OutputFormattedHelpText(output_strm, "", help_text);
   output_strm << "\nSyntax: " << GetSyntax() << "\n";
   Options *options = GetOptions();
   if (options != nullptr) {


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -849,12 +849,11 @@
 
 void CommandObject::GenerateHelpText(Stream &output_strm) {
   CommandInterpreter &interpreter = GetCommandInterpreter();
+  std::string help_text(GetHelp());
   if (WantsRawCommandString()) {
-std::string help_text(GetHelp());
 help_text.append("  Expects 'raw' input (see 'help raw-input'.)");
-interpreter.OutputFormattedHelpText(output_strm, "", "", help_text, 1);
-  } else
-interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1);
+  }
+  interpreter.OutputFormattedHelpText(output_strm, "", help_text);
   output_strm << "\nSyntax: " << GetSyntax() << "\n";
   Options *options = GetOptions();
   if (options != nullptr) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81783: [lldb] Remove indentation before help output.

2020-06-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: LLDB, jingham, labath, clayborg.
JDevlieghere updated this revision to Diff 270564.
JDevlieghere added a comment.

Explicit `llvm::StringRef` -> `std::string` conversion.


I always found it weird that there was this level of indentation before the 
first line of the help output. Supposedly it's meat to be aligned with the 
subcommands, but I find it visually confusion. This patch remove the 
indentation before the command help output.

**Before**

  (lldb) help breakpoint
   Commands for operating on breakpoints (see 'help b' for shorthand.)
  
  Syntax: breakpoint  []
  
  The following subcommands are supported:
  
clear   -- Delete or disable breakpoints matching the specified source 
file and line.`

**After**

  (lldb) help breakpoint
  Commands for operating on breakpoints (see 'help b' for shorthand.)
  
  Syntax: breakpoint  []
  
  The following subcommands are supported:
  
clear   -- Delete or disable breakpoints matching the specified source 
file and line.


https://reviews.llvm.org/D81783

Files:
  lldb/source/Interpreter/CommandObject.cpp


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -849,12 +849,11 @@
 
 void CommandObject::GenerateHelpText(Stream &output_strm) {
   CommandInterpreter &interpreter = GetCommandInterpreter();
+  std::string help_text(GetHelp());
   if (WantsRawCommandString()) {
-std::string help_text(GetHelp());
 help_text.append("  Expects 'raw' input (see 'help raw-input'.)");
-interpreter.OutputFormattedHelpText(output_strm, "", "", help_text, 1);
-  } else
-interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1);
+  }
+  interpreter.OutputFormattedHelpText(output_strm, "", help_text);
   output_strm << "\nSyntax: " << GetSyntax() << "\n";
   Options *options = GetOptions();
   if (options != nullptr) {


Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -849,12 +849,11 @@
 
 void CommandObject::GenerateHelpText(Stream &output_strm) {
   CommandInterpreter &interpreter = GetCommandInterpreter();
+  std::string help_text(GetHelp());
   if (WantsRawCommandString()) {
-std::string help_text(GetHelp());
 help_text.append("  Expects 'raw' input (see 'help raw-input'.)");
-interpreter.OutputFormattedHelpText(output_strm, "", "", help_text, 1);
-  } else
-interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1);
+  }
+  interpreter.OutputFormattedHelpText(output_strm, "", help_text);
   output_strm << "\nSyntax: " << GetSyntax() << "\n";
   Options *options = GetOptions();
   if (options != nullptr) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits