[Lldb-commits] [PATCH] D65397: Qualify includes of Properties[Enum].inc files. NFC

2019-07-29 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367241: [lldb] Qualify includes of Properties[Enum].inc 
files. NFC (authored by rupprecht, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65397?vs=212167=212193#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65397

Files:
  lldb/trunk/source/Core/CMakeLists.txt
  lldb/trunk/source/Core/CoreProperties.td
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/ModuleList.cpp
  lldb/trunk/source/Core/Properties.td
  lldb/trunk/source/Interpreter/CMakeLists.txt
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp
  lldb/trunk/source/Interpreter/InterpreterProperties.td
  lldb/trunk/source/Interpreter/Properties.td
  lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt
  
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernelProperties.td
  lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/Properties.td
  lldb/trunk/source/Plugins/JITLoader/GDB/CMakeLists.txt
  lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
  lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDBProperties.td
  lldb/trunk/source/Plugins/JITLoader/GDB/Properties.td
  lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSXProperties.td
  lldb/trunk/source/Plugins/Platform/MacOSX/Properties.td
  lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPProperties.td
  lldb/trunk/source/Plugins/Process/MacOSX-Kernel/Properties.td
  lldb/trunk/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
  lldb/trunk/source/Plugins/Process/gdb-remote/Properties.td
  lldb/trunk/source/Plugins/StructuredData/DarwinLog/CMakeLists.txt
  lldb/trunk/source/Plugins/StructuredData/DarwinLog/Properties.td
  lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
  
lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLogProperties.td
  lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/trunk/source/Plugins/SymbolFile/DWARF/Properties.td
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
  lldb/trunk/source/Target/CMakeLists.txt
  lldb/trunk/source/Target/Platform.cpp
  lldb/trunk/source/Target/Process.cpp
  lldb/trunk/source/Target/Properties.td
  lldb/trunk/source/Target/Target.cpp
  lldb/trunk/source/Target/TargetProperties.td
  lldb/trunk/source/Target/Thread.cpp

Index: lldb/trunk/source/Core/CMakeLists.txt
===
--- lldb/trunk/source/Core/CMakeLists.txt
+++ lldb/trunk/source/Core/CMakeLists.txt
@@ -1,9 +1,9 @@
-lldb_tablegen(Properties.inc -gen-lldb-property-defs
-  SOURCE Properties.td
+lldb_tablegen(CoreProperties.inc -gen-lldb-property-defs
+  SOURCE CoreProperties.td
   TARGET LLDBCorePropertiesGen)
 
-lldb_tablegen(PropertiesEnum.inc -gen-lldb-property-enum-defs
-  SOURCE Properties.td
+lldb_tablegen(CorePropertiesEnum.inc -gen-lldb-property-enum-defs
+  SOURCE CoreProperties.td
   TARGET LLDBCorePropertiesEnumGen)
 
 set(LLDB_CURSES_LIBS)
Index: lldb/trunk/source/Core/CoreProperties.td
===
--- lldb/trunk/source/Core/CoreProperties.td
+++ lldb/trunk/source/Core/CoreProperties.td
@@ -0,0 +1,118 @@
+include "../../include/lldb/Core/PropertiesBase.td"
+
+let Definition = "modulelist" in {
+  def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">;
+  def ClangModulesCachePath: Property<"clang-modules-cache-path", "FileSpec">,
+Global,
+DefaultStringValue<"">,
+Desc<"The path to the clang modules cache directory (-fmodules-cache-path).">;
+}
+
+let Definition = "debugger" in {
+  def AutoConfirm: Property<"auto-confirm", "Boolean">,
+

[Lldb-commits] [PATCH] D65397: Qualify includes of Properties[Enum].inc files. NFC

2019-07-29 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

Committed this for you as r367241, including a rebase past r367238 (which I 
really hope I didn't mess up -- `ninja check-lldb` passed, at least).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D65397



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-02 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

FYI, we've root caused some internal lldb asan failures to this patch. I don't 
have a repro yet (my lldb tests seem to be failing locally for unrelated 
reasons), but e.g. `Register/x86-64-read.test` is failing to read all the 
non-general purpose registers:

  (lldb) register read --all
  General Purpose Registers:
 rax = 0x7fffd660
 ... etc. ...
  
  Floating Point Registers:
  42 registers were unavailable.
  
  Advanced Vector Extensions:
  16 registers were unavailable.
  
  Memory Protection Extensions:
  6 registers were unavailable.
  
  (lldb) process continue
  error: Failed to resume process: Resume timed out..

These tests are passing in all other modes, including other sanitizer modes


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D70137: [lldb][Editline] Support ctrl+left/right arrow word navigation.

2019-11-14 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 229349.
rupprecht marked an inline comment as done.
rupprecht added a comment.

- Fix test comment
- Use `expect` helper from lldbpexpect


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70137

Files:
  lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
  lldb/source/Host/common/Editline.cpp


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);
Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -0,0 +1,49 @@
+"""
+Test that the lldb editline handling is configured correctly.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class EditlineTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_left_right_arrow(self):
+"""Test that ctrl+left/right arrow navigates words correctly.
+
+Note: just sending escape characters to pexpect and checking the buffer
+doesn't work well, so we run real commands. We want to type
+"help command" while exercising word-navigation, so type it as below,
+where [] indicates cursor position.
+
+1. Send "el ommand" -> "el ommand[]"
+2. Ctrl+left once   -> "el []ommand"
+3. Send "c" -> "el c[]ommand"
+4. Ctrl+left twice  -> "[]el command"
+5. Send "h" -> "h[]el command"
+6. Ctrl+right   -> "hel[] command"
+7. Send "p" -> "help command"
+"""
+self.launch()
+
+# Run help for different commands for escape variants to make sure each
+# one matches uniquely (the buffer isn't cleared in between matches).
+cases = [
+("print", "\x1b[1;5D", "\x1b[1;5C"),
+("step", "\x1b[5D", "\x1b[5C"),
+("exit", "\x1b\x1b[D", "\x1b\x1b[C"),
+]
+for (cmd, l_escape, r_escape) in cases:
+self.expect("el {cmd_tail}{L}{cmd_head}{L}{L}h{R}p\n".format(
+cmd_head=cmd[0], cmd_tail=cmd[1:], L=l_escape, R=r_escape),
+substrs=["Syntax: %s" % cmd])
+
+self.quit()


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);
Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -0,0 +1,49 @@
+"""
+Test that the lldb editline handling is configured correctly.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class EditlineTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+

[Lldb-commits] [PATCH] D70137: [lldb][Editline] Support ctrl+left/right arrow word navigation.

2019-11-14 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht marked an inline comment as done.
rupprecht added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py:37-38
+
+# Run help for different commands for escape variants to make sure each
+# one matches uniquely (the buffer isn't cleared in between matches).
+cases = [

labath wrote:
> The buffer isn't exactly "cleared", but each "expect" command should only 
> match from the end of the previous match, so repeating the same command 
> should not be a problem. What the other (few) pexpect tests do is put an 
> `self.expect_prompt()` to ensure all output from the previous command is 
> ignored, and lldb is ready to receive a new command. You could do that too. 
> In fact, you could probably use the helper "expect" command which does all of 
> this for you:
> `self.expect("el ommand{L}c{L}{L}h{R}p".format(...), substrs=["Syntax: 
> command"])`
The expect helper is nice, thanks!

> but each "expect" command should only match from the end of the previous match
I am not able to reproduce that. If I change the expect to the static string 
`"Syntax: print"` (not `% cmd`), then the second case (which types `"help 
step"`) passes. Which implies it's checking the entire buffer.

The third case (`"help exit"`) fails because the buffer does not contain the 
`print` help text anymore. But that means this behavior is dependent on the 
relation between help text length and buffer size. For now, I'll leave this as 
separate help commands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70137



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


[Lldb-commits] [PATCH] D70137: [lldb][Editline] Support ctrl+left/right arrow word navigation.

2019-11-14 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf2e65447b3cb: [lldb][Editline] Support ctrl+left/right arrow 
word navigation. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D70137?vs=229349=229373#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70137

Files:
  lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
  lldb/source/Host/common/Editline.cpp


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);
Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -0,0 +1,49 @@
+"""
+Test that the lldb editline handling is configured correctly.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class EditlineTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_left_right_arrow(self):
+"""Test that ctrl+left/right arrow navigates words correctly.
+
+Note: just sending escape characters to pexpect and checking the buffer
+doesn't work well, so we run real commands. We want to type
+"help command" while exercising word-navigation, so type it as below,
+where [] indicates cursor position.
+
+1. Send "el ommand" -> "el ommand[]"
+2. Ctrl+left once   -> "el []ommand"
+3. Send "c" -> "el c[]ommand"
+4. Ctrl+left twice  -> "[]el command"
+5. Send "h" -> "h[]el command"
+6. Ctrl+right   -> "hel[] command"
+7. Send "p" -> "help command"
+"""
+self.launch()
+
+# Run help for different commands for escape variants to make sure each
+# one matches uniquely (the buffer isn't cleared in between matches).
+cases = [
+("print", "\x1b[1;5D", "\x1b[1;5C"),
+("step", "\x1b[5D", "\x1b[5C"),
+("exit", "\x1b\x1b[D", "\x1b\x1b[C"),
+]
+for (cmd, l_escape, r_escape) in cases:
+self.expect("el {cmd_tail}{L}{cmd_head}{L}{L}h{R}p".format(
+cmd_head=cmd[0], cmd_tail=cmd[1:], L=l_escape, R=r_escape),
+substrs=["Syntax: %s" % cmd])
+
+self.quit()


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);
Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -0,0 +1,49 @@
+"""
+Test that the lldb editline handling is configured correctly.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import 

[Lldb-commits] [PATCH] D70137: [lldb][Editline] Support ctrl+left/right arrow word navigation.

2019-11-12 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: JDevlieghere, labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This adds several 5C/5D escape codes that allow moving forward/backward words 
similar to bash command line navigation.

On my terminal, `ctrl+v ctrl+` prints `^[[1;5D`. However, it seems 
inputrc also maps other escape variants of this to forward/backward word, so 
I've included those too. Similar for 5C = ctrl+right arrow.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70137

Files:
  lldb/source/Host/common/Editline.cpp


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70137: [lldb][Editline] Support ctrl+left/right arrow word navigation.

2019-11-12 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 228972.
rupprecht added a comment.

- Add a pexpect test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70137

Files:
  lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
  lldb/source/Host/common/Editline.cpp


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);
Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -0,0 +1,49 @@
+"""
+Test that the lldb editline handling is configured correctly.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class EditlineTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_left_right_arrow(self):
+"""Test that ctrl+left/right arrow navigates words correctly.
+
+Note: just sending escape characters to pexpect and checking the buffer
+doesn't work well, so we run real commands. We want to type
+"help command" while exercising word-navigation, so type it as below,
+where [] indicates cursor position.
+
+1. Send "el ommand" -> "el command[]"
+2. Ctrl+left once   -> "el []command"
+3. Send "c" -> "el c[]ommand"
+4. Ctrl+left twice  -> "[]el command"
+5. Send "h" -> "h[]el command"
+6. Ctrl+right   -> "hel[] command"
+7. Send "p" -> "help command"
+"""
+self.launch()
+
+# Run help for different commands for escape variants to make sure each
+# one matches uniquely (the buffer isn't cleared in between matches).
+cases = [
+("print", "\x1b[1;5D", "\x1b[1;5C"),
+("step", "\x1b[5D", "\x1b[5C"),
+("exit", "\x1b\x1b[D", "\x1b\x1b[C"),
+]
+for (cmd, l_escape, r_escape) in cases:
+self.child.send("el {cmd_tail}{L}{cmd_head}{L}{L}h{R}p\n".format(
+cmd_head=cmd[0], cmd_tail=cmd[1:], L=l_escape, R=r_escape))
+self.child.expect_exact("Syntax: %s" % cmd)
+
+self.quit()


Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1105,6 +1105,15 @@
   el_set(m_editline, EL_BIND, "\t", "lldb-complete",
  NULL); // Bind TAB to auto complete
 
+  // 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);
+  el_set(m_editline, EL_BIND, ESCAPE "[1;5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE "[5D", "ed-prev-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[C", "em-next-word", NULL);
+  el_set(m_editline, EL_BIND, ESCAPE ESCAPE "[D", "ed-prev-word", NULL);
+
   // Allow user-specific customization prior to registering bindings we
   // absolutely require
   el_source(m_editline, nullptr);
Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -0,0 +1,49 @@
+"""
+Test that the lldb editline handling is configured correctly.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class EditlineTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_left_right_arrow(self):
+"""Test that 

[Lldb-commits] [PATCH] D70137: [lldb][Editline] Support ctrl+left/right arrow word navigation.

2019-11-12 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D70137#1742766 , @JDevlieghere 
wrote:

> This is very nice, thanks!
>
> Any chance we could test this with a pexpect test?


Absolutely. It was waaay more complicated than I expected due to funny escaping 
somewhere between pexpect and lldb, but testing an actual command seems to 
work. Hopefully I've captured that in the test doc comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70137



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


[Lldb-commits] [PATCH] D70137: [lldb][Editline] Support ctrl+left/right arrow word navigation.

2019-11-16 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht marked 3 inline comments as done.
rupprecht added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py:37-38
+
+# Run help for different commands for escape variants to make sure each
+# one matches uniquely (the buffer isn't cleared in between matches).
+cases = [

labath wrote:
> rupprecht wrote:
> > labath wrote:
> > > The buffer isn't exactly "cleared", but each "expect" command should only 
> > > match from the end of the previous match, so repeating the same command 
> > > should not be a problem. What the other (few) pexpect tests do is put an 
> > > `self.expect_prompt()` to ensure all output from the previous command is 
> > > ignored, and lldb is ready to receive a new command. You could do that 
> > > too. In fact, you could probably use the helper "expect" command which 
> > > does all of this for you:
> > > `self.expect("el ommand{L}c{L}{L}h{R}p".format(...), substrs=["Syntax: 
> > > command"])`
> > The expect helper is nice, thanks!
> > 
> > > but each "expect" command should only match from the end of the previous 
> > > match
> > I am not able to reproduce that. If I change the expect to the static 
> > string `"Syntax: print"` (not `% cmd`), then the second case (which types 
> > `"help step"`) passes. Which implies it's checking the entire buffer.
> > 
> > The third case (`"help exit"`) fails because the buffer does not contain 
> > the `print` help text anymore. But that means this behavior is dependent on 
> > the relation between help text length and buffer size. For now, I'll leave 
> > this as separate help commands.
> That's very odd. It's definitely not how things behave on my end (the second 
> check fails straight away), and it's not clear to me why would that differ 
> for you. Looking at the code, it's pretty obvious 
> 
>  that pexpect intends to reset the internal buffer to include only the text 
> after the last match.
> 
> I'd like to get to the bottom of this. Can you dig around (maybe step through 
> the pexpect code) to see what's happening in your case? One thing that's been 
> causing confusion in the past was the leftover 
> `third_party/Python/module/pexpect-2.X` folder from the time before we 
> updated pexpect. However, I find it unlikely that this would be the case 
> here, as this should have been the pexpect behavior since forever...
Figured out what was going on and mailed D70324 to prevent this from happening 
to the next person this bites -- which could be me :)

I originally had:

```
self.child.send("help command\n")
self.child.expect_exact("Syntax: command")
```

And based on your suggestion, changed it to:
```
self.expect("help command\n", substrs=["Syntax: command"])
```

Which is wrong, because `self.expect()` calls `self.child.sendline(cmd)`, so 
it's running `"help command\n\n"` == `"help command\nhelp command\n"`.
The `expect_prompt()` helper will match the first prompt it sees, so the second 
run of the command is still in the match buffer. Checking for "Syntax: command" 
would still pass even though it was not intentionally ran twice.

I also tried changing `expect_prompt()` to continuously match until the last 
prompt it sees, but it's simpler to just disallow `\n` in the command.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70137



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


[Lldb-commits] [PATCH] D70324: [lldb][test] Prevent \n in calls to lldb's expect() test helper.

2019-11-16 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

expect() forwards its command to sendline(). This can be problematic if the 
command already contains a newline: sendline() unconditionally adds a newline 
to the command, which causes the command to run twice (hitting enter in lldb 
runs the previous command). The expect() helper looks for the prompt and finds 
the first one, but because the command has run a second time, the buffer will 
contain the contents of the second time the command ran, causing potential 
erroneous matching.

Simplify the editline test, which was using different commands to workaround 
this misunderstanding.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70324

Files:
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py
  lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py


Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -34,16 +34,13 @@
 """
 self.launch()
 
-# Run help for different commands for escape variants to make sure each
-# one matches uniquely (the buffer isn't cleared in between matches).
-cases = [
-("print", "\x1b[1;5D", "\x1b[1;5C"),
-("step", "\x1b[5D", "\x1b[5C"),
-("exit", "\x1b\x1b[D", "\x1b\x1b[C"),
+escape_pairs = [
+("\x1b[1;5D", "\x1b[1;5C"),
+("\x1b[5D", "\x1b[5C"),
+("\x1b\x1b[D", "\x1b\x1b[C"),
 ]
-for (cmd, l_escape, r_escape) in cases:
-self.expect("el {cmd_tail}{L}{cmd_head}{L}{L}h{R}p".format(
-cmd_head=cmd[0], cmd_tail=cmd[1:], L=l_escape, R=r_escape),
-substrs=["Syntax: %s" % cmd])
+for (l_escape, r_escape) in escape_pairs:
+self.expect("el rint{L}p{L}{L}h{R}p".format(
+L=l_escape, R=r_escape), substrs=["Syntax: print"])
 
 self.quit()
Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -50,6 +50,7 @@
 self.expect_prompt()
 
 def expect(self, cmd, substrs=None):
+self.assertNotIn('\n', cmd)
 self.child.sendline(cmd)
 if substrs is not None:
 for s in substrs:


Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -34,16 +34,13 @@
 """
 self.launch()
 
-# Run help for different commands for escape variants to make sure each
-# one matches uniquely (the buffer isn't cleared in between matches).
-cases = [
-("print", "\x1b[1;5D", "\x1b[1;5C"),
-("step", "\x1b[5D", "\x1b[5C"),
-("exit", "\x1b\x1b[D", "\x1b\x1b[C"),
+escape_pairs = [
+("\x1b[1;5D", "\x1b[1;5C"),
+("\x1b[5D", "\x1b[5C"),
+("\x1b\x1b[D", "\x1b\x1b[C"),
 ]
-for (cmd, l_escape, r_escape) in cases:
-self.expect("el {cmd_tail}{L}{cmd_head}{L}{L}h{R}p".format(
-cmd_head=cmd[0], cmd_tail=cmd[1:], L=l_escape, R=r_escape),
-substrs=["Syntax: %s" % cmd])
+for (l_escape, r_escape) in escape_pairs:
+self.expect("el rint{L}p{L}{L}h{R}p".format(
+L=l_escape, R=r_escape), substrs=["Syntax: print"])
 
 self.quit()
Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -50,6 +50,7 @@
 self.expect_prompt()
 
 def expect(self, cmd, substrs=None):
+self.assertNotIn('\n', cmd)
 self.child.sendline(cmd)
 if substrs is not None:
 for s in substrs:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70324: [lldb][test] Prevent \n in calls to lldb's expect() test helper.

2019-11-22 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D70324#1755712 , @davide wrote:

> In D70324#1755704 , @labath wrote:
>
> > [This is probably not the right patch, as the last run on that bot still 
> > doesn't have this commit.]
>


-> D70137  is the correct patch that actually 
adds this test -- this is testonly cleanup

>> My understanding is that all pexpect tests are failing on that bot and are 
>> skipped with `@skipIfAsan`. Probably this one needs to be skipped too. 
>> @teemperor was trying to reproduce some of those failures locally and 
>> failed... Maybe that bot is cursed...
> 
> Fair.

I looked at the failure in some detail. (I don't have hardware to repro it on 
though). The test itself runs fine but the cleanup (I guess the `self.quit()`) 
at the end seems to fail: `pexpect.exceptions.ExceptionPexpect: Could not 
terminate the child.` Is that in line with the failures that `@skipIfAsan` is 
intended for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70324



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


[Lldb-commits] [PATCH] D70517: [lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.

2019-11-22 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG506144da04b9: [lldb][DataFormatters] Support pretty printing 
std::string when built with… (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70517

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -425,6 +425,13 @@
 "std::__[[:alnum:]]+::char_traits, "
 "std::__[[:alnum:]]+::allocator >$"),
 stl_summary_flags, true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibcxxStringSummaryProviderASCII,
+"std::string summary provider",
+ConstString("^std::__[[:alnum:]]+::basic_string, "
+"std::__[[:alnum:]]+::allocator >$"),
+stl_summary_flags, true);
 
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxStringSummaryProviderUTF16,
@@ -723,6 +730,10 @@
   ConstString("std::__cxx11::basic_string, "
   "std::allocator >"),
   cxx11_string_summary_sp);
+  cpp_category_sp->GetTypeSummariesContainer()->Add(
+  ConstString("std::__cxx11::basic_string, "
+  "std::allocator >"),
+  cxx11_string_summary_sp);
 
   // making sure we force-pick the summary for printing wstring (_M_p is a
   // wchar_t*)
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
@@ -9,6 +9,7 @@
 std::string empty("");
 std::string q("hello world");
 std::string Q("quite a long std::strin with lots of info inside it");
+std::basic_string uchar(5, 'a');
 S.assign(L"!"); // Set break point at this line.
 return 0;
 }
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
@@ -59,26 +59,28 @@
 var_empty = self.frame().FindVariable('empty')
 var_q = self.frame().FindVariable('q')
 var_Q = self.frame().FindVariable('Q')
+var_uchar = self.frame().FindVariable('uchar')
 
 # TODO: This is currently broken
-# self.assertTrue(var_wempty.GetSummary() == 'L""', "wempty summary wrong")
-self.assertTrue(
-var_s.GetSummary() == 'L"hello world! מזל טוב!"',
+# self.assertEqual(var_wempty.GetSummary(), 'L""', "wempty summary wrong")
+self.assertEqual(
+var_s.GetSummary(), 'L"hello world! מזל טוב!"',
 "s summary wrong")
-self.assertTrue(var_S.GetSummary() == 'L""', "S summary wrong")
-self.assertTrue(
-var_mazeltov.GetSummary() == 'L"מזל טוב"',
+self.assertEqual(var_S.GetSummary(), 'L""', "S summary wrong")
+self.assertEqual(
+var_mazeltov.GetSummary(), 'L"מזל טוב"',
 "mazeltov summary wrong")
-self.assertTrue(var_empty.GetSummary() == '""', "empty summary wrong")
-self.assertTrue(
-var_q.GetSummary() == '"hello world"',
+self.assertEqual(var_empty.GetSummary(), '""', "empty summary wrong")
+self.assertEqual(
+var_q.GetSummary(), '"hello world"',
 "q summary wrong")
-self.assertTrue(
-var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"',
+self.assertEqual(
+var_Q.GetSummary(), '"quite a long std::strin with lots of info inside 

[Lldb-commits] [PATCH] D70622: [cmake][lit] Follow symlinks when looking for lit tests & reconfigure lldb's tests.

2019-11-22 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: JDevlieghere, labath.
Herald added subscribers: llvm-commits, lldb-commits, mgorny.
Herald added projects: LLDB, LLVM.

The lldb tree contains a symlink directory, `lldb/test/API/testcases`, which 
points to the tests in `../../packages/Python/lldbsuite/test`. Because the 
`add_lit_testsuites()` cmake rule does not follow symlinks, it doesn't find the 
nested directory tree to create make/ninja rules for.

Also, because the lldb lit config points the source root directly into the 
testcases tree, the `check-lldb-api-testcases` rule fails to find the 
`testcases` directory, and therefore finds no tests. Changing the source root 
to the containing lit file, like most lit configs do, fixes this.

After this patch, `ninja check-lldb-api-testcases-linux` works, and runs only 
the test cases in `lldb/packages/Python/lldbsuite/test/linux`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70622

Files:
  lldb/test/API/lit.cfg.py
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1488,7 +1488,8 @@
 
 # Search recursively for test directories by assuming anything not
 # in a directory called Inputs contains tests.
-file(GLOB_RECURSE to_process LIST_DIRECTORIES true ${directory}/*)
+# Follow symlinks as some tests in lldb are structured that way.
+file(GLOB_RECURSE to_process FOLLOW_SYMLINKS LIST_DIRECTORIES true 
${directory}/*)
 foreach(lit_suite ${to_process})
   if(NOT IS_DIRECTORY ${lit_suite})
 continue()
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -17,8 +17,7 @@
 
 # test_source_root: The root path where tests are located.
 # test_exec_root: The root path where tests should be run.
-config.test_source_root = os.path.join(config.lldb_src_root, 'packages',
-   'Python', 'lldbsuite', 'test')
+config.test_source_root = os.path.dirname(__file__)
 config.test_exec_root = config.test_source_root
 
 if 'Address' in config.llvm_use_sanitizer:


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1488,7 +1488,8 @@
 
 # Search recursively for test directories by assuming anything not
 # in a directory called Inputs contains tests.
-file(GLOB_RECURSE to_process LIST_DIRECTORIES true ${directory}/*)
+# Follow symlinks as some tests in lldb are structured that way.
+file(GLOB_RECURSE to_process FOLLOW_SYMLINKS LIST_DIRECTORIES true ${directory}/*)
 foreach(lit_suite ${to_process})
   if(NOT IS_DIRECTORY ${lit_suite})
 continue()
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -17,8 +17,7 @@
 
 # test_source_root: The root path where tests are located.
 # test_exec_root: The root path where tests should be run.
-config.test_source_root = os.path.join(config.lldb_src_root, 'packages',
-   'Python', 'lldbsuite', 'test')
+config.test_source_root = os.path.dirname(__file__)
 config.test_exec_root = config.test_source_root
 
 if 'Address' in config.llvm_use_sanitizer:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71151: [lldb][test] Remove symlink for API tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere.
Herald added subscribers: lldb-commits, jfb, arphaman, atanasyan, mgrang, 
jrtc27, christof, kbarton, krytarowski, arichardson, nemanjai, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: jfb.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.
rupprecht added a comment.
Herald added subscribers: wuzish, dexonsmith.
rupprecht added a parent revision: D71150: [lldb][test] Create a separate 
LLDB_TEST_SRC var to allow moving tests..

Since the diff is large, I'll paste the only non-mechanical part here:

  % git diff HEAD^1 -- lldb/packages/Python/lldbsuite/__init__.py 
lldb/test/API/lit.cfg.py
  diff --git a/lldb/packages/Python/lldbsuite/__init__.py 
b/lldb/packages/Python/lldbsuite/__init__.py
  index c98c668ed6b..188f6ed1532 100644
  --- a/lldb/packages/Python/lldbsuite/__init__.py
  +++ b/lldb/packages/Python/lldbsuite/__init__.py
  @@ -22,11 +22,4 @@ lldb_root = find_lldb_root()
   
   # lldbsuite.lldb_test_src_root refers to the root of the python test case 
tree
   # (i.e. the actual unit tests).
  -lldb_test_root = os.path.join(
  -lldb_root,
  -"packages",
  -"Python",
  -"lldbsuite",
  -"test")
  -# TODO(rupprecht): update the above definition after moving test cases:
  -# lldb_test_root = os.path.join(lldb_root, "test", "API", "test")
  +lldb_test_root = os.path.join(lldb_root, "test", "API", "test")
  diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
  index 9b1c3c12f17..90d8a141e9a 100644
  --- a/lldb/test/API/lit.cfg.py
  +++ b/lldb/test/API/lit.cfg.py
  @@ -17,8 +17,7 @@ config.suffixes = ['.py']
   
   # test_source_root: The root path where tests are located.
   # test_exec_root: The root path where tests should be run.
  -config.test_source_root = os.path.join(config.lldb_src_root, 'packages',
  -   'Python', 'lldbsuite', 'test')
  +config.test_source_root = os.path.dirname(__file__)
   config.test_exec_root = config.test_source_root
   
   if 'Address' in config.llvm_use_sanitizer:


This is a largely mechanical change, moved with the following steps:

  rm lldb/test/API/testcases
  mkdir -p lldb/test/API/test/{test_runner/test,tools/lldb-{server,vscode}}
  mv lldb/packages/Python/lldbsuite/test/.categories lldb/test/API/test/
  mv lldb/packages/Python/lldbsuite/test/test_runner/test 
lldb/test/API/test/test_runner
  for d in $(find lldb/packages/Python/lldbsuite/test/* -maxdepth 0 -type d | 
egrep -v "make|plugins|test_runner|tools"); do mv $d lldb/test/API/test; done
  for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-vscode 
-maxdepth 1 -mindepth 1 | grep -v ".py"); do mv $d 
lldb/test/API/test/tools/lldb-vscode; done
  for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-server 
-maxdepth 1 -mindepth 1 | egrep -v 
"gdbremote_testcase.py|lldbgdbserverutils.py|socket_packet_pump.py"); do mv $d 
lldb/test/API/test/tools/lldb-server; done

lldb/packages/Python/lldbsuite/__init__.py and lldb/test/API/lit.cfg.py were 
also updated with the new directory structure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71151

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/.categories
  lldb/packages/Python/lldbsuite/test/android/platform/Makefile
  
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
  lldb/packages/Python/lldbsuite/test/android/platform/main.cpp
  lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/Makefile
  
lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py
  
lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/main.cpp.template
  lldb/packages/Python/lldbsuite/test/api/command-return-object/Makefile
  
lldb/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
  lldb/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
  lldb/packages/Python/lldbsuite/test/api/listeners/Makefile
  lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py
  lldb/packages/Python/lldbsuite/test/api/listeners/main.c
  lldb/packages/Python/lldbsuite/test/api/log/TestAPILog.py
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/.categories
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/Makefile
  
lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
  
lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/testprog.cpp
  lldb/packages/Python/lldbsuite/test/api/multiple-targets/Makefile
  
lldb/packages/Python/lldbsuite/test/api/multiple-targets/TestMultipleTargets.py
  lldb/packages/Python/lldbsuite/test/api/multiple-targets/main.cpp
  lldb/packages/Python/lldbsuite/test/api/multithreaded/Makefile
  

[Lldb-commits] [PATCH] D71150: [lldb][test] Create a separate LLDB_TEST_SRC var to allow moving tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This creates a separate LLDB_TEST_SRC var to match the existing LLDB_TEST var. 
LLDB_TEST points to the test framework, LLDB_TEST_SRC points to the tests 
themselves.

The var points to the same place, but a future patch will move the tree + 
update var.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71150

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -61,12 +61,13 @@
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
 lldb_build = os.environ["LLDB_BUILD"]
-if not (lldb_test and lldb_build and test_subdir and test_name and
-(not os.path.isabs(test_subdir))):
+if not (lldb_test and lldb_test_src and lldb_build and test_subdir and
+test_name and (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
 build_dir = os.path.join(lldb_build, test_subdir, test_name)
-src_dir = os.path.join(lldb_test, test_subdir)
+src_dir = os.path.join(lldb_test_src, test_subdir)
 # This is a bit of a hack to make inline testcases work.
 makefile = os.path.join(src_dir, "Makefile")
 if not os.path.isfile(makefile):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -498,7 +498,7 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST"]) + 1:]
+rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -518,10 +518,10 @@
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST} is defined.
-# See also dotest.py which sets up ${LLDB_TEST}.
-if ("LLDB_TEST" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST"],
+# Change current working directory if ${LLDB_TEST_SRC} is defined.
+# See also dotest.py which sets up ${LLDB_TEST_SRC}.
+if ("LLDB_TEST_SRC" in os.environ):
+full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
 cls.mydir)
 if traceAlways:
 print("Change dir to:", full_dir, file=sys.stderr)
@@ -656,7 +656,7 @@
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST"], self.mydir)
+return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1089,7 +1089,7 @@
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST"],
+dname = os.path.join(os.environ["LLDB_TEST_SRC"],
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -488,6 +488,7 @@
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
+os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 builddir = configuration.test_build_dir
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -20,10 +20,13 @@
 # lldbsuite.lldb_root refers to the root of the git/svn source checkout
 lldb_root = find_lldb_root()
 
-# lldbsuite.lldb_test_root refers to the root of the python test tree
+# lldbsuite.lldb_test_src_root refers to the root of the python test case tree
+# (i.e. the actual unit tests).
 lldb_test_root = os.path.join(
 lldb_root,
 "packages",
 "Python",
 "lldbsuite",
 "test")
+# TODO(rupprecht): update the above definition after moving test cases:
+# lldb_test_root = os.path.join(lldb_root, "test", "API", "test")



[Lldb-commits] [PATCH] D71151: [lldb][test] Remove symlink for API tests.

2019-12-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D71151#1774586 , @labath wrote:

> While I'm not opposed to moving "lldbsuite" to some place closer to the 
> tests, one thing I'd like to get out of this is to have the actual tests 
> stand out more prominently.


Ditto; my direct goal is just to be able to run something more fine grained 
than `ninja check-lldb-api`, but splitting tests & test framework is a nice 
side benefit. (Actually it might be simpler if I didn't split it, but now I've 
already done the work).

> For that reason, I wouldn't want to just take the "lldbsuite" folder and 
> "drop" it into `test/API`. In fact, ideally I'd like to get rid of the 
> redundant nested `test` subfolder, and put the tests directly into `test/API`.

SGTM. I can adjust that paths so there is no shim "test" directory. Will await 
resolution of the specific paths as chosen below:

> However, like I said in the other review, if lua is going to become a thing, 
> we should evaluate how will this layout work with additional scripting 
> languages: I see several options here:
> 
> - make a subfolder for each language (`test/API/{Python,Lua}`)
> - ditch the "API" part and put these at the top level (`test/{Python,Lua}`)
> - keep Python in "API", but put lua in Lua (`test/{API,Lua}`) -- besides 
> backward compat, this would kind of signal that "python" is our preferred 
> vessel for writing tests
> - ???

Any of these options are fine with me. Actually, they seem most logical in the 
order you've listed -- the last one seems kind of weird that "API" implicitly 
means python, and there are other non-python API tests elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71151



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


[Lldb-commits] [PATCH] D71319: [lldb][dotest] Improve libc++ detection

2019-12-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: labath.
Herald added a reviewer: EricWF.
Herald added subscribers: lldb-commits, ldionne.
Herald added a project: LLDB.

The test logic for running libc++ tests only looks to see if 
`/usr/include/c++/v1` exists. This adds a fallback for including libc++ tests 
as long as `$(CC) -stdlib=libc++` works.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71319

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -32,6 +32,7 @@
 import signal
 import subprocess
 import sys
+import tempfile
 
 # Third-party modules
 import six
@@ -850,9 +851,15 @@
 return True, "libc++ always present"
 
 if platform == "linux":
-if not os.path.isdir("/usr/include/c++/v1"):
-return False, "Unable to find libc++ installation"
-return True, "Headers found, let's hope they work"
+if os.path.isdir("/usr/include/c++/v1"):
+return True, "Headers found, let's hope they work"
+with tempfile.NamedTemporaryFile() as f:
+cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", 
f.name, "-"]
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+_, stderr = p.communicate("int main() {}")
+if not p.returncode:
+return True, "Compiling with -stdlib=libc++ works"
+return False, "Compiling with -stdlib=libc++ fails with the error: 
%s" % stderr
 
 return False, "Don't know how to build with libc++ on %s" % platform
 


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -32,6 +32,7 @@
 import signal
 import subprocess
 import sys
+import tempfile
 
 # Third-party modules
 import six
@@ -850,9 +851,15 @@
 return True, "libc++ always present"
 
 if platform == "linux":
-if not os.path.isdir("/usr/include/c++/v1"):
-return False, "Unable to find libc++ installation"
-return True, "Headers found, let's hope they work"
+if os.path.isdir("/usr/include/c++/v1"):
+return True, "Headers found, let's hope they work"
+with tempfile.NamedTemporaryFile() as f:
+cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+_, stderr = p.communicate("int main() {}")
+if not p.returncode:
+return True, "Compiling with -stdlib=libc++ works"
+return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
 
 return False, "Don't know how to build with libc++ on %s" % platform
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71150: [lldb][test] Create a separate LLDB_TEST_SRC var to allow moving tests.

2019-12-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D71150#1774575 , @labath wrote:

> Hmm... given the lua thread on lldb-dev, maybe we should slow down here, and 
> consider the potential relationship of these tests and the hypothetical lua 
> tests that come to be. One of the reasons the current tests are so deeply 
> nested was that Zach was trying to future-proof ourselves for addition of new 
> scripting languages (at that time, Java was being floated around, but the 
> idea never took off the ground). I'd hate to move these tests now, only to 
> have to move them around again in a couple of weeks to make room for lua...


I don't *think* this patch is affected by that discussion, except for the 
speculative comment to update `lldb_test_root = os.path.join(lldb_root, "test", 
"API", "test")` with the next patch. I'll followup with the next patch 
discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71150



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


[Lldb-commits] [PATCH] D71319: [lldb][dotest] Improve libc++ detection

2019-12-11 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG34ef51b5f979: [lldb][dotest] Improve libc++ detection 
(authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71319

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -32,6 +32,7 @@
 import signal
 import subprocess
 import sys
+import tempfile
 
 # Third-party modules
 import six
@@ -850,9 +851,15 @@
 return True, "libc++ always present"
 
 if platform == "linux":
-if not os.path.isdir("/usr/include/c++/v1"):
-return False, "Unable to find libc++ installation"
-return True, "Headers found, let's hope they work"
+if os.path.isdir("/usr/include/c++/v1"):
+return True, "Headers found, let's hope they work"
+with tempfile.NamedTemporaryFile() as f:
+cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", 
f.name, "-"]
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+_, stderr = p.communicate("int main() {}")
+if not p.returncode:
+return True, "Compiling with -stdlib=libc++ works"
+return False, "Compiling with -stdlib=libc++ fails with the error: 
%s" % stderr
 
 return False, "Don't know how to build with libc++ on %s" % platform
 


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -32,6 +32,7 @@
 import signal
 import subprocess
 import sys
+import tempfile
 
 # Third-party modules
 import six
@@ -850,9 +851,15 @@
 return True, "libc++ always present"
 
 if platform == "linux":
-if not os.path.isdir("/usr/include/c++/v1"):
-return False, "Unable to find libc++ installation"
-return True, "Headers found, let's hope they work"
+if os.path.isdir("/usr/include/c++/v1"):
+return True, "Headers found, let's hope they work"
+with tempfile.NamedTemporaryFile() as f:
+cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+_, stderr = p.communicate("int main() {}")
+if not p.returncode:
+return True, "Compiling with -stdlib=libc++ works"
+return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
 
 return False, "Don't know how to build with libc++ on %s" % platform
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71376: [lldb][dotest] Add `#include ` to libc++ detection

2019-12-11 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG786b6db8e6fd: [lldb][dotest] Add `#include 
algorithm` to libc++ detection (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71376

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -856,7 +856,7 @@
 with tempfile.NamedTemporaryFile() as f:
 cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", 
f.name, "-"]
 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
-_, stderr = p.communicate("int main() {}")
+_, stderr = p.communicate("#include \nint main() {}")
 if not p.returncode:
 return True, "Compiling with -stdlib=libc++ works"
 return False, "Compiling with -stdlib=libc++ fails with the error: 
%s" % stderr


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -856,7 +856,7 @@
 with tempfile.NamedTemporaryFile() as f:
 cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
-_, stderr = p.communicate("int main() {}")
+_, stderr = p.communicate("#include \nint main() {}")
 if not p.returncode:
 return True, "Compiling with -stdlib=libc++ works"
 return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71319: [lldb][dotest] Improve libc++ detection

2019-12-11 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht marked an inline comment as done.
rupprecht added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:859
+p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+_, stderr = p.communicate("int main() {}")
+if not p.returncode:

FYI, the check didn't work because this isn't exercising anything in libc++, it 
really only checks that `-stdlib=libc++` is a valid compiler flag. 
786b6db8e6fd87fb82f2ad3e94e20c5c9cf9c4e4 fixes this by adding a libc++ include, 
which fails the command if libc++ is not installed where clang can find it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71319



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


[Lldb-commits] [PATCH] D71376: [lldb][dotest] Add `#include ` to libc++ detection

2019-12-11 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: echristo.
Herald added a reviewer: EricWF.
Herald added subscribers: lldb-commits, ldionne.
Herald added a project: LLDB.
echristo accepted this revision.
This revision is now accepted and ready to land.

Speculative fix after 34ef51b5f979 
 broke the 
lldb buildbot on libc++ tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71376

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -856,7 +856,7 @@
 with tempfile.NamedTemporaryFile() as f:
 cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", 
f.name, "-"]
 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
-_, stderr = p.communicate("int main() {}")
+_, stderr = p.communicate("#include \nint main() {}")
 if not p.returncode:
 return True, "Compiling with -stdlib=libc++ works"
 return False, "Compiling with -stdlib=libc++ fails with the error: 
%s" % stderr


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -856,7 +856,7 @@
 with tempfile.NamedTemporaryFile() as f:
 cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
-_, stderr = p.communicate("int main() {}")
+_, stderr = p.communicate("#include \nint main() {}")
 if not p.returncode:
 return True, "Compiling with -stdlib=libc++ works"
 return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70622: [cmake][lit] Follow symlinks when looking for lit tests & reconfigure lldb's tests.

2019-12-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D70622#1765674 , @JDevlieghere 
wrote:

> No objections to moving the test. Jordan, let me know if you're up for it, 
> otherwise I'm happy to take care of it.


I tried moving it today. The rabbit hole goes deep :D
The test framework seems pretty tied to the directory layout (because python), 
e.g. those must be in a directory called "lldbsuite" to be able to "import 
lldbsuite"
The test infrastructure also seems to assume tests + test framework are in the 
same tree (e.g. the LLDB_TEST env var is used for both), so moving the 
individual test directories and leaving just the framework classes in lldbsuite 
breaks a few things.

I agree it's probably cleaner to move the tests, so I'll keep poking. 
Suggestions welcome though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70622



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


[Lldb-commits] [PATCH] D70622: [cmake][lit] Follow symlinks when looking for lit tests & reconfigure lldb's tests.

2019-12-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D70622#1771601 , @rupprecht wrote:

> In D70622#1765674 , @JDevlieghere 
> wrote:
>
> > No objections to moving the test. Jordan, let me know if you're up for it, 
> > otherwise I'm happy to take care of it.
>
>
> I tried moving it today. The rabbit hole goes deep :D
>  The test framework seems pretty tied to the directory layout (because 
> python), e.g. those must be in a directory called "lldbsuite" to be able to 
> "import lldbsuite"
>  The test infrastructure also seems to assume tests + test framework are in 
> the same tree (e.g. the LLDB_TEST env var is used for both), so moving the 
> individual test directories and leaving just the framework classes in 
> lldbsuite breaks a few things.
>
> I agree it's probably cleaner to move the tests, so I'll keep poking. 
> Suggestions welcome though.


I have it down to ~5 failing tests (some may be preexisting failures), so I'll 
start pulling apart my change into submittable pieces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70622



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


[Lldb-commits] [PATCH] D71099: [lldb][test] Handle .categories lookup for inline tests.

2019-12-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When creating a test with `lldbinline.MakeInlineTest()`, the reported 
`inspect.getfile(test.__class__)` is `lldbtest.pyc`, meaning any `.categories` 
file will be ineffective for those tests. Check for the test_filename first, 
which inline tests will set.

Additionally, raise an error with the starting dir if `.categories` is not 
found. This makes the problem more obvious when it occurs: when the test is 
separated from the test framework tree.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71099

Files:
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@
 """
 import inspect
 import os.path
-folder = inspect.getfile(test.__class__)
-folder = os.path.dirname(folder)
+# Use test.test_filename if the test was created with
+# lldbinline.MakeInlineTest().
+if hasattr(test, 'test_filename'):
+start_path = test.test_filename
+else:
+start_path = inspect.getfile(test.__class__)
+
+folder = os.path.dirname(start_path)
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@
 else:
 folder = os.path.dirname(folder)
 continue
+raise Exception("Did not find a .categories file, starting at: %s" % 
start_path)
 
 
 def getCategoriesForTest(self, test):


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@
 """
 import inspect
 import os.path
-folder = inspect.getfile(test.__class__)
-folder = os.path.dirname(folder)
+# Use test.test_filename if the test was created with
+# lldbinline.MakeInlineTest().
+if hasattr(test, 'test_filename'):
+start_path = test.test_filename
+else:
+start_path = inspect.getfile(test.__class__)
+
+folder = os.path.dirname(start_path)
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@
 else:
 folder = os.path.dirname(folder)
 continue
+raise Exception("Did not find a .categories file, starting at: %s" % start_path)
 
 
 def getCategoriesForTest(self, test):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71099: [lldb][test] Handle .categories lookup for inline tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03a242bd41ee: [lldb][test] Handle .categories lookup for 
inline tests. (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71099

Files:
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@
 """
 import inspect
 import os.path
-folder = inspect.getfile(test.__class__)
-folder = os.path.dirname(folder)
+# Use test.test_filename if the test was created with
+# lldbinline.MakeInlineTest().
+if hasattr(test, 'test_filename'):
+start_path = test.test_filename
+else:
+start_path = inspect.getfile(test.__class__)
+
+folder = os.path.dirname(start_path)
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@
 else:
 folder = os.path.dirname(folder)
 continue
+raise Exception("Did not find a .categories file, starting at: %s" % 
start_path)
 
 
 def getCategoriesForTest(self, test):


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -113,8 +113,14 @@
 """
 import inspect
 import os.path
-folder = inspect.getfile(test.__class__)
-folder = os.path.dirname(folder)
+# Use test.test_filename if the test was created with
+# lldbinline.MakeInlineTest().
+if hasattr(test, 'test_filename'):
+start_path = test.test_filename
+else:
+start_path = inspect.getfile(test.__class__)
+
+folder = os.path.dirname(start_path)
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
@@ -127,6 +133,7 @@
 else:
 folder = os.path.dirname(folder)
 continue
+raise Exception("Did not find a .categories file, starting at: %s" % start_path)
 
 
 def getCategoriesForTest(self, test):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70622: [cmake][lit] Follow symlinks when looking for lit tests & reconfigure lldb's tests.

2019-12-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht abandoned this revision.
rupprecht added a comment.

Officially abandoning this

rG0d236d8b4f8aecc258e26ad53755a39d9b76032e 
 - fixes 
makefiles when separated from `Makefile.rules`
rG03a242bd41ee49e17f8da96af9787d13e7ea2b93 
 - fixes 
`.categories` lookup when tests are moved

I have one more to split up `os.environ["LLDB_TEST"]` into separate trees for 
test framework/test source, then the tests can be moved in a very mechanical 
way. (It will create heavy merge conflicts, I want it to be trivial to apply 
for downstream users).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70622



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


[Lldb-commits] [PATCH] D70517: [lldb][DataFormatters] Support pretty printing std::string when built with -funsigned-char.

2019-11-20 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere, shafik.
Herald added subscribers: lldb-commits, christof.
Herald added a project: LLDB.

When built w/ `-funsigned-char`, `std::string` becomes equivalent to 
`std::basic_string`, causing these formatters to not match. This 
patch adds overloads for both libstdc++ and libc++ string formatters that 
accepts unsigned char.

Motivated by the following example:

  $ cat pretty_print.cc
  
  template 
  void print_val(T s) {
std::cerr << s << '\n';  // Set a breakpoint here!
  }
  
  int main() {
std::string val = "hello";
print_val(val);
return 0;
  }
  $ clang++ -stdlib=libc++ -funsigned-char -fstandalone-debug -g pretty_print.cc
  $ lldb ./a.out -b -o 'b pretty_print.cc:6' -o r -o 'fr v'
  ...
  (lldb) fr v
  (std::__1::basic_string, 
std::__1::allocator >) s = {
__r_ = {
  std::__1::__compressed_pair_elem, std::__1::allocator 
>::__rep, 0, false> = {
__value_ = {
   = {
__l = (__cap_ = 122511465736202, __size_ = 0, __data_ = 
0x)
__s = {
   = (__size_ = '\n', __lx = '\n')
  __data_ = {
[0] = 'h'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
[5] = '\0'
  ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70517

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -425,6 +425,13 @@
 "std::__[[:alnum:]]+::char_traits, "
 "std::__[[:alnum:]]+::allocator >$"),
 stl_summary_flags, true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibcxxStringSummaryProviderASCII,
+"std::string summary provider",
+ConstString("^std::__[[:alnum:]]+::basic_string, "
+"std::__[[:alnum:]]+::allocator >$"),
+stl_summary_flags, true);
 
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxStringSummaryProviderUTF16,
@@ -723,6 +730,10 @@
   ConstString("std::__cxx11::basic_string, "
   "std::allocator >"),
   cxx11_string_summary_sp);
+  cpp_category_sp->GetTypeSummariesContainer()->Add(
+  ConstString("std::__cxx11::basic_string, "
+  "std::allocator >"),
+  cxx11_string_summary_sp);
 
   // making sure we force-pick the summary for printing wstring (_M_p is a
   // wchar_t*)
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
@@ -9,6 +9,7 @@
 std::string empty("");
 std::string q("hello world");
 std::string Q("quite a long std::strin with lots of info inside it");
+std::basic_string uchar(5, 'a');
 S.assign(L"!"); // Set break point at this line.
 return 0;
 }
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
@@ -59,26 +59,28 @@
 var_empty = self.frame().FindVariable('empty')
 var_q = self.frame().FindVariable('q')
 var_Q = self.frame().FindVariable('Q')
+var_uchar = self.frame().FindVariable('uchar')
 
 # TODO: This is currently broken
-# self.assertTrue(var_wempty.GetSummary() == 'L""', "wempty summary wrong")
-self.assertTrue(
-var_s.GetSummary() == 'L"hello world! מזל טוב!"',
+# self.assertEqual(var_wempty.GetSummary(), 'L""', 

[Lldb-commits] [PATCH] D70324: [lldb][test] Prevent \n in calls to lldb's expect() test helper.

2019-11-19 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG327a18ca0a00: [lldb][test] Prevent \n in calls to 
lldbs expect() test helper. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D70324?vs=229593=230157#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70324

Files:
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py
  lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py


Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -24,26 +24,23 @@
 "help command" while exercising word-navigation, so type it as below,
 where [] indicates cursor position.
 
-1. Send "el ommand" -> "el ommand[]"
-2. Ctrl+left once   -> "el []ommand"
-3. Send "c" -> "el c[]ommand"
-4. Ctrl+left twice  -> "[]el command"
-5. Send "h" -> "h[]el command"
-6. Ctrl+right   -> "hel[] command"
-7. Send "p" -> "help command"
+1. Send "el rint"  -> "el rint[]"
+2. Ctrl+left once  -> "el []rint"
+3. Send "p"-> "el p[]rint"
+4. Ctrl+left twice -> "[]el print"
+5. Send "h"-> "h[]el print"
+6. Ctrl+right  -> "hel[] print"
+7. Send "p"-> "help print"
 """
 self.launch()
 
-# Run help for different commands for escape variants to make sure each
-# one matches uniquely (the buffer isn't cleared in between matches).
-cases = [
-("print", "\x1b[1;5D", "\x1b[1;5C"),
-("step", "\x1b[5D", "\x1b[5C"),
-("exit", "\x1b\x1b[D", "\x1b\x1b[C"),
+escape_pairs = [
+("\x1b[1;5D", "\x1b[1;5C"),
+("\x1b[5D", "\x1b[5C"),
+("\x1b\x1b[D", "\x1b\x1b[C"),
 ]
-for (cmd, l_escape, r_escape) in cases:
-self.expect("el {cmd_tail}{L}{cmd_head}{L}{L}h{R}p".format(
-cmd_head=cmd[0], cmd_tail=cmd[1:], L=l_escape, R=r_escape),
-substrs=["Syntax: %s" % cmd])
+for (l_escape, r_escape) in escape_pairs:
+self.expect("el rint{L}p{L}{L}h{R}p".format(
+L=l_escape, R=r_escape), substrs=["Syntax: print"])
 
 self.quit()
Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -50,6 +50,7 @@
 self.expect_prompt()
 
 def expect(self, cmd, substrs=None):
+self.assertNotIn('\n', cmd)
 self.child.sendline(cmd)
 if substrs is not None:
 for s in substrs:


Index: lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
===
--- lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
+++ lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -24,26 +24,23 @@
 "help command" while exercising word-navigation, so type it as below,
 where [] indicates cursor position.
 
-1. Send "el ommand" -> "el ommand[]"
-2. Ctrl+left once   -> "el []ommand"
-3. Send "c" -> "el c[]ommand"
-4. Ctrl+left twice  -> "[]el command"
-5. Send "h" -> "h[]el command"
-6. Ctrl+right   -> "hel[] command"
-7. Send "p" -> "help command"
+1. Send "el rint"  -> "el rint[]"
+2. Ctrl+left once  -> "el []rint"
+3. Send "p"-> "el p[]rint"
+4. Ctrl+left twice -> "[]el print"
+5. Send "h"-> "h[]el print"
+6. Ctrl+right  -> "hel[] print"
+7. Send "p"-> "help print"
 """
 self.launch()
 
-# Run help for different commands for escape variants to make sure each
-# one matches uniquely (the buffer isn't cleared in between matches).
-cases = [
-("print", "\x1b[1;5D", "\x1b[1;5C"),
-("step", "\x1b[5D", "\x1b[5C"),
-("exit", "\x1b\x1b[D", "\x1b\x1b[C"),
+escape_pairs = [
+("\x1b[1;5D", "\x1b[1;5C"),
+("\x1b[5D", "\x1b[5C"),
+("\x1b\x1b[D", "\x1b\x1b[C"),
 ]
-for (cmd, l_escape, r_escape) in cases:
-self.expect("el {cmd_tail}{L}{cmd_head}{L}{L}h{R}p".format(
-cmd_head=cmd[0], cmd_tail=cmd[1:], L=l_escape, R=r_escape),
-substrs=["Syntax: %s" % cmd])
+for (l_escape, r_escape) in escape_pairs:
+self.expect("el rint{L}p{L}{L}h{R}p".format(
+

[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-03 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D68299#1692503 , @labath wrote:

> > FYI, we've root caused some internal lldb asan failures to this patch. I 
> > don't have a repro yet (my lldb tests seem to be failing locally for 
> > unrelated reasons)
>
> This should be fixed with r373572.


Thanks!

> BTW, are you sure those reasons were unrelated? If you have had nearly every 
> test failing then it was very likely due to this. (The reason only a couple 
> of tests failed for you in asan mode is because our CI does not run a large 
> chunk of the lldb tests... :/ )

Yes, tests are still failing locally for me, e.g. 
`Driver/TestConvenienceVariables.test` in `ninja check-lldb-driver` fails:

  Command Output (stderr):
  --
  Traceback (most recent call last):
File "", line 1, in 
  ImportError: No module named lldb.embedded_interpreter
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  error: python failed attempting to evaluate 'print(lldb.debugger)'

I think it's a python-related misconfiguration somewhere about not finding the 
lldb module, but I'm not sure when it started -- these tests used to pass, but 
I nuked my cmake tree and apparently didn't reconfigure it correctly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D71150: [lldb][test] Create a separate LLDB_TEST_SRC var to allow moving tests.

2020-02-07 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht marked an inline comment as done.
rupprecht added inline comments.



Comment at: lldb/packages/Python/lldbsuite/__init__.py:32
+# TODO(rupprecht): update the above definition after moving test cases:
+# lldb_test_root = os.path.join(lldb_root, "test", "API", "test")

... I'm finally planning to submit this (checking now that the patch still 
passes), with an updated path based on D71151.

This patch is intended to be NFC, I'll retitle it when submitting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71150



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


[Lldb-commits] [PATCH] D71151: [lldb][test] Remove symlink for API tests.

2020-02-07 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D71151#1813772 , @labath wrote:

> Judging by the direction of the lua patches, it doesn't look like we will 
> have lua "dotest" tests, so I think it's fine to just put this into API 
> directly (without the extra "test" subfolder").


Updated the recipe in the description w/o the test subfolder.

Since this is a pretty large (though mechanical) change, I'll ping lldb-dev 
Monday to put it on peoples' radars.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71151



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


[Lldb-commits] [PATCH] D71150: [lldb][test] Create a separate LLDB_TEST_SRC var to allow moving tests.

2020-02-07 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG25675d4eaab6: [lldb][test][NFC] Create a separate 
LLDB_TEST_SRC var to allow moving tests. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D71150?vs=232656=243301#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71150

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -61,12 +61,13 @@
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
 lldb_build = os.environ["LLDB_BUILD"]
-if not (lldb_test and lldb_build and test_subdir and test_name and
-(not os.path.isabs(test_subdir))):
+if not (lldb_test and lldb_test_src and lldb_build and test_subdir and
+test_name and (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
 build_dir = os.path.join(lldb_build, test_subdir, test_name)
-src_dir = os.path.join(lldb_test, test_subdir)
+src_dir = os.path.join(lldb_test_src, test_subdir)
 # This is a bit of a hack to make inline testcases work.
 makefile = os.path.join(src_dir, "Makefile")
 if not os.path.isfile(makefile):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -498,7 +498,7 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST"]) + 1:]
+rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -518,10 +518,10 @@
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST} is defined.
-# See also dotest.py which sets up ${LLDB_TEST}.
-if ("LLDB_TEST" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST"],
+# Change current working directory if ${LLDB_TEST_SRC} is defined.
+# See also dotest.py which sets up ${LLDB_TEST_SRC}.
+if ("LLDB_TEST_SRC" in os.environ):
+full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
 cls.mydir)
 if traceAlways:
 print("Change dir to:", full_dir, file=sys.stderr)
@@ -656,7 +656,7 @@
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST"], self.mydir)
+return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1089,7 +1089,7 @@
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST"],
+dname = os.path.join(os.environ["LLDB_TEST_SRC"],
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -504,6 +504,7 @@
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
+os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 builddir = configuration.test_build_dir
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -20,10 +20,13 @@
 # lldbsuite.lldb_root refers to the root of the git/svn source checkout
 lldb_root = find_lldb_root()
 
-# lldbsuite.lldb_test_root refers to the root of the python test tree
+# lldbsuite.lldb_test_src_root refers to the root of the python test case tree
+# (i.e. the actual unit tests).
 lldb_test_root = os.path.join(
 lldb_root,
 "packages",
 "Python",
 "lldbsuite",
 "test")
+# TODO(rupprecht): update the above definition after moving test cases:
+# lldb_test_root = os.path.join(lldb_root, "test", "API")


Index: 

[Lldb-commits] [PATCH] D74859: [lldb] Fix version string when using LLDB_REVISION but not LLDB_REPOSITORY

2020-02-20 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ffa6e1a7e1c: [lldb] Fix version string when using 
LLDB_REVISION but not LLDB_REPOSITORY (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74859

Files:
  lldb/source/lldb.cpp


Index: lldb/source/lldb.cpp
===
--- lldb/source/lldb.cpp
+++ lldb/source/lldb.cpp
@@ -50,8 +50,10 @@
   g_version_str += " (";
   if (lldb_repo)
 g_version_str += lldb_repo;
+  if (lldb_repo && lldb_rev)
+g_version_str += " ";
   if (lldb_rev) {
-g_version_str += " revision ";
+g_version_str += "revision ";
 g_version_str += lldb_rev;
   }
   g_version_str += ")";


Index: lldb/source/lldb.cpp
===
--- lldb/source/lldb.cpp
+++ lldb/source/lldb.cpp
@@ -50,8 +50,10 @@
   g_version_str += " (";
   if (lldb_repo)
 g_version_str += lldb_repo;
+  if (lldb_repo && lldb_rev)
+g_version_str += " ";
   if (lldb_rev) {
-g_version_str += " revision ";
+g_version_str += "revision ";
 g_version_str += lldb_rev;
   }
   g_version_str += ")";
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74859: [lldb] Fix version string when using LLDB_REVISION but not LLDB_REPOSITORY

2020-02-19 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere, friss.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

lldb's format string (line one) is:
`lldb version $clang_version ($lldb_repo revision $lldb_revision)`

When only using $lldb_revision and not $lldb_repo, this might look like:
`lldb version 11 ( revision 12345)`
which looks pretty ugly.

Aside: I'm not sure we really need all the different versions since we've moved 
to the monorepo layout -- I don't think anyone is using different 
llvm/clang/lldb revisions, are they? We could likely tidy this up further if we 
knew how people consumed the output of lldb --version.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74859

Files:
  lldb/source/lldb.cpp


Index: lldb/source/lldb.cpp
===
--- lldb/source/lldb.cpp
+++ lldb/source/lldb.cpp
@@ -50,8 +50,10 @@
   g_version_str += " (";
   if (lldb_repo)
 g_version_str += lldb_repo;
+  if (lldb_repo && lldb_rev)
+g_version_str += " ";
   if (lldb_rev) {
-g_version_str += " revision ";
+g_version_str += "revision ";
 g_version_str += lldb_rev;
   }
   g_version_str += ")";


Index: lldb/source/lldb.cpp
===
--- lldb/source/lldb.cpp
+++ lldb/source/lldb.cpp
@@ -50,8 +50,10 @@
   g_version_str += " (";
   if (lldb_repo)
 g_version_str += lldb_repo;
+  if (lldb_repo && lldb_rev)
+g_version_str += " ";
   if (lldb_rev) {
-g_version_str += " revision ";
+g_version_str += "revision ";
 g_version_str += lldb_rev;
   }
   g_version_str += ")";
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71151: [lldb][test] Remove symlink for API tests.

2020-02-11 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99451b445368: [lldb][test] Remove symlink for API tests. 
(authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D71151?vs=232658=243908#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71151

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/android/platform/Makefile
  
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
  lldb/packages/Python/lldbsuite/test/android/platform/main.cpp
  lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/Makefile
  
lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py
  
lldb/packages/Python/lldbsuite/test/api/check_public_api_headers/main.cpp.template
  lldb/packages/Python/lldbsuite/test/api/command-return-object/Makefile
  
lldb/packages/Python/lldbsuite/test/api/command-return-object/TestSBCommandReturnObject.py
  lldb/packages/Python/lldbsuite/test/api/command-return-object/main.cpp
  lldb/packages/Python/lldbsuite/test/api/listeners/Makefile
  lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py
  lldb/packages/Python/lldbsuite/test/api/listeners/main.c
  lldb/packages/Python/lldbsuite/test/api/log/TestAPILog.py
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/.categories
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/Makefile
  
lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
  
lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
  lldb/packages/Python/lldbsuite/test/api/multiple-debuggers/testprog.cpp
  lldb/packages/Python/lldbsuite/test/api/multiple-targets/Makefile
  
lldb/packages/Python/lldbsuite/test/api/multiple-targets/TestMultipleTargets.py
  lldb/packages/Python/lldbsuite/test/api/multiple-targets/main.cpp
  lldb/packages/Python/lldbsuite/test/api/multithreaded/Makefile
  lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
  lldb/packages/Python/lldbsuite/test/api/multithreaded/common.h
  lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template
  lldb/packages/Python/lldbsuite/test/api/multithreaded/inferior.cpp
  
lldb/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template
  
lldb/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template
  
lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template
  
lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template
  
lldb/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template
  lldb/packages/Python/lldbsuite/test/arm/breakpoint-it/Makefile
  lldb/packages/Python/lldbsuite/test/arm/breakpoint-it/TestBreakpointIt.py
  lldb/packages/Python/lldbsuite/test/arm/breakpoint-it/main.c
  lldb/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile
  
lldb/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py
  lldb/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c
  lldb/packages/Python/lldbsuite/test/arm/emulation/TestEmulations.py
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-1-arm.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-1-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-10-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-11-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-12-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-2-arm.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-2-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-3-arm.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-3-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-4-arm.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-4-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-5-arm.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-5-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-6-arm.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-6-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-7-arm.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-7-thumb.dat
  
lldb/packages/Python/lldbsuite/test/arm/emulation/new-test-files/test-add-8-arm.dat
  

[Lldb-commits] [PATCH] D86818: [lldb/Host] Add missing proc states

2020-09-02 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5aa63dd560b: [lldb/Host] Add missing proc states (authored 
by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86818

Files:
  lldb/source/Host/linux/Host.cpp


Index: lldb/source/Host/linux/Host.cpp
===
--- lldb/source/Host/linux/Host.cpp
+++ lldb/source/Host/linux/Host.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Object/ELF.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -35,8 +36,11 @@
 namespace {
 enum class ProcessState {
   Unknown,
+  Dead,
   DiskSleep,
+  Idle,
   Paging,
+  Parked,
   Running,
   Sleeping,
   TracedOrStopped,
@@ -50,12 +54,14 @@
 
 static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo ,
   ProcessState , ::pid_t ) {
+  Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
   auto BufferOrError = getProcFile(Pid, "status");
   if (!BufferOrError)
 return false;
 
   llvm::StringRef Rest = BufferOrError.get()->getBuffer();
-  while(!Rest.empty()) {
+  while (!Rest.empty()) {
 llvm::StringRef Line;
 std::tie(Line, Rest) = Rest.split('\n');
 
@@ -84,26 +90,19 @@
   Line.ltrim().consumeInteger(10, PPid);
   ProcessInfo.SetParentProcessID(PPid);
 } else if (Line.consume_front("State:")) {
-  char S = Line.ltrim().front();
-  switch (S) {
-  case 'R':
-State = ProcessState::Running;
-break;
-  case 'S':
-State = ProcessState::Sleeping;
-break;
-  case 'D':
-State = ProcessState::DiskSleep;
-break;
-  case 'Z':
-State = ProcessState::Zombie;
-break;
-  case 'T':
-State = ProcessState::TracedOrStopped;
-break;
-  case 'W':
-State = ProcessState::Paging;
-break;
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
   }
 } else if (Line.consume_front("TracerPid:")) {
   Line = Line.ltrim();


Index: lldb/source/Host/linux/Host.cpp
===
--- lldb/source/Host/linux/Host.cpp
+++ lldb/source/Host/linux/Host.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Object/ELF.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -35,8 +36,11 @@
 namespace {
 enum class ProcessState {
   Unknown,
+  Dead,
   DiskSleep,
+  Idle,
   Paging,
+  Parked,
   Running,
   Sleeping,
   TracedOrStopped,
@@ -50,12 +54,14 @@
 
 static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo ,
   ProcessState , ::pid_t ) {
+  Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
   auto BufferOrError = getProcFile(Pid, "status");
   if (!BufferOrError)
 return false;
 
   llvm::StringRef Rest = BufferOrError.get()->getBuffer();
-  while(!Rest.empty()) {
+  while (!Rest.empty()) {
 llvm::StringRef Line;
 std::tie(Line, Rest) = Rest.split('\n');
 
@@ -84,26 +90,19 @@
   Line.ltrim().consumeInteger(10, PPid);
   ProcessInfo.SetParentProcessID(PPid);
 } else if (Line.consume_front("State:")) {
-  char S = Line.ltrim().front();
-  switch (S) {
-  case 'R':
-State = ProcessState::Running;
-break;
-  case 'S':
-State = ProcessState::Sleeping;
-break;
-  case 'D':
-State = ProcessState::DiskSleep;
-break;
-  case 'Z':
-State = ProcessState::Zombie;
-break;
-  case 'T':
-State = ProcessState::TracedOrStopped;
-break;
-  case 'W':
-State = ProcessState::Paging;
-break;
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+

[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-09 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 290799.
rupprecht added a comment.

- Don't use "localhost" to avoid dns latency. Instead, prefer either 127.0.0.1 
or ::1 directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Host/SocketTestUtilities.cpp

Index: lldb/unittests/Host/SocketTestUtilities.cpp
===
--- lldb/unittests/Host/SocketTestUtilities.cpp
+++ lldb/unittests/Host/SocketTestUtilities.cpp
@@ -101,13 +101,14 @@
  "Creating a canary {0} TCP socket failed: {1}.",
  Proto, Err)
  .str();
-  bool HasAddrNotAvail = false;
+  bool HasProtocolError = false;
   handleAllErrors(std::move(Err), [&](std::unique_ptr ECErr) {
-if (ECErr->convertToErrorCode() ==
-std::make_error_code(std::errc::address_not_available))
-  HasAddrNotAvail = true;
+std::error_code ec = ECErr->convertToErrorCode();
+if (ec == std::make_error_code(std::errc::address_family_not_supported) ||
+ec == std::make_error_code(std::errc::address_not_available))
+  HasProtocolError = true;
   });
-  if (HasAddrNotAvail) {
+  if (HasProtocolError) {
 GTEST_LOG_(WARNING)
 << llvm::formatv(
"Assuming the host does not support {0}. Skipping test.", Proto)
Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -14,12 +14,24 @@
 
 using namespace lldb_private;
 
-class SocketTest : public testing::Test {
+struct SocketTestParams {
+  bool is_ipv6;
+  std::string localhost_ip;
+};
+
+class SocketTest : public testing::TestWithParam {
 public:
   SubsystemRAII subsystems;
+
+protected:
+  bool HostSupportsProtocol() const {
+if (GetParam().is_ipv6)
+  return HostSupportsIPv6();
+return HostSupportsIPv4();
+  }
 };
 
-TEST_F(SocketTest, DecodeHostAndPort) {
+TEST_P(SocketTest, DecodeHostAndPort) {
   std::string host_str;
   std::string port_str;
   int32_t port;
@@ -86,7 +98,7 @@
 }
 
 #if LLDB_ENABLE_POSIX
-TEST_F(SocketTest, DomainListenConnectAccept) {
+TEST_P(SocketTest, DomainListenConnectAccept) {
   llvm::SmallString<64> Path;
   std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
   ASSERT_FALSE(EC);
@@ -102,18 +114,22 @@
 }
 #endif
 
-TEST_F(SocketTest, TCPListen0ConnectAccept) {
+TEST_P(SocketTest, TCPListen0ConnectAccept) {
+  if (!HostSupportsProtocol())
+return;
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 }
 
-TEST_F(SocketTest, TCPGetAddress) {
+TEST_P(SocketTest, TCPGetAddress) {
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  if (!HostSupportsIPv4())
+  if (!HostSupportsProtocol())
 return;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 
   EXPECT_EQ(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetRemotePortNumber());
@@ -121,19 +137,26 @@
 socket_a_up->GetRemotePortNumber());
   EXPECT_NE(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetLocalPortNumber());
-  EXPECT_STREQ("127.0.0.1", socket_a_up->GetRemoteIPAddress().c_str());
-  EXPECT_STREQ("127.0.0.1", socket_b_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_a_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_b_up->GetRemoteIPAddress().c_str());
 }
 
-TEST_F(SocketTest, UDPConnect) {
-  llvm::Expected> socket =
-  UDPSocket::Connect("127.0.0.1:0", /*child_processes_inherit=*/false);
+TEST_P(SocketTest, UDPConnect) {
+  // UDPSocket::Connect() creates sockets with AF_INET (IPv4).
+  if (!HostSupportsIPv4())
+return;
+  llvm::Expected> socket = UDPSocket::Connect(
+  "127.0.0.1:0", /*child_processes_inherit=*/false);
 
   ASSERT_THAT_EXPECTED(socket, llvm::Succeeded());
   EXPECT_TRUE(socket.get()->IsValid());
 }
 
-TEST_F(SocketTest, TCPListen0GetPort) {
+TEST_P(SocketTest, TCPListen0GetPort) {
+  if (!HostSupportsIPv4())
+return;
   Predicate port_predicate;
   port_predicate.SetValue(0, eBroadcastNever);
   llvm::Expected> sock =
@@ 

[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-09 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

This is ready for review now after scrubbing out the "localhost" changes I had 
earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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


[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-09 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 290800.
rupprecht added a comment.

- clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Host/SocketTestUtilities.cpp

Index: lldb/unittests/Host/SocketTestUtilities.cpp
===
--- lldb/unittests/Host/SocketTestUtilities.cpp
+++ lldb/unittests/Host/SocketTestUtilities.cpp
@@ -101,13 +101,14 @@
  "Creating a canary {0} TCP socket failed: {1}.",
  Proto, Err)
  .str();
-  bool HasAddrNotAvail = false;
+  bool HasProtocolError = false;
   handleAllErrors(std::move(Err), [&](std::unique_ptr ECErr) {
-if (ECErr->convertToErrorCode() ==
-std::make_error_code(std::errc::address_not_available))
-  HasAddrNotAvail = true;
+std::error_code ec = ECErr->convertToErrorCode();
+if (ec == std::make_error_code(std::errc::address_family_not_supported) ||
+ec == std::make_error_code(std::errc::address_not_available))
+  HasProtocolError = true;
   });
-  if (HasAddrNotAvail) {
+  if (HasProtocolError) {
 GTEST_LOG_(WARNING)
 << llvm::formatv(
"Assuming the host does not support {0}. Skipping test.", Proto)
Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -14,12 +14,24 @@
 
 using namespace lldb_private;
 
-class SocketTest : public testing::Test {
+struct SocketTestParams {
+  bool is_ipv6;
+  std::string localhost_ip;
+};
+
+class SocketTest : public testing::TestWithParam {
 public:
   SubsystemRAII subsystems;
+
+protected:
+  bool HostSupportsProtocol() const {
+if (GetParam().is_ipv6)
+  return HostSupportsIPv6();
+return HostSupportsIPv4();
+  }
 };
 
-TEST_F(SocketTest, DecodeHostAndPort) {
+TEST_P(SocketTest, DecodeHostAndPort) {
   std::string host_str;
   std::string port_str;
   int32_t port;
@@ -86,7 +98,7 @@
 }
 
 #if LLDB_ENABLE_POSIX
-TEST_F(SocketTest, DomainListenConnectAccept) {
+TEST_P(SocketTest, DomainListenConnectAccept) {
   llvm::SmallString<64> Path;
   std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
   ASSERT_FALSE(EC);
@@ -102,18 +114,22 @@
 }
 #endif
 
-TEST_F(SocketTest, TCPListen0ConnectAccept) {
+TEST_P(SocketTest, TCPListen0ConnectAccept) {
+  if (!HostSupportsProtocol())
+return;
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 }
 
-TEST_F(SocketTest, TCPGetAddress) {
+TEST_P(SocketTest, TCPGetAddress) {
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  if (!HostSupportsIPv4())
+  if (!HostSupportsProtocol())
 return;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 
   EXPECT_EQ(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetRemotePortNumber());
@@ -121,11 +137,16 @@
 socket_a_up->GetRemotePortNumber());
   EXPECT_NE(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetLocalPortNumber());
-  EXPECT_STREQ("127.0.0.1", socket_a_up->GetRemoteIPAddress().c_str());
-  EXPECT_STREQ("127.0.0.1", socket_b_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_a_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_b_up->GetRemoteIPAddress().c_str());
 }
 
-TEST_F(SocketTest, UDPConnect) {
+TEST_P(SocketTest, UDPConnect) {
+  // UDPSocket::Connect() creates sockets with AF_INET (IPv4).
+  if (!HostSupportsIPv4())
+return;
   llvm::Expected> socket =
   UDPSocket::Connect("127.0.0.1:0", /*child_processes_inherit=*/false);
 
@@ -133,7 +154,9 @@
   EXPECT_TRUE(socket.get()->IsValid());
 }
 
-TEST_F(SocketTest, TCPListen0GetPort) {
+TEST_P(SocketTest, TCPListen0GetPort) {
+  if (!HostSupportsIPv4())
+return;
   Predicate port_predicate;
   port_predicate.SetValue(0, eBroadcastNever);
   llvm::Expected> sock =
@@ -143,12 +166,13 @@
   EXPECT_NE(sock.get()->GetLocalPortNumber(), 0);
 }
 
-TEST_F(SocketTest, TCPGetConnectURI) {
+TEST_P(SocketTest, TCPGetConnectURI) {
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;

[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-15 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D87333#2273506 , @labath wrote:

> (Sorry about the delay.) Given the current requirements, I think this patch 
> is fine (excellent even).
>
> That said, I'm not sure whether the original motivation for this requirement 
> (avoiding dns lookups) is still relevant. These days, we communicate with the 
> local debug server via `socketpair(2)` sockets (which wasn't the case back 
> then), which does not require any dns lookups and is immune to a 
> misconfigured hosts file.

The initial dns lookup may still fail, I think? e.g. my initial version of this 
patch had:

  if (llvm::Error error =
  listen_socket.Listen("localhost:0", backlog).ToError())

If the hosts file has a bad value for localhost, that will create a bad socket. 
That said, I don't know how to reproduce the original issue -- maybe it isn't 
an issue for some other reason.

> Given that none of the things touched by this patch is extremely critical 
> (`GDBRemoteCommunication::ConnectLocally` is used for reproducers and the 
> rest is test code), maybe we could use this to test the water and see whether 
> we can start using the network stack the way it's supposed to be used ?

Many non-reproducers tests fail w/o the change to 
`GDBRemoteCommunication::ConnectLocally`, so it's at least used outside of that.

I can go either way with using `localhost` or using hard-coded localhost IPs. 
Whichever way we go, I have a slight preference for keeping the tests and code 
consistent, e.g. if we use hard-coded IPs in code linked into lldb to allow 
people with a bad hosts file to use lldb, we should use hard-coded IPs in the 
tests to allow those same users to develop on lldb.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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


[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-15 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 291956.
rupprecht marked an inline comment as done.
rupprecht added a comment.

- Compare directly against the error code instead of hopping through 
`std::make_error_code()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Host/SocketTestUtilities.cpp

Index: lldb/unittests/Host/SocketTestUtilities.cpp
===
--- lldb/unittests/Host/SocketTestUtilities.cpp
+++ lldb/unittests/Host/SocketTestUtilities.cpp
@@ -101,13 +101,14 @@
  "Creating a canary {0} TCP socket failed: {1}.",
  Proto, Err)
  .str();
-  bool HasAddrNotAvail = false;
+  bool HasProtocolError = false;
   handleAllErrors(std::move(Err), [&](std::unique_ptr ECErr) {
-if (ECErr->convertToErrorCode() ==
-std::make_error_code(std::errc::address_not_available))
-  HasAddrNotAvail = true;
+std::error_code ec = ECErr->convertToErrorCode();
+if (ec == std::make_error_code(std::errc::address_family_not_supported) ||
+ec == std::make_error_code(std::errc::address_not_available))
+  HasProtocolError = true;
   });
-  if (HasAddrNotAvail) {
+  if (HasProtocolError) {
 GTEST_LOG_(WARNING)
 << llvm::formatv(
"Assuming the host does not support {0}. Skipping test.", Proto)
Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -14,12 +14,24 @@
 
 using namespace lldb_private;
 
-class SocketTest : public testing::Test {
+struct SocketTestParams {
+  bool is_ipv6;
+  std::string localhost_ip;
+};
+
+class SocketTest : public testing::TestWithParam {
 public:
   SubsystemRAII subsystems;
+
+protected:
+  bool HostSupportsProtocol() const {
+if (GetParam().is_ipv6)
+  return HostSupportsIPv6();
+return HostSupportsIPv4();
+  }
 };
 
-TEST_F(SocketTest, DecodeHostAndPort) {
+TEST_P(SocketTest, DecodeHostAndPort) {
   std::string host_str;
   std::string port_str;
   int32_t port;
@@ -86,7 +98,7 @@
 }
 
 #if LLDB_ENABLE_POSIX
-TEST_F(SocketTest, DomainListenConnectAccept) {
+TEST_P(SocketTest, DomainListenConnectAccept) {
   llvm::SmallString<64> Path;
   std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
   ASSERT_FALSE(EC);
@@ -102,18 +114,22 @@
 }
 #endif
 
-TEST_F(SocketTest, TCPListen0ConnectAccept) {
+TEST_P(SocketTest, TCPListen0ConnectAccept) {
+  if (!HostSupportsProtocol())
+return;
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 }
 
-TEST_F(SocketTest, TCPGetAddress) {
+TEST_P(SocketTest, TCPGetAddress) {
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  if (!HostSupportsIPv4())
+  if (!HostSupportsProtocol())
 return;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 
   EXPECT_EQ(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetRemotePortNumber());
@@ -121,11 +137,16 @@
 socket_a_up->GetRemotePortNumber());
   EXPECT_NE(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetLocalPortNumber());
-  EXPECT_STREQ("127.0.0.1", socket_a_up->GetRemoteIPAddress().c_str());
-  EXPECT_STREQ("127.0.0.1", socket_b_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_a_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_b_up->GetRemoteIPAddress().c_str());
 }
 
-TEST_F(SocketTest, UDPConnect) {
+TEST_P(SocketTest, UDPConnect) {
+  // UDPSocket::Connect() creates sockets with AF_INET (IPv4).
+  if (!HostSupportsIPv4())
+return;
   llvm::Expected> socket =
   UDPSocket::Connect("127.0.0.1:0", /*child_processes_inherit=*/false);
 
@@ -133,7 +154,9 @@
   EXPECT_TRUE(socket.get()->IsValid());
 }
 
-TEST_F(SocketTest, TCPListen0GetPort) {
+TEST_P(SocketTest, TCPListen0GetPort) {
+  if (!HostSupportsIPv4())
+return;
   Predicate port_predicate;
   port_predicate.SetValue(0, eBroadcastNever);
   llvm::Expected> sock =
@@ -143,12 +166,13 @@
   EXPECT_NE(sock.get()->GetLocalPortNumber(), 0);
 }
 
-TEST_F(SocketTest, 

[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest

2020-09-14 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.

Register the `faulthandler` module so we can see what lldb tests are doing when 
they misbehave (e.g. run under a test runner that sets a timeout). This will 
print a stack trace for the following signals:

- `SIGSEGV`, `SIGFPE`, `SIGABRT`, `SIGBUS`, and `SIGILL` (via 
`faulthandler.enable()`)
- `SIGTERM` (via `faulthandler.register(SIGTERM)`) [This is what our test 
runners sends when it times out].

The only signal we currently handle is `SIGINT` (via 
`unittest2.signals.installHandler()`) so there should be no overlap added by 
this patch.

Because this import is not available until python3, and the `register()` method 
is not available on Windows, this is enabled defensively.

This should have absolutely no effect when tests are passing (or even normally 
failing), but can be observed by running this while ninja is running:

  kill -s SIGTERM $(ps aux | grep dotest.py | head -1 | awk '{print $2}')


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87637

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -449,6 +449,18 @@
 
 lldbtest_config.codesign_identity = args.codesign_identity
 
+def registerFaulthandler():
+try:
+import faulthandler
+except ImportError:
+# faulthandler is not available until python3
+return
+
+faulthandler.enable()
+# faulthandler.register is not available on Windows.
+if getattr(faulthandler, 'register', None):
+faulthandler.register(signal.SIGTERM, chain=True)
+
 def setupSysPath():
 """
 Add LLDB.framework/Resources/Python to the search paths for modules.
@@ -875,6 +887,9 @@
 #
 parseOptionsAndInitTestdirs()
 
+# Print a stack trace if the test hangs or is passed SIGTERM.
+registerFaulthandler()
+
 setupSysPath()
 
 import lldbconfig


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -449,6 +449,18 @@
 
 lldbtest_config.codesign_identity = args.codesign_identity
 
+def registerFaulthandler():
+try:
+import faulthandler
+except ImportError:
+# faulthandler is not available until python3
+return
+
+faulthandler.enable()
+# faulthandler.register is not available on Windows.
+if getattr(faulthandler, 'register', None):
+faulthandler.register(signal.SIGTERM, chain=True)
+
 def setupSysPath():
 """
 Add LLDB.framework/Resources/Python to the search paths for modules.
@@ -875,6 +887,9 @@
 #
 parseOptionsAndInitTestdirs()
 
+# Print a stack trace if the test hangs or is passed SIGTERM.
+registerFaulthandler()
+
 setupSysPath()
 
 import lldbconfig
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86825: [lldb/Gui] zero-initialize children_stop_id

2020-09-02 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7e04b710d2d: [lldb/Gui] zero-initialize children_stop_id 
(authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D86825?vs=288731=289625#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86825

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1497,19 +1497,18 @@
   ValueObjectManager value;
   Row *parent;
   // The process stop ID when the children were calculated.
-  uint32_t children_stop_id;
-  int row_idx;
-  int x;
-  int y;
+  uint32_t children_stop_id = 0;
+  int row_idx = 0;
+  int x = 1;
+  int y = 1;
   bool might_have_children;
-  bool expanded;
-  bool calculated_children;
+  bool expanded = false;
+  bool calculated_children = false;
   std::vector children;
 
   Row(const ValueObjectSP , Row *p)
-  : value(v, lldb::eDynamicDontRunTarget, true), parent(p), row_idx(0),
-x(1), y(1), might_have_children(v ? v->MightHaveChildren() : false),
-expanded(false), calculated_children(false), children() {}
+  : value(v, lldb::eDynamicDontRunTarget, true), parent(p),
+might_have_children(v ? v->MightHaveChildren() : false) {}
 
   size_t GetDepth() const {
 if (parent)


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1497,19 +1497,18 @@
   ValueObjectManager value;
   Row *parent;
   // The process stop ID when the children were calculated.
-  uint32_t children_stop_id;
-  int row_idx;
-  int x;
-  int y;
+  uint32_t children_stop_id = 0;
+  int row_idx = 0;
+  int x = 1;
+  int y = 1;
   bool might_have_children;
-  bool expanded;
-  bool calculated_children;
+  bool expanded = false;
+  bool calculated_children = false;
   std::vector children;
 
   Row(const ValueObjectSP , Row *p)
-  : value(v, lldb::eDynamicDontRunTarget, true), parent(p), row_idx(0),
-x(1), y(1), might_have_children(v ? v->MightHaveChildren() : false),
-expanded(false), calculated_children(false), children() {}
+  : value(v, lldb::eDynamicDontRunTarget, true), parent(p),
+might_have_children(v ? v->MightHaveChildren() : false) {}
 
   size_t GetDepth() const {
 if (parent)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86825: [lldb/Gui] zero-initialize children_stop_id

2020-09-02 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht marked an inline comment as done.
rupprecht added a comment.

SG, will land momentarily with the one formatting change. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86825

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


[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-08 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D87333#2262241 , @clayborg wrote:

> In D87333#2262236 , @rupprecht wrote:
>
>> In D87333#2262229 , @clayborg wrote:
>>
>>> FYI: we switched away from "localhost" a long time ago due to issues with 
>>> people having a "localhost" entry in their /etc/hosts folder.
>>
>> I assume you mean people *not* having a "localhost" entry?
>
> I believe the issue was with people having a modified version that replaces 
> localhost with some other IP address.
>
>> I didn't even realize that was an option. Yes, this patch would break that. 
>> I'll have to take another approach, then.
>
> You might check the "git log" on any files that have "127.0.0.1" in them for 
> details.
>
>> Do you happen to have any references (bugs etc.) for those kinds of issues?

Looks like rLLDB202424  is the patch that 
did most of this. There may be more context in rdar://problem/16154630 but I 
don't have access to that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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


[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-08 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D87333#2262229 , @clayborg wrote:

> FYI: we switched away from "localhost" a long time ago due to issues with 
> people having a "localhost" entry in their /etc/hosts folder.

I assume you mean people *not* having a "localhost" entry? I didn't even 
realize that was an option. Yes, this patch would break that. I'll have to take 
another approach, then.

Do you happen to have any references (bugs etc.) for those kinds of issues?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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


[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-08 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, clayborg.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

When running in an ipv6-only environment where `AF_INET` sockets are not 
available, many lldb tests (mostly gdb remote tests) fail because things like 
`127.0.0.1` don't work there.

This change is mostly a simple search-and-replace of `127.0.0.1` -> `localhost` 
until tests pass in an internal ipv6-only environment. A few places have been 
updated to dynamically retry with `AF_INET6` if creating a socket with 
`AF_INET` doesn't work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87333

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  lldb/source/Target/Platform.cpp
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Host/SocketTestUtilities.cpp

Index: lldb/unittests/Host/SocketTestUtilities.cpp
===
--- lldb/unittests/Host/SocketTestUtilities.cpp
+++ lldb/unittests/Host/SocketTestUtilities.cpp
@@ -101,13 +101,14 @@
  "Creating a canary {0} TCP socket failed: {1}.",
  Proto, Err)
  .str();
-  bool HasAddrNotAvail = false;
+  bool HasProtocolError = false;
   handleAllErrors(std::move(Err), [&](std::unique_ptr ECErr) {
-if (ECErr->convertToErrorCode() ==
-std::make_error_code(std::errc::address_not_available))
-  HasAddrNotAvail = true;
+std::error_code ec = ECErr->convertToErrorCode();
+if (ec == std::make_error_code(std::errc::address_family_not_supported) ||
+ec == std::make_error_code(std::errc::address_not_available))
+  HasProtocolError = true;
   });
-  if (HasAddrNotAvail) {
+  if (HasProtocolError) {
 GTEST_LOG_(WARNING)
 << llvm::formatv(
"Assuming the host does not support {0}. Skipping test.", Proto)
Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -14,12 +14,24 @@
 
 using namespace lldb_private;
 
-class SocketTest : public testing::Test {
+struct SocketTestParams {
+  bool is_ipv6;
+  std::string localhost_ip;
+};
+
+class SocketTest : public testing::TestWithParam {
 public:
   SubsystemRAII subsystems;
+
+protected:
+  bool HostSupportsProtocol() const {
+if (GetParam().is_ipv6)
+  return HostSupportsIPv6();
+return HostSupportsIPv4();
+  }
 };
 
-TEST_F(SocketTest, DecodeHostAndPort) {
+TEST_P(SocketTest, DecodeHostAndPort) {
   std::string host_str;
   std::string port_str;
   int32_t port;
@@ -86,7 +98,7 @@
 }
 
 #if LLDB_ENABLE_POSIX
-TEST_F(SocketTest, DomainListenConnectAccept) {
+TEST_P(SocketTest, DomainListenConnectAccept) {
   llvm::SmallString<64> Path;
   std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
   ASSERT_FALSE(EC);
@@ -102,18 +114,22 @@
 }
 #endif
 
-TEST_F(SocketTest, TCPListen0ConnectAccept) {
+TEST_P(SocketTest, TCPListen0ConnectAccept) {
+  if (!HostSupportsProtocol())
+return;
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 }
 
-TEST_F(SocketTest, TCPGetAddress) {
+TEST_P(SocketTest, TCPGetAddress) {
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  if (!HostSupportsIPv4())
+  if (!HostSupportsProtocol())
 return;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 
   EXPECT_EQ(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetRemotePortNumber());
@@ -121,11 +137,16 @@
 socket_a_up->GetRemotePortNumber());
   EXPECT_NE(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetLocalPortNumber());
-  EXPECT_STREQ("127.0.0.1", socket_a_up->GetRemoteIPAddress().c_str());
-  EXPECT_STREQ("127.0.0.1", socket_b_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_a_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_b_up->GetRemoteIPAddress().c_str());
 }
 
-TEST_F(SocketTest, UDPConnect) {
+TEST_P(SocketTest, UDPConnect) {
+  // UDPSocket::Connect() creates sockets with AF_INET (IPv4).
+  if 

[Lldb-commits] [PATCH] D88840: [dotest] Simplify logic to find the Python path

2020-10-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht accepted this revision.
rupprecht added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:550-551
+# If our lldb supports the -P option, use it to find the python path:
+with open(os.devnull, 'w') as DEVNULL:
+lldb_dash_p_result = 
subprocess.check_output([lldbtest_config.lldbExec, "-P"], stderr=DEVNULL, 
universal_newlines=True)
+if lldb_dash_p_result:

Is DEVNULL necessary? I think `stderr=None` might work just as well.

FWIW, subprocess.DEVNULL exists as of python 3.3, but I guess we still have 
python2 users.


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

https://reviews.llvm.org/D88840

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


[Lldb-commits] [PATCH] D88840: [dotest] Simplify logic to find the Python path

2020-10-06 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D88840#2313331 , @kastiglione wrote:

> About `-P`, the man page for `lldb` and the driver's `Options.td` say it:
>
>> Prints out the path to the lldb.py file for this version of lldb.
>
> Should it do just that? If so this can be simplified further.

It can print the path, or it can print `` if e.g. lldb 
wasn't built with python support or has some non-standard python setup. So I 
think this is basically as simple as the parsing can get.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88840

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


[Lldb-commits] [PATCH] D86752: [lldb/test] Use shorter test case names in TestStandardUnwind

2020-08-28 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bd895cac0cd: [lldb/test] Use shorter test case names in 
TestStandardUnwind (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86752

Files:
  lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py


Index: lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
===
--- lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
+++ lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
@@ -164,7 +164,7 @@
 self.skipTest("Inferior not supported")
 self.standard_unwind_tests()
 
-test_name = "test_unwind_" + str(f)
+test_name = "test_unwind_" + str(os.path.basename(f))
 for c in ".=()/\\":
 test_name = test_name.replace(c, '_')
 


Index: lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
===
--- lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
+++ lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
@@ -164,7 +164,7 @@
 self.skipTest("Inferior not supported")
 self.standard_unwind_tests()
 
-test_name = "test_unwind_" + str(f)
+test_name = "test_unwind_" + str(os.path.basename(f))
 for c in ".=()/\\":
 test_name = test_name.replace(c, '_')
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86825: [lldb/Gui] zero-initialize children_stop_id

2020-08-28 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added subscribers: lldb-commits, danielkiss.
Herald added a project: LLDB.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

This is currently causing msan warnings in the API tests when run under msan, 
e.g. `commands/gui/basic/TestGuiBasic.py`.

I'm not sure if 0 is the right initial value, but the tests pass with it (and 
msan doesn't complain anymore).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86825

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1507,8 +1507,9 @@
   std::vector children;
 
   Row(const ValueObjectSP , Row *p)
-  : value(v, lldb::eDynamicDontRunTarget, true), parent(p), row_idx(0),
-x(1), y(1), might_have_children(v ? v->MightHaveChildren() : false),
+  : value(v, lldb::eDynamicDontRunTarget, true), parent(p),
+children_stop_id(0), row_idx(0), x(1), y(1),
+might_have_children(v ? v->MightHaveChildren() : false),
 expanded(false), calculated_children(false), children() {}
 
   size_t GetDepth() const {


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1507,8 +1507,9 @@
   std::vector children;
 
   Row(const ValueObjectSP , Row *p)
-  : value(v, lldb::eDynamicDontRunTarget, true), parent(p), row_idx(0),
-x(1), y(1), might_have_children(v ? v->MightHaveChildren() : false),
+  : value(v, lldb::eDynamicDontRunTarget, true), parent(p),
+children_stop_id(0), row_idx(0), x(1), y(1),
+might_have_children(v ? v->MightHaveChildren() : false),
 expanded(false), calculated_children(false), children() {}
 
   size_t GetDepth() const {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86818: [lldb/Host] Add missing proc states

2020-08-28 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added subscribers: lldb-commits, danielkiss.
Herald added a project: LLDB.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

The /proc//status parsing is missing a few cases:

- Idle
- Parked
- Dead

If we encounter an unknown proc state, this leads to an msan warning. In 
reality, we only check that the state != Zombie, so it doesn't really matter 
that we handle all cases, but handle them anyway (current list: [1]). Also 
explicitly set it to unknown if we encounter an unknown state. There will still 
be an msan warning if the proc entry has no `State:` line, but that should not 
happen.

Use a StringSwitch to make the handling of proc states a little more compact.

[1] https://github.com/torvalds/linux/blob/master/fs/proc/array.c


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86818

Files:
  lldb/source/Host/linux/Host.cpp


Index: lldb/source/Host/linux/Host.cpp
===
--- lldb/source/Host/linux/Host.cpp
+++ lldb/source/Host/linux/Host.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Object/ELF.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -35,8 +36,11 @@
 namespace {
 enum class ProcessState {
   Unknown,
+  Dead,
   DiskSleep,
+  Idle,
   Paging,
+  Parked,
   Running,
   Sleeping,
   TracedOrStopped,
@@ -50,12 +54,14 @@
 
 static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo ,
   ProcessState , ::pid_t ) {
+  Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
   auto BufferOrError = getProcFile(Pid, "status");
   if (!BufferOrError)
 return false;
 
   llvm::StringRef Rest = BufferOrError.get()->getBuffer();
-  while(!Rest.empty()) {
+  while (!Rest.empty()) {
 llvm::StringRef Line;
 std::tie(Line, Rest) = Rest.split('\n');
 
@@ -84,26 +90,19 @@
   Line.ltrim().consumeInteger(10, PPid);
   ProcessInfo.SetParentProcessID(PPid);
 } else if (Line.consume_front("State:")) {
-  char S = Line.ltrim().front();
-  switch (S) {
-  case 'R':
-State = ProcessState::Running;
-break;
-  case 'S':
-State = ProcessState::Sleeping;
-break;
-  case 'D':
-State = ProcessState::DiskSleep;
-break;
-  case 'Z':
-State = ProcessState::Zombie;
-break;
-  case 'T':
-State = ProcessState::TracedOrStopped;
-break;
-  case 'W':
-State = ProcessState::Paging;
-break;
+  State = llvm::StringSwitch(Line.ltrim().take_front(1))
+  .Case("D", ProcessState::DiskSleep)
+  .Case("I", ProcessState::Idle)
+  .Case("R", ProcessState::Running)
+  .Case("S", ProcessState::Sleeping)
+  .CaseLower("T", ProcessState::TracedOrStopped)
+  .Case("W", ProcessState::Paging)
+  .Case("P", ProcessState::Parked)
+  .Case("X", ProcessState::Dead)
+  .Case("Z", ProcessState::Zombie)
+  .Default(ProcessState::Unknown);
+  if (State == ProcessState::Unknown) {
+LLDB_LOG(log, "Unknown process state {0}", Line);
   }
 } else if (Line.consume_front("TracerPid:")) {
   Line = Line.ltrim();


Index: lldb/source/Host/linux/Host.cpp
===
--- lldb/source/Host/linux/Host.cpp
+++ lldb/source/Host/linux/Host.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Object/ELF.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -35,8 +36,11 @@
 namespace {
 enum class ProcessState {
   Unknown,
+  Dead,
   DiskSleep,
+  Idle,
   Paging,
+  Parked,
   Running,
   Sleeping,
   TracedOrStopped,
@@ -50,12 +54,14 @@
 
 static bool GetStatusInfo(::pid_t Pid, ProcessInstanceInfo ,
   ProcessState , ::pid_t ) {
+  Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
   auto BufferOrError = getProcFile(Pid, "status");
   if (!BufferOrError)
 return false;
 
   llvm::StringRef Rest = BufferOrError.get()->getBuffer();
-  while(!Rest.empty()) {
+  while (!Rest.empty()) {
 llvm::StringRef Line;
 std::tie(Line, Rest) = Rest.split('\n');
 
@@ -84,26 +90,19 @@
   Line.ltrim().consumeInteger(10, PPid);
   ProcessInfo.SetParentProcessID(PPid);
 } else if (Line.consume_front("State:")) {
-  char S = Line.ltrim().front();
-  switch (S) {
-  case 'R':
-State = ProcessState::Running;
-break;
-  case 'S':
-State = ProcessState::Sleeping;
-break;
-  case 'D':
-State = ProcessState::DiskSleep;
-break;
-  case 'Z':
-State = ProcessState::Zombie;
-break;
-  case 'T':
-State = ProcessState::TracedOrStopped;
-break;
-  case 'W':
-State = 

[Lldb-commits] [PATCH] D86752: [lldb/test] Use shorter test case names in TestStandardUnwind

2020-08-27 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

TestStandardUnwind uses the full absolute path to a set of C/C++ files as the 
test case name, which in turn is used in the name of a log file. When the 
source file is long, and the directory where log files are stored is also long, 
this causes an OSError because the log filename is too long.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86752

Files:
  lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py


Index: lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
===
--- lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
+++ lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
@@ -164,7 +164,7 @@
 self.skipTest("Inferior not supported")
 self.standard_unwind_tests()
 
-test_name = "test_unwind_" + str(f)
+test_name = "test_unwind_" + str(os.path.basename(f))
 for c in ".=()/\\":
 test_name = test_name.replace(c, '_')
 


Index: lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
===
--- lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
+++ lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
@@ -164,7 +164,7 @@
 self.skipTest("Inferior not supported")
 self.standard_unwind_tests()
 
-test_name = "test_unwind_" + str(f)
+test_name = "test_unwind_" + str(os.path.basename(f))
 for c in ".=()/\\":
 test_name = test_name.replace(c, '_')
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86745: [lldb/test] Use @skipIfWindows for PExpectTest

2020-08-27 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: teemperor.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

Annotating `PExpectTest` with `@skipIfWindows` instead of marking it as an 
empty class will make the test runner recognize it as a test class, which 
should allow me to reland adb5c23f8c0d60eeec41dcbe21d1b26184e1c97d 
.

I don't have a windows machine to verify this works, but I did some tests using 
`@skipIfLinux` and they all worked as expected. In case the `pexpect` import is 
not at all available on windows, I moved it to within the method where it's 
used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86745

Files:
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py

Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -13,65 +13,60 @@
 from . import lldbutil
 from lldbsuite.test.decorators import *
 
-if sys.platform.startswith('win32'):
-# llvm.org/pr22274: need a pexpect replacement for windows
-class PExpectTest(object):
-pass
-else:
-import pexpect
+@skipIfRemote
+@skipIfWindows  # llvm.org/pr22274: need a pexpect replacement for windows
+class PExpectTest(TestBase):
 
-@skipIfRemote
-class PExpectTest(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+PROMPT = "(lldb) "
 
-NO_DEBUG_INFO_TESTCASE = True
-PROMPT = "(lldb) "
+def expect_prompt(self):
+self.child.expect_exact(self.PROMPT)
 
-def expect_prompt(self):
-self.child.expect_exact(self.PROMPT)
+def launch(self, executable=None, extra_args=None, timeout=30, dimensions=None):
+logfile = getattr(sys.stdout, 'buffer',
+sys.stdout) if self.TraceOn() else None
 
-def launch(self, executable=None, extra_args=None, timeout=30, dimensions=None):
-logfile = getattr(sys.stdout, 'buffer',
-  sys.stdout) if self.TraceOn() else None
+args = ['--no-lldbinit', '--no-use-colors']
+for cmd in self.setUpCommands():
+args += ['-O', cmd]
+if executable is not None:
+args += ['--file', executable]
+if extra_args is not None:
+args.extend(extra_args)
 
-args = ['--no-lldbinit', '--no-use-colors']
-for cmd in self.setUpCommands():
-args += ['-O', cmd]
-if executable is not None:
-args += ['--file', executable]
-if extra_args is not None:
-args.extend(extra_args)
+env = dict(os.environ)
+env["TERM"]="vt100"
 
-env = dict(os.environ)
-env["TERM"]="vt100"
-
-self.child = pexpect.spawn(
-lldbtest_config.lldbExec, args=args, logfile=logfile,
-timeout=timeout, dimensions=dimensions, env=env)
+import pexpect
+self.child = pexpect.spawn(
+lldbtest_config.lldbExec, args=args, logfile=logfile,
+timeout=timeout, dimensions=dimensions, env=env)
+self.expect_prompt()
+for cmd in self.setUpCommands():
+self.child.expect_exact(cmd)
 self.expect_prompt()
-for cmd in self.setUpCommands():
-self.child.expect_exact(cmd)
-self.expect_prompt()
-if executable is not None:
-self.child.expect_exact("target create")
-self.child.expect_exact("Current executable set to")
-self.expect_prompt()
-
-def expect(self, cmd, substrs=None):
-self.assertNotIn('\n', cmd)
-self.child.sendline(cmd)
-if substrs is not None:
-for s in substrs:
-self.child.expect_exact(s)
+if executable is not None:
+self.child.expect_exact("target create")
+self.child.expect_exact("Current executable set to")
 self.expect_prompt()
 
-def quit(self, gracefully=True):
-self.child.sendeof()
-self.child.close(force=not gracefully)
-self.child = None
+def expect(self, cmd, substrs=None):
+self.assertNotIn('\n', cmd)
+self.child.sendline(cmd)
+if substrs is not None:
+for s in substrs:
+self.child.expect_exact(s)
+self.expect_prompt()
+
+def quit(self, gracefully=True):
+self.child.sendeof()
+self.child.close(force=not gracefully)
+self.child = None
 
-def cursor_forward_escape_seq(self, chars_to_move):
-"""
-Returns the escape sequence to 

[Lldb-commits] [PATCH] D88513: [lldb-vscode] Allow an empty 'breakpoints' field to clear breakpoints.

2020-09-29 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: wallace, clayborg, labath.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.

Per the DAP spec for SetBreakpoints [1], the way to clear breakpoints is: `To 
clear all breakpoint for a source, specify an empty array.`

However, leaving the breakpoints field unset is also a well formed request 
(note the `breakpoints?:` in the `SetBreakpointsArguments` definition). If it's 
unset, we have a couple choices:

1. Crash (current behavior)
2. Clear breakpoints
3. Return an error response that the breakpoints field is missing.

I propose we do (2) instead of (1), and treat an unset breakpoints field the 
same as an empty breakpoints field.

[1] 
https://microsoft.github.io/debug-adapter-protocol/specification#Requests_SetBreakpoints


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88513

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1936,27 +1936,32 @@
 
   // Decode the source breakpoint infos for this "setBreakpoints" request
   SourceBreakpointMap request_bps;
-  for (const auto  : *breakpoints) {
-auto bp_obj = bp.getAsObject();
-if (bp_obj) {
-  SourceBreakpoint src_bp(*bp_obj);
-  request_bps[src_bp.line] = src_bp;
-
-  // We check if this breakpoint already exists to update it
-  auto existing_source_bps = g_vsc.source_breakpoints.find(path);
-  if (existing_source_bps != g_vsc.source_breakpoints.end()) {
-const auto _bp = existing_source_bps->second.find(src_bp.line);
-if (existing_bp != existing_source_bps->second.end()) {
-  existing_bp->second.UpdateBreakpoint(src_bp);
-  AppendBreakpoint(existing_bp->second.bp, response_breakpoints, path,
-   src_bp.line);
-  continue;
+  // "breakpoints" may be unset, in which case we treat it the same as being set
+  // to an empty array.
+  if (breakpoints) {
+for (const auto  : *breakpoints) {
+  auto bp_obj = bp.getAsObject();
+  if (bp_obj) {
+SourceBreakpoint src_bp(*bp_obj);
+request_bps[src_bp.line] = src_bp;
+
+// We check if this breakpoint already exists to update it
+auto existing_source_bps = g_vsc.source_breakpoints.find(path);
+if (existing_source_bps != g_vsc.source_breakpoints.end()) {
+  const auto _bp =
+  existing_source_bps->second.find(src_bp.line);
+  if (existing_bp != existing_source_bps->second.end()) {
+existing_bp->second.UpdateBreakpoint(src_bp);
+AppendBreakpoint(existing_bp->second.bp, response_breakpoints, path,
+ src_bp.line);
+continue;
+  }
 }
+// At this point the breakpoint is new
+src_bp.SetBreakpoint(path.data());
+AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
+g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
   }
-  // At this point the breakpoint is new
-  src_bp.SetBreakpoint(path.data());
-  AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
-  g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
 }
   }
 
Index: lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
===
--- lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
+++ lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
@@ -219,6 +219,47 @@
 self.assertTrue(breakpoint['verified'],
 "expect breakpoint still verified")
 
+@skipIfWindows
+@skipIfRemote
+def test_clear_breakpoints_unset_breakpoints(self):
+'''Test clearing breakpoints like test_set_and_clear, but clear
+   breakpoints by omitting the breakpoints array instead of sending an
+   empty one.'''
+lines = [line_number('main.cpp', 'break 12')]
+
+# Visual Studio Code Debug Adaptors have no way to specify the file
+# without launching or attaching to a process, so we must start a
+# process in order to be able to set breakpoints.
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+# Set one breakpoint and verify that it got set correctly.
+response = self.vscode.request_setBreakpoints(self.main_path, lines)
+line_to_id = {}
+breakpoints = response['body']['breakpoints']
+self.assertEquals(len(breakpoints), 

[Lldb-commits] [PATCH] D88051: [lldb/test] Clean up version checking.

2020-09-21 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: JDevlieghere, arsenm.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: wdng.

A few fixes while trying to figure out why tests are being skipped for arsenm:

- We check `$compiler -v`, but `-v` is `--verbose`, not `--version`. Use the 
long flag name.
- We check all lines matching `version ...`, but we should exit early for the 
first version string we see (which should be the main one). I'm not sure if 
this is the issue, but perhaps this is causing some users to skip some tests if 
another "version ..." is showing up later.
- Having `\.` in a python string is triggering pylint warnings, because it 
should be escaped as a regex string, e.g. `r'\.' However, `.` in a character 
class does not need to be escaped, as it matches only a literal `.` in that 
context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88051

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D88051: [lldb/test] Clean up version checking.

2020-09-21 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG307b7a1d6658: [lldb/test] Clean up version checking. 
(authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88051

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1364,15 +1364,13 @@
 """ Returns a string that represents the compiler version.
 Supports: llvm, clang.
 """
-version = 'unknown'
-
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])
+version_output = system([[compiler, "--version"]])
 for line in version_output.split(os.linesep):
-m = re.search('version ([0-9\.]+)', line)
+m = re.search('version ([0-9.]+)', line)
 if m:
-version = m.group(1)
-return version
+return m.group(1)
+return 'unknown'
 
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-23 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 293887.
rupprecht added a comment.

- Switch back to using localhost for non-socket uses


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Host/SocketTestUtilities.cpp

Index: lldb/unittests/Host/SocketTestUtilities.cpp
===
--- lldb/unittests/Host/SocketTestUtilities.cpp
+++ lldb/unittests/Host/SocketTestUtilities.cpp
@@ -101,13 +101,14 @@
  "Creating a canary {0} TCP socket failed: {1}.",
  Proto, Err)
  .str();
-  bool HasAddrNotAvail = false;
+  bool HasProtocolError = false;
   handleAllErrors(std::move(Err), [&](std::unique_ptr ECErr) {
-if (ECErr->convertToErrorCode() ==
-std::make_error_code(std::errc::address_not_available))
-  HasAddrNotAvail = true;
+std::error_code ec = ECErr->convertToErrorCode();
+if (ec == std::make_error_code(std::errc::address_family_not_supported) ||
+ec == std::make_error_code(std::errc::address_not_available))
+  HasProtocolError = true;
   });
-  if (HasAddrNotAvail) {
+  if (HasProtocolError) {
 GTEST_LOG_(WARNING)
 << llvm::formatv(
"Assuming the host does not support {0}. Skipping test.", Proto)
Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -14,12 +14,24 @@
 
 using namespace lldb_private;
 
-class SocketTest : public testing::Test {
+struct SocketTestParams {
+  bool is_ipv6;
+  std::string localhost_ip;
+};
+
+class SocketTest : public testing::TestWithParam {
 public:
   SubsystemRAII subsystems;
+
+protected:
+  bool HostSupportsProtocol() const {
+if (GetParam().is_ipv6)
+  return HostSupportsIPv6();
+return HostSupportsIPv4();
+  }
 };
 
-TEST_F(SocketTest, DecodeHostAndPort) {
+TEST_P(SocketTest, DecodeHostAndPort) {
   std::string host_str;
   std::string port_str;
   int32_t port;
@@ -86,7 +98,7 @@
 }
 
 #if LLDB_ENABLE_POSIX
-TEST_F(SocketTest, DomainListenConnectAccept) {
+TEST_P(SocketTest, DomainListenConnectAccept) {
   llvm::SmallString<64> Path;
   std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
   ASSERT_FALSE(EC);
@@ -102,18 +114,22 @@
 }
 #endif
 
-TEST_F(SocketTest, TCPListen0ConnectAccept) {
+TEST_P(SocketTest, TCPListen0ConnectAccept) {
+  if (!HostSupportsProtocol())
+return;
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 }
 
-TEST_F(SocketTest, TCPGetAddress) {
+TEST_P(SocketTest, TCPGetAddress) {
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  if (!HostSupportsIPv4())
+  if (!HostSupportsProtocol())
 return;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 
   EXPECT_EQ(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetRemotePortNumber());
@@ -121,11 +137,16 @@
 socket_a_up->GetRemotePortNumber());
   EXPECT_NE(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetLocalPortNumber());
-  EXPECT_STREQ("127.0.0.1", socket_a_up->GetRemoteIPAddress().c_str());
-  EXPECT_STREQ("127.0.0.1", socket_b_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_a_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_b_up->GetRemoteIPAddress().c_str());
 }
 
-TEST_F(SocketTest, UDPConnect) {
+TEST_P(SocketTest, UDPConnect) {
+  // UDPSocket::Connect() creates sockets with AF_INET (IPv4).
+  if (!HostSupportsIPv4())
+return;
   llvm::Expected> socket =
   UDPSocket::Connect("127.0.0.1:0", /*child_processes_inherit=*/false);
 
@@ -133,7 +154,9 @@
   EXPECT_TRUE(socket.get()->IsValid());
 }
 
-TEST_F(SocketTest, TCPListen0GetPort) {
+TEST_P(SocketTest, TCPListen0GetPort) {
+  if (!HostSupportsIPv4())
+return;
   Predicate port_predicate;
   port_predicate.SetValue(0, eBroadcastNever);
   llvm::Expected> sock =
@@ -143,12 +166,13 @@
   EXPECT_NE(sock.get()->GetLocalPortNumber(), 0);
 }
 
-TEST_F(SocketTest, TCPGetConnectURI) {
+TEST_P(SocketTest, TCPGetConnectURI) {
   std::unique_ptr 

[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-23 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D87333#2274572 , @rupprecht wrote:

> In D87333#2273506 , @labath wrote:
>
>> (Sorry about the delay.) Given the current requirements, I think this patch 
>> is fine (excellent even).
>>
>> That said, I'm not sure whether the original motivation for this requirement 
>> (avoiding dns lookups) is still relevant. These days, we communicate with 
>> the local debug server via `socketpair(2)` sockets (which wasn't the case 
>> back then), which does not require any dns lookups and is immune to a 
>> misconfigured hosts file.
>
> The initial dns lookup may still fail, I think? e.g. my initial version of 
> this patch had:
>
>   if (llvm::Error error =
>   listen_socket.Listen("localhost:0", backlog).ToError())
>
> If the hosts file has a bad value for localhost, that will create a bad 
> socket. That said, I don't know how to reproduce the original issue -- maybe 
> it isn't an issue for some other reason.
>
>> Given that none of the things touched by this patch is extremely critical 
>> (`GDBRemoteCommunication::ConnectLocally` is used for reproducers and the 
>> rest is test code), maybe we could use this to test the water and see 
>> whether we can start using the network stack the way it's supposed to be 
>> used ?
>
> Many non-reproducers tests fail w/o the change to 
> `GDBRemoteCommunication::ConnectLocally`, so it's at least used outside of 
> that.
>
> I can go either way with using `localhost` or using hard-coded localhost IPs. 
> Whichever way we go, I have a slight preference for keeping the tests and 
> code consistent, e.g. if we use hard-coded IPs in code linked into lldb to 
> allow people with a bad hosts file to use lldb, we should use hard-coded IPs 
> in the tests to allow those same users to develop on lldb.

Switched back to the original approach of using `localhost` when possible [1], 
though I still have the git branch so I can always switch back. I don't have a 
personal preference either way, but would like to land one of the two 
approaches as this creates a strange amount of test flakiness internally when 
we need to support ipv4.

[1] IIUC, when connecting via hostname, attempting "localhost" will try both 
AF_INET and AF_INET6, but there is no corresponding way to construct a raw 
socket with automatic fallback to AF_INET6 if AF_INET does not work, so that 
part is the same as before (try to create AF_INET and catch the error manually)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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


[Lldb-commits] [PATCH] D88513: [lldb-vscode] Allow an empty 'breakpoints' field to clear breakpoints.

2020-09-30 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
rupprecht marked an inline comment as done.
Closed by commit rGad865d9d10b8: [lldb-vscode] Allow an empty 
breakpoints field to clear breakpoints. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D88513?vs=295124=295364#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88513

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1936,27 +1936,32 @@
 
   // Decode the source breakpoint infos for this "setBreakpoints" request
   SourceBreakpointMap request_bps;
-  for (const auto  : *breakpoints) {
-auto bp_obj = bp.getAsObject();
-if (bp_obj) {
-  SourceBreakpoint src_bp(*bp_obj);
-  request_bps[src_bp.line] = src_bp;
-
-  // We check if this breakpoint already exists to update it
-  auto existing_source_bps = g_vsc.source_breakpoints.find(path);
-  if (existing_source_bps != g_vsc.source_breakpoints.end()) {
-const auto _bp = existing_source_bps->second.find(src_bp.line);
-if (existing_bp != existing_source_bps->second.end()) {
-  existing_bp->second.UpdateBreakpoint(src_bp);
-  AppendBreakpoint(existing_bp->second.bp, response_breakpoints, path,
-   src_bp.line);
-  continue;
+  // "breakpoints" may be unset, in which case we treat it the same as being set
+  // to an empty array.
+  if (breakpoints) {
+for (const auto  : *breakpoints) {
+  auto bp_obj = bp.getAsObject();
+  if (bp_obj) {
+SourceBreakpoint src_bp(*bp_obj);
+request_bps[src_bp.line] = src_bp;
+
+// We check if this breakpoint already exists to update it
+auto existing_source_bps = g_vsc.source_breakpoints.find(path);
+if (existing_source_bps != g_vsc.source_breakpoints.end()) {
+  const auto _bp =
+  existing_source_bps->second.find(src_bp.line);
+  if (existing_bp != existing_source_bps->second.end()) {
+existing_bp->second.UpdateBreakpoint(src_bp);
+AppendBreakpoint(existing_bp->second.bp, response_breakpoints, path,
+ src_bp.line);
+continue;
+  }
 }
+// At this point the breakpoint is new
+src_bp.SetBreakpoint(path.data());
+AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
+g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
   }
-  // At this point the breakpoint is new
-  src_bp.SetBreakpoint(path.data());
-  AppendBreakpoint(src_bp.bp, response_breakpoints, path, src_bp.line);
-  g_vsc.source_breakpoints[path][src_bp.line] = std::move(src_bp);
 }
   }
 
Index: lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
===
--- lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
+++ lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
@@ -219,6 +219,48 @@
 self.assertTrue(breakpoint['verified'],
 "expect breakpoint still verified")
 
+@skipIfWindows
+@skipIfRemote
+def test_clear_breakpoints_unset_breakpoints(self):
+'''Test clearing breakpoints like test_set_and_clear, but clear
+   breakpoints by omitting the breakpoints array instead of sending an
+   empty one.'''
+lines = [line_number('main.cpp', 'break 12'),
+ line_number('main.cpp', 'break 13')]
+
+# Visual Studio Code Debug Adaptors have no way to specify the file
+# without launching or attaching to a process, so we must start a
+# process in order to be able to set breakpoints.
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+# Set one breakpoint and verify that it got set correctly.
+response = self.vscode.request_setBreakpoints(self.main_path, lines)
+line_to_id = {}
+breakpoints = response['body']['breakpoints']
+self.assertEquals(len(breakpoints), len(lines),
+"expect %u source breakpoints" % (len(lines)))
+for (breakpoint, index) in zip(breakpoints, range(len(lines))):
+line = breakpoint['line']
+self.assertTrue(line, lines[index])
+# Store the "id" of the breakpoint that was set for later
+line_to_id[line] = breakpoint['id']
+

[Lldb-commits] [PATCH] D87333: [lldb/ipv6] Support running lldb tests in an ipv6-only environment.

2020-09-30 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3193e464cbd: [lldb/ipv6] Support running lldb tests in an 
ipv6-only environment. (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Host/SocketTestUtilities.cpp

Index: lldb/unittests/Host/SocketTestUtilities.cpp
===
--- lldb/unittests/Host/SocketTestUtilities.cpp
+++ lldb/unittests/Host/SocketTestUtilities.cpp
@@ -101,13 +101,14 @@
  "Creating a canary {0} TCP socket failed: {1}.",
  Proto, Err)
  .str();
-  bool HasAddrNotAvail = false;
+  bool HasProtocolError = false;
   handleAllErrors(std::move(Err), [&](std::unique_ptr ECErr) {
-if (ECErr->convertToErrorCode() ==
-std::make_error_code(std::errc::address_not_available))
-  HasAddrNotAvail = true;
+std::error_code ec = ECErr->convertToErrorCode();
+if (ec == std::make_error_code(std::errc::address_family_not_supported) ||
+ec == std::make_error_code(std::errc::address_not_available))
+  HasProtocolError = true;
   });
-  if (HasAddrNotAvail) {
+  if (HasProtocolError) {
 GTEST_LOG_(WARNING)
 << llvm::formatv(
"Assuming the host does not support {0}. Skipping test.", Proto)
Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -14,12 +14,24 @@
 
 using namespace lldb_private;
 
-class SocketTest : public testing::Test {
+struct SocketTestParams {
+  bool is_ipv6;
+  std::string localhost_ip;
+};
+
+class SocketTest : public testing::TestWithParam {
 public:
   SubsystemRAII subsystems;
+
+protected:
+  bool HostSupportsProtocol() const {
+if (GetParam().is_ipv6)
+  return HostSupportsIPv6();
+return HostSupportsIPv4();
+  }
 };
 
-TEST_F(SocketTest, DecodeHostAndPort) {
+TEST_P(SocketTest, DecodeHostAndPort) {
   std::string host_str;
   std::string port_str;
   int32_t port;
@@ -86,7 +98,7 @@
 }
 
 #if LLDB_ENABLE_POSIX
-TEST_F(SocketTest, DomainListenConnectAccept) {
+TEST_P(SocketTest, DomainListenConnectAccept) {
   llvm::SmallString<64> Path;
   std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
   ASSERT_FALSE(EC);
@@ -102,18 +114,22 @@
 }
 #endif
 
-TEST_F(SocketTest, TCPListen0ConnectAccept) {
+TEST_P(SocketTest, TCPListen0ConnectAccept) {
+  if (!HostSupportsProtocol())
+return;
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 }
 
-TEST_F(SocketTest, TCPGetAddress) {
+TEST_P(SocketTest, TCPGetAddress) {
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
-  if (!HostSupportsIPv4())
+  if (!HostSupportsProtocol())
 return;
-  CreateTCPConnectedSockets("127.0.0.1", _a_up, _b_up);
+  CreateTCPConnectedSockets(GetParam().localhost_ip, _a_up,
+_b_up);
 
   EXPECT_EQ(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetRemotePortNumber());
@@ -121,11 +137,16 @@
 socket_a_up->GetRemotePortNumber());
   EXPECT_NE(socket_a_up->GetLocalPortNumber(),
 socket_b_up->GetLocalPortNumber());
-  EXPECT_STREQ("127.0.0.1", socket_a_up->GetRemoteIPAddress().c_str());
-  EXPECT_STREQ("127.0.0.1", socket_b_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_a_up->GetRemoteIPAddress().c_str());
+  EXPECT_STREQ(GetParam().localhost_ip.c_str(),
+   socket_b_up->GetRemoteIPAddress().c_str());
 }
 
-TEST_F(SocketTest, UDPConnect) {
+TEST_P(SocketTest, UDPConnect) {
+  // UDPSocket::Connect() creates sockets with AF_INET (IPv4).
+  if (!HostSupportsIPv4())
+return;
   llvm::Expected> socket =
   UDPSocket::Connect("127.0.0.1:0", /*child_processes_inherit=*/false);
 
@@ -133,7 +154,9 @@
   EXPECT_TRUE(socket.get()->IsValid());
 }
 
-TEST_F(SocketTest, TCPListen0GetPort) {
+TEST_P(SocketTest, TCPListen0GetPort) {
+  if (!HostSupportsIPv4())
+return;
   Predicate port_predicate;
   port_predicate.SetValue(0, eBroadcastNever);
   llvm::Expected> sock =
@@ -143,12 +166,13 @@
   

[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest

2020-09-16 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd67581407c1: [lldb/test] Enable faulthandler in dotest 
(authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87637

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -449,6 +449,18 @@
 
 lldbtest_config.codesign_identity = args.codesign_identity
 
+def registerFaulthandler():
+try:
+import faulthandler
+except ImportError:
+# faulthandler is not available until python3
+return
+
+faulthandler.enable()
+# faulthandler.register is not available on Windows.
+if getattr(faulthandler, 'register', None):
+faulthandler.register(signal.SIGTERM, chain=True)
+
 def setupSysPath():
 """
 Add LLDB.framework/Resources/Python to the search paths for modules.
@@ -875,6 +887,9 @@
 #
 parseOptionsAndInitTestdirs()
 
+# Print a stack trace if the test hangs or is passed SIGTERM.
+registerFaulthandler()
+
 setupSysPath()
 
 import lldbconfig


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -449,6 +449,18 @@
 
 lldbtest_config.codesign_identity = args.codesign_identity
 
+def registerFaulthandler():
+try:
+import faulthandler
+except ImportError:
+# faulthandler is not available until python3
+return
+
+faulthandler.enable()
+# faulthandler.register is not available on Windows.
+if getattr(faulthandler, 'register', None):
+faulthandler.register(signal.SIGTERM, chain=True)
+
 def setupSysPath():
 """
 Add LLDB.framework/Resources/Python to the search paths for modules.
@@ -875,6 +887,9 @@
 #
 parseOptionsAndInitTestdirs()
 
+# Print a stack trace if the test hangs or is passed SIGTERM.
+registerFaulthandler()
+
 setupSysPath()
 
 import lldbconfig
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85169: [test] Exit with an error if no tests are run.

2020-08-03 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

If the test suite is misconfigured when it's run (a bad regexp, wrong test 
directory, etc.), the test suite may not discover any tests. When this happens, 
the test runner exits happily because no tests failed:

  Ran 0 tests in 0.000s
  RESULT: PASSED (0 passes, 0 failures, 0 errors, 0 skipped, 0 expected 
failures, 0 unexpected successes)

Change this to return an error so the misconfiguration can be more easily 
detected. Verified that `lldb-dotest -p TestDoesNotExist.py` successfully fails.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85169

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1039,6 +1039,10 @@
 (configuration.suite.countTestCases(),
  configuration.suite.countTestCases() != 1 and "s" or ""))
 
+if configuration.suite.countTestCases() == 0:
+print("error: did not discover any tests.")
+exitTestSuite(1)
+
 # Invoke the test runner.
 if configuration.count == 1:
 result = unittest2.TextTestRunner(


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1039,6 +1039,10 @@
 (configuration.suite.countTestCases(),
  configuration.suite.countTestCases() != 1 and "s" or ""))
 
+if configuration.suite.countTestCases() == 0:
+print("error: did not discover any tests.")
+exitTestSuite(1)
+
 # Invoke the test runner.
 if configuration.count == 1:
 result = unittest2.TextTestRunner(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85169: [test] Exit with an error if no tests are run.

2020-08-03 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGadb5c23f8c0d: [test] Exit with an error if no tests are run. 
(authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85169

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1039,6 +1039,10 @@
 (configuration.suite.countTestCases(),
  configuration.suite.countTestCases() != 1 and "s" or ""))
 
+if configuration.suite.countTestCases() == 0:
+logging.error("did not discover any matching tests")
+exitTestSuite(1)
+
 # Invoke the test runner.
 if configuration.count == 1:
 result = unittest2.TextTestRunner(


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1039,6 +1039,10 @@
 (configuration.suite.countTestCases(),
  configuration.suite.countTestCases() != 1 and "s" or ""))
 
+if configuration.suite.countTestCases() == 0:
+logging.error("did not discover any matching tests")
+exitTestSuite(1)
+
 # Invoke the test runner.
 if configuration.count == 1:
 result = unittest2.TextTestRunner(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85169: [test] Exit with an error if no tests are run.

2020-08-03 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 282759.
rupprecht added a comment.

- Use logging.error
- Remove trailing stop
- Edit message to indicate that matching tests weren't found (user error)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85169

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1039,6 +1039,10 @@
 (configuration.suite.countTestCases(),
  configuration.suite.countTestCases() != 1 and "s" or ""))
 
+if configuration.suite.countTestCases() == 0:
+logging.error("did not discover any matching tests")
+exitTestSuite(1)
+
 # Invoke the test runner.
 if configuration.count == 1:
 result = unittest2.TextTestRunner(


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1039,6 +1039,10 @@
 (configuration.suite.countTestCases(),
  configuration.suite.countTestCases() != 1 and "s" or ""))
 
+if configuration.suite.countTestCases() == 0:
+logging.error("did not discover any matching tests")
+exitTestSuite(1)
+
 # Invoke the test runner.
 if configuration.count == 1:
 result = unittest2.TextTestRunner(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85169: [test] Exit with an error if no tests are run.

2020-08-03 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

Thanks for the quick review!

I have a few more boring changes coming up, but hopefully some interesting ones 
after that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85169

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


[Lldb-commits] [PATCH] D85175: [test] Use abspath instead of realpath sometimes

2020-08-03 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

In these two cases, use of `os.path.realpath` is problematic:

- The name of the compiler is significant [1] . For testing purposes, we might 
provide a compiler called "clang" which is actually a symlink to some build 
script (which does some flag processing before invoking the real clang). The 
destination the symlink may not be called "clang", but we still want it to be 
treated as such.
- When using a build system that puts build artifacts in an arbitrary build 
location, and later creates a symlink for it (e.g. creates a "/lldbsuite/test/dotest.py" symlinks that points to 
"/build/artifact//dotest.py"), looking at the realpath will not match the 
"test" convention required here.

[1] See `Makefile.rules` in the lldb tree, e.g. we use different flags if the 
compiler is named "clang"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85175

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@
 do_help = True
 
 if args.compiler:
-configuration.compiler = os.path.realpath(args.compiler)
+configuration.compiler = os.path.abspath(args.compiler)
 if not is_exe(configuration.compiler):
 configuration.compiler = which(args.compiler)
 if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@
 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
 else:
-scriptPath = os.path.dirname(os.path.realpath(__file__))
+scriptPath = os.path.dirname(os.path.abspath(__file__))
 if not scriptPath.endswith('test'):
 print("This script expects to reside in lldb's test directory.")
 sys.exit(-1)


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@
 do_help = True
 
 if args.compiler:
-configuration.compiler = os.path.realpath(args.compiler)
+configuration.compiler = os.path.abspath(args.compiler)
 if not is_exe(configuration.compiler):
 configuration.compiler = which(args.compiler)
 if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@
 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
 else:
-scriptPath = os.path.dirname(os.path.realpath(__file__))
+scriptPath = os.path.dirname(os.path.abspath(__file__))
 if not scriptPath.endswith('test'):
 print("This script expects to reside in lldb's test directory.")
 sys.exit(-1)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85258: [test] Use realpath consistently for test root file paths.

2020-08-04 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

LLDB tests assume that tests are in the test tree (the `LLDB_TEST_SRC` env 
variable, configured by `dotest.py`).
If this assertion doesn't hold, tests fail in strange ways. An early place this 
goes wrong is in `compute_mydir` which does a simple length-based substring to 
get the relative path. Later, we use that path to chdir to. If the test file 
and test tree don't agree in realpath-ness (and therefore length), this will be 
a cryptic error of chdir-ing to a directory that does not exist.

The actual discrepency is that the places we look for `use_lldb_suite.py` don't 
use a realpath, but `dotest.py` does (see initialization of 
`configuration.testdirs`).

It doesn't particularly matter whether we use realpath or abspath to 
canonicalize things, but many places end up with implicit dependencies on the 
canonicalized pwd being a realpath, so make them realpath consistently. Also, 
in the `compute_mydir` method mentioned, raise an error if the path types don't 
agree.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85258

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/use_lldb_suite.py


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -4,9 +4,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(
-os.path.abspath(inspect.getfile(inspect.currentframe()))
-)
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
+if not test_file.startswith(lldb_test_src):
+  raise Exception(
+  "Test file '%s' must reside within LLDB_TEST_SRC "
+  "(which is '%s')." % (test_file, lldb_test_src))
+return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
 def TraceOn(self):
 """Returns True if we are in trace mode (tracing detailed test 
execution)."""
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -6,7 +6,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -4,9 +4,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(
-os.path.abspath(inspect.getfile(inspect.currentframe()))
-)
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
+if not test_file.startswith(lldb_test_src):
+  raise Exception(
+  "Test file '%s' must reside within LLDB_TEST_SRC "
+  "(which is '%s')." % (test_file, lldb_test_src))
+return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
 def TraceOn(self):
 """Returns True if we are in trace mode (tracing detailed test execution)."""
Index: 

[Lldb-commits] [PATCH] D85248: [test] Support git commit version ids for clang.

2020-08-04 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

`getCompilerVersion` assumes that `clang --version` prints out a string like 
`version [0-9\.]+`.
If clang is built from trunk, the version line might look like `clang version 
trunk (123abc)`.

Since there isn't any way of knowing by the commit id alone whether one commit 
is newer or older than another git commit (or clang version), assume that clang 
with a version id like this is very close to trunk. For example, any tests with 
`@skipIf(compiler="clang", compiler_version=['<', '8'])` should be run.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85248

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1322,25 +1322,35 @@
Use compiler_version[0] to specify the operator used to determine 
if a match has occurred.
Any operator other than the following defaults to an equality test:
  '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+   If the current compiler version cannot be determined, we assume it 
is close to the top
+   of trunk, so any less-than or equal-to comparisons will return 
False, and any
+   greater-than or not-equal-to comparisons will return True.
 """
-if (compiler_version is None):
+if compiler_version is None:
 return True
 operator = str(compiler_version[0])
 version = compiler_version[1]
 
-if (version is None):
+if version is None:
 return True
-if (operator == '>'):
-return LooseVersion(self.getCompilerVersion()) > 
LooseVersion(version)
-if (operator == '>=' or operator == '=>'):
-return LooseVersion(self.getCompilerVersion()) >= 
LooseVersion(version)
-if (operator == '<'):
-return LooseVersion(self.getCompilerVersion()) < 
LooseVersion(version)
-if (operator == '<=' or operator == '=<'):
-return LooseVersion(self.getCompilerVersion()) <= 
LooseVersion(version)
-if (operator == '!=' or operator == '!' or operator == 'not'):
-return str(version) not in str(self.getCompilerVersion())
-return str(version) in str(self.getCompilerVersion())
+
+test_compiler_version = self.getCompilerVersion()
+if test_compiler_version == 'unknown':
+# Assume the compiler version is at or near the top of trunk.
+return operator in ['>', '>=', '!', '!=', 'not']
+
+if operator == '>':
+return LooseVersion(test_compiler_version) > LooseVersion(version)
+if operator == '>=' or operator == '=>':
+return LooseVersion(test_compiler_version) >= LooseVersion(version)
+if operator == '<':
+return LooseVersion(test_compiler_version) < LooseVersion(version)
+if operator == '<=' or operator == '=<':
+return LooseVersion(test_compiler_version) <= LooseVersion(version)
+if operator == '!=' or operator == '!' or operator == 'not':
+return str(version) not in str(test_compiler_version)
+return str(version) in str(test_compiler_version)
 
 def expectedCompiler(self, compilers):
 """Returns True iff any element of compilers is a sub-string of the 
current compiler."""


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1322,25 +1322,35 @@
Use compiler_version[0] to specify the operator used to determine if a match has occurred.
Any operator other than the following defaults to an equality test:
  '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+   If the current compiler version cannot be determined, we assume it is close to the top
+   of trunk, so any less-than or equal-to comparisons will return False, and any
+   greater-than or not-equal-to comparisons will return True.
 """
-if (compiler_version is None):
+if compiler_version is None:
 return True
 operator = str(compiler_version[0])
 version = compiler_version[1]
 
-if (version is None):
+if version is None:
 return True
-if (operator == '>'):
-return LooseVersion(self.getCompilerVersion()) > LooseVersion(version)
-if (operator == '>=' or operator == '=>'):
-return LooseVersion(self.getCompilerVersion()) >= LooseVersion(version)
-if (operator == 

[Lldb-commits] [PATCH] D85175: [test] Use abspath instead of realpath sometimes

2020-08-04 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG817b3a6fe3a4: [test] Use abspath instead of realpath 
sometimes (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85175

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@
 do_help = True
 
 if args.compiler:
-configuration.compiler = os.path.realpath(args.compiler)
+configuration.compiler = os.path.abspath(args.compiler)
 if not is_exe(configuration.compiler):
 configuration.compiler = which(args.compiler)
 if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@
 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
 else:
-scriptPath = os.path.dirname(os.path.realpath(__file__))
+scriptPath = os.path.dirname(os.path.abspath(__file__))
 if not scriptPath.endswith('test'):
 print("This script expects to reside in lldb's test directory.")
 sys.exit(-1)


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@
 do_help = True
 
 if args.compiler:
-configuration.compiler = os.path.realpath(args.compiler)
+configuration.compiler = os.path.abspath(args.compiler)
 if not is_exe(configuration.compiler):
 configuration.compiler = which(args.compiler)
 if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@
 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
 else:
-scriptPath = os.path.dirname(os.path.realpath(__file__))
+scriptPath = os.path.dirname(os.path.abspath(__file__))
 if not scriptPath.endswith('test'):
 print("This script expects to reside in lldb's test directory.")
 sys.exit(-1)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85322: [lldb/test] Replace LLDB_TEST_SRC env variable with configuration

2020-08-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85322

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -62,12 +62,11 @@
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
-lldb_test_src = os.environ["LLDB_TEST_SRC"]
-if not (lldb_test and lldb_test_src and configuration.test_build_dir and 
test_subdir and
+if not (lldb_test and configuration.test_build_dir and test_subdir and
 test_name and (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
 build_dir = os.path.join(configuration.test_build_dir, test_subdir, 
test_name)
-src_dir = os.path.join(lldb_test_src, test_subdir)
+src_dir = os.path.join(configuration.test_src_root, test_subdir)
 # This is a bit of a hack to make inline testcases work.
 makefile = os.path.join(src_dir, "Makefile")
 if not os.path.isfile(makefile):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,7 +496,7 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
+rel_prefix = test_file[len(configuration.test_src_root) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -520,15 +520,11 @@
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST_SRC} is defined.
-# See also dotest.py which sets up ${LLDB_TEST_SRC}.
-if ("LLDB_TEST_SRC" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
-cls.mydir)
-if traceAlways:
-print("Change dir to:", full_dir, file=sys.stderr)
-os.chdir(full_dir)
-lldb.SBReproducer.SetWorkingDirectory(full_dir)
+full_dir = os.path.join(configuration.test_src_root, cls.mydir)
+if traceAlways:
+print("Change dir to:", full_dir, file=sys.stderr)
+os.chdir(full_dir)
+lldb.SBReproducer.SetWorkingDirectory(full_dir)
 
 # Set platform context.
 cls.platformContext = lldbplatformutil.createPlatformContext()
@@ -662,7 +658,7 @@
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
+return os.path.join(configuration.test_src_root, self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1095,7 +1091,7 @@
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST_SRC"],
+dname = os.path.join(configuration.test_src_root,
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -467,7 +467,6 @@
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
-os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 if not configuration.test_build_dir:
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -103,6 +103,10 @@
 # because it doesn't work under a debugger
 testdirs = [lldbsuite.lldb_test_root]
 
+# The root of the test case tree (where the actual tests reside, not the test
+# infrastructure).
+test_src_root = lldbsuite.lldb_test_root
+
 # Separator string.
 separator = '-' * 70
 


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ 

[Lldb-commits] [PATCH] D85322: [lldb/test] Replace LLDB_TEST_SRC env variable with configuration

2020-08-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf425c0442c3e: [lldb/test] Replace LLDB_TEST_SRC env variable 
with configuration (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85322

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -62,12 +62,11 @@
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
-lldb_test_src = os.environ["LLDB_TEST_SRC"]
-if not (lldb_test and lldb_test_src and configuration.test_build_dir and 
test_subdir and
+if not (lldb_test and configuration.test_build_dir and test_subdir and
 test_name and (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
 build_dir = os.path.join(configuration.test_build_dir, test_subdir, 
test_name)
-src_dir = os.path.join(lldb_test_src, test_subdir)
+src_dir = os.path.join(configuration.test_src_root, test_subdir)
 # This is a bit of a hack to make inline testcases work.
 makefile = os.path.join(src_dir, "Makefile")
 if not os.path.isfile(makefile):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,7 +496,7 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
+rel_prefix = test_file[len(configuration.test_src_root) + 1:]
 return os.path.dirname(rel_prefix)
 
 def TraceOn(self):
@@ -520,15 +520,11 @@
 # Save old working directory.
 cls.oldcwd = os.getcwd()
 
-# Change current working directory if ${LLDB_TEST_SRC} is defined.
-# See also dotest.py which sets up ${LLDB_TEST_SRC}.
-if ("LLDB_TEST_SRC" in os.environ):
-full_dir = os.path.join(os.environ["LLDB_TEST_SRC"],
-cls.mydir)
-if traceAlways:
-print("Change dir to:", full_dir, file=sys.stderr)
-os.chdir(full_dir)
-lldb.SBReproducer.SetWorkingDirectory(full_dir)
+full_dir = os.path.join(configuration.test_src_root, cls.mydir)
+if traceAlways:
+print("Change dir to:", full_dir, file=sys.stderr)
+os.chdir(full_dir)
+lldb.SBReproducer.SetWorkingDirectory(full_dir)
 
 # Set platform context.
 cls.platformContext = lldbplatformutil.createPlatformContext()
@@ -662,7 +658,7 @@
 
 def getSourceDir(self):
 """Return the full path to the current test."""
-return os.path.join(os.environ["LLDB_TEST_SRC"], self.mydir)
+return os.path.join(configuration.test_src_root, self.mydir)
 
 def getBuildDirBasename(self):
 return self.__class__.__module__ + "." + self.testMethodName
@@ -1098,7 +1094,7 @@
 
 /--..
 """
-dname = os.path.join(os.environ["LLDB_TEST_SRC"],
+dname = os.path.join(configuration.test_src_root,
  os.environ["LLDB_SESSION_DIRNAME"])
 if not os.path.isdir(dname):
 os.mkdir(dname)
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -467,7 +467,6 @@
 sys.exit(-1)
 
 os.environ["LLDB_TEST"] = scriptPath
-os.environ["LLDB_TEST_SRC"] = lldbsuite.lldb_test_root
 
 # Set up the root build directory.
 if not configuration.test_build_dir:
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -103,6 +103,10 @@
 # because it doesn't work under a debugger
 testdirs = [lldbsuite.lldb_test_root]
 
+# The root of the test case tree (where the actual tests reside, not the test
+# infrastructure).
+test_src_root = lldbsuite.lldb_test_root
+
 # Separator string.
 separator = '-' * 70
 


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- 

[Lldb-commits] [PATCH] D85258: [test] Use realpath consistently for test root file paths.

2020-08-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht marked an inline comment as done.
rupprecht added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:499
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(os.environ["LLDB_TEST_SRC"]) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = os.environ["LLDB_TEST_SRC"]
+if not test_file.startswith(lldb_test_src):

JDevlieghere wrote:
> While you are here... can you change this to pass the source directory trough 
> the `configuration`?
Absolutely, but in the spirit of small/isolated changes, split off as D85322.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85258

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


[Lldb-commits] [PATCH] D85258: [test] Use realpath consistently for test root file paths.

2020-08-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
rupprecht marked an inline comment as done.
Closed by commit rGfcb0d8163a4f: [lldb/test] Use realpath consistently for test 
root file paths. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D85258?vs=283060=283316#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85258

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/use_lldb_suite.py


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -4,9 +4,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(
-os.path.abspath(inspect.getfile(inspect.currentframe()))
-)
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(configuration.test_src_root) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = configuration.test_src_root
+if not test_file.startswith(lldb_test_src):
+  raise Exception(
+  "Test file '%s' must reside within lldb_test_src "
+  "(which is '%s')." % (test_file, lldb_test_src))
+return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
 def TraceOn(self):
 """Returns True if we are in trace mode (tracing detailed test 
execution)."""
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -6,7 +6,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -4,9 +4,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(
-os.path.abspath(inspect.getfile(inspect.currentframe()))
-)
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@
 mydir = TestBase.compute_mydir(__file__)
 '''
 # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-rel_prefix = test_file[len(configuration.test_src_root) + 1:]
-return os.path.dirname(rel_prefix)
+lldb_test_src = configuration.test_src_root
+if not test_file.startswith(lldb_test_src):
+  raise Exception(
+  "Test file '%s' must reside within lldb_test_src "
+  "(which is '%s')." % (test_file, lldb_test_src))
+return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
 def TraceOn(self):
 """Returns True if we are in trace mode (tracing detailed test execution)."""
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -6,7 +6,8 @@
 
 
 def find_lldb_root():
-lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+lldb_root = os.path.realpath(
+os.path.dirname(inspect.getfile(inspect.currentframe(
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85248: [test] Support git commit version ids for clang.

2020-08-05 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1dbac09dd6ec: [lldb/test] Support git commit version ids for 
clang. (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85248

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1325,25 +1325,35 @@
Use compiler_version[0] to specify the operator used to determine 
if a match has occurred.
Any operator other than the following defaults to an equality test:
  '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+   If the current compiler version cannot be determined, we assume it 
is close to the top
+   of trunk, so any less-than or equal-to comparisons will return 
False, and any
+   greater-than or not-equal-to comparisons will return True.
 """
-if (compiler_version is None):
+if compiler_version is None:
 return True
 operator = str(compiler_version[0])
 version = compiler_version[1]
 
-if (version is None):
+if version is None:
 return True
-if (operator == '>'):
-return LooseVersion(self.getCompilerVersion()) > 
LooseVersion(version)
-if (operator == '>=' or operator == '=>'):
-return LooseVersion(self.getCompilerVersion()) >= 
LooseVersion(version)
-if (operator == '<'):
-return LooseVersion(self.getCompilerVersion()) < 
LooseVersion(version)
-if (operator == '<=' or operator == '=<'):
-return LooseVersion(self.getCompilerVersion()) <= 
LooseVersion(version)
-if (operator == '!=' or operator == '!' or operator == 'not'):
-return str(version) not in str(self.getCompilerVersion())
-return str(version) in str(self.getCompilerVersion())
+
+test_compiler_version = self.getCompilerVersion()
+if test_compiler_version == 'unknown':
+# Assume the compiler version is at or near the top of trunk.
+return operator in ['>', '>=', '!', '!=', 'not']
+
+if operator == '>':
+return LooseVersion(test_compiler_version) > LooseVersion(version)
+if operator == '>=' or operator == '=>':
+return LooseVersion(test_compiler_version) >= LooseVersion(version)
+if operator == '<':
+return LooseVersion(test_compiler_version) < LooseVersion(version)
+if operator == '<=' or operator == '=<':
+return LooseVersion(test_compiler_version) <= LooseVersion(version)
+if operator == '!=' or operator == '!' or operator == 'not':
+return str(version) not in str(test_compiler_version)
+return str(version) in str(test_compiler_version)
 
 def expectedCompiler(self, compilers):
 """Returns True iff any element of compilers is a sub-string of the 
current compiler."""


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1325,25 +1325,35 @@
Use compiler_version[0] to specify the operator used to determine if a match has occurred.
Any operator other than the following defaults to an equality test:
  '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+   If the current compiler version cannot be determined, we assume it is close to the top
+   of trunk, so any less-than or equal-to comparisons will return False, and any
+   greater-than or not-equal-to comparisons will return True.
 """
-if (compiler_version is None):
+if compiler_version is None:
 return True
 operator = str(compiler_version[0])
 version = compiler_version[1]
 
-if (version is None):
+if version is None:
 return True
-if (operator == '>'):
-return LooseVersion(self.getCompilerVersion()) > LooseVersion(version)
-if (operator == '>=' or operator == '=>'):
-return LooseVersion(self.getCompilerVersion()) >= LooseVersion(version)
-if (operator == '<'):
-return LooseVersion(self.getCompilerVersion()) < LooseVersion(version)
-if (operator == '<=' or operator == '=<'):
-return LooseVersion(self.getCompilerVersion()) <= LooseVersion(version)
-if (operator == '!=' or operator == '!' or operator == 'not'):
-return str(version) not in str(self.getCompilerVersion())
-return str(version) in str(self.getCompilerVersion())
+
+

[Lldb-commits] [PATCH] D83840: [lldb][test] Prevent infinite loop while looking for use_lldb_suite_root.py.

2020-07-14 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: labath, JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

use_lldb_suite.py looks for use_lldb_suite_root.py by checking parent 
directories. If for some reason it doesn't exist, it keeps checking parent 
directories until it finds it.

However, this only breaks when the parent directory is None, but at least on 
Linux, dirname('/') == '/', so this will never be None.

This changes the lookup to stop if the dirname(lldb_root) is unchanged. It 
still stops if dirname returns None on some systems.

Additionally, this makes the failure mode more visible -- if the root is not 
found, it complains loudly instead of silently failing, having later modules 
that need lldb_root fail.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83840

Files:
  lldb/test/API/use_lldb_suite.py


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -7,22 +7,25 @@
 lldb_root = os.path.dirname(
 os.path.abspath(inspect.getfile(inspect.currentframe()))
 )
+# On Linux, dirname('/') == '/', so we keep looking in parent directories
+# until the parent directory doesn't change.
+prev_lldb_root = None
 while True:
+prev_lldb_root = lldb_root
 lldb_root = os.path.dirname(lldb_root)
-if lldb_root is None:
-return None
+if lldb_root is None or lldb_root == prev_lldb_root:
+raise Exception("use_lldb_suite_root.py not found")
 
 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
 if os.path.isfile(test_path):
 return lldb_root
-return None
 
 lldb_root = find_lldb_root()
-if lldb_root is not None:
-import imp
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+
+import imp
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -7,22 +7,25 @@
 lldb_root = os.path.dirname(
 os.path.abspath(inspect.getfile(inspect.currentframe()))
 )
+# On Linux, dirname('/') == '/', so we keep looking in parent directories
+# until the parent directory doesn't change.
+prev_lldb_root = None
 while True:
+prev_lldb_root = lldb_root
 lldb_root = os.path.dirname(lldb_root)
-if lldb_root is None:
-return None
+if lldb_root is None or lldb_root == prev_lldb_root:
+raise Exception("use_lldb_suite_root.py not found")
 
 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
 if os.path.isfile(test_path):
 return lldb_root
-return None
 
 lldb_root = find_lldb_root()
-if lldb_root is not None:
-import imp
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+
+import imp
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D83840: [lldb][test] Prevent infinite loop while looking for use_lldb_suite_root.py.

2020-07-15 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D83840#2152706 , @labath wrote:

> Heh I fixed the same thing back in 67f6d842fab6 for 
> `scripts/use_lldb_suite.py`, but of course I forgot to update this copy... 
> The idea is good, just please make sure both files end up using the same 
> solution.


Oh, and there's another one -- `lldb/packages/Python/lldbsuite/__init__.py`. 
I'll update it too.

> (Also, if you have any ideas on how to avoid having multiple copies of this 
> file around, then don't keep them to yourself. :) )

Not at the moment, but I have a feeling I'll be staring at these files long 
enough to come up with something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83840



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


[Lldb-commits] [PATCH] D83840: [lldb][test] Prevent infinite loop while looking for use_lldb_suite_root.py.

2020-07-15 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf3f100fcbf9: [lldb][test] Prevent infinite loop while 
looking for use_lldb_suite_root.py. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D83840?vs=278042=278219#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83840

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/scripts/use_lldb_suite.py
  lldb/test/API/use_lldb_suite.py


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -8,21 +8,21 @@
 os.path.abspath(inspect.getfile(inspect.currentframe()))
 )
 while True:
-lldb_root = os.path.dirname(lldb_root)
-if lldb_root is None:
-return None
+parent = os.path.dirname(lldb_root)
+if parent == lldb_root: # dirname('/') == '/'
+raise Exception("use_lldb_suite_root.py not found")
+lldb_root = parent
 
 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
 if os.path.isfile(test_path):
 return lldb_root
-return None
 
 lldb_root = find_lldb_root()
-if lldb_root is not None:
-import imp
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+
+import imp
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()
Index: lldb/scripts/use_lldb_suite.py
===
--- lldb/scripts/use_lldb_suite.py
+++ lldb/scripts/use_lldb_suite.py
@@ -8,20 +8,18 @@
 while True:
 parent = os.path.dirname(lldb_root)
 if parent == lldb_root: # dirname('/') == '/'
-break
+raise Exception("use_lldb_suite_root.py not found")
 lldb_root = parent
 
 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
 if os.path.isfile(test_path):
 return lldb_root
-return None
 
 lldb_root = find_lldb_root()
-if lldb_root is not None:
-import imp
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+import imp
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()
Index: lldb/packages/Python/lldbsuite/__init__.py
===
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -8,14 +8,14 @@
 def find_lldb_root():
 lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
 while True:
-lldb_root = os.path.dirname(lldb_root)
-if lldb_root is None:
-return None
+parent = os.path.dirname(lldb_root)
+if parent == lldb_root: # dirname('/') == '/'
+raise Exception("use_lldb_suite_root.py not found")
+lldb_root = parent
 
 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
 if os.path.isfile(test_path):
 return lldb_root
-return None
 
 # lldbsuite.lldb_root refers to the root of the git/svn source checkout
 lldb_root = find_lldb_root()


Index: lldb/test/API/use_lldb_suite.py
===
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -8,21 +8,21 @@
 os.path.abspath(inspect.getfile(inspect.currentframe()))
 )
 while True:
-lldb_root = os.path.dirname(lldb_root)
-if lldb_root is None:
-return None
+parent = os.path.dirname(lldb_root)
+if parent == lldb_root: # dirname('/') == '/'
+raise Exception("use_lldb_suite_root.py not found")
+lldb_root = parent
 
 test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
 if os.path.isfile(test_path):
 return lldb_root
-return None
 
 lldb_root = find_lldb_root()
-if lldb_root is not None:
-import imp
-fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
-try:
-imp.load_module("use_lldb_suite_root", fp, pathname, desc)
-finally:
-if fp:
-fp.close()
+
+import imp
+fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
+try:
+imp.load_module("use_lldb_suite_root", fp, pathname, desc)
+finally:
+if fp:
+fp.close()
Index: 

[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest

2020-11-13 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

Thanks, I'll take a look at that.

For SIGTERM (issued by test runners to handle timeouts), the stack trace is 
printed via `faulthandler.register(signal.SIGTERM, chain=True)`. The 
`chain=True` //should// cause previous signal handlers registered for SIGTERM 
to execute.

For all other signal types, this is enabled with `faulthandler.enable()`, and 
there doesn't appear to be any equivalent option AFAICT, so it's plausible that 
it's overwriting the signal handler. Maybe we could replace that with calls to 
`faulthandler.register()` for each signal, but hopefully there's a cleaner way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87637

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


[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest

2020-11-13 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

At head:

  $ ninja check-lldb-api-commands-apropos-basic
  [2/3] Running lit suite 
/home/rupprecht/src/llvm-project/lldb/test/API/commands/apropos/basic
  FAIL: lldb-api :: commands/apropos/basic/TestApropos.py (1 of 1)
   TEST 'lldb-api :: commands/apropos/basic/TestApropos.py' 
FAILED 
  Script:
  --
  /usr/bin/python3.8 /home/rupprecht/src/llvm-project/lldb/test/API/dotest.py 
<...> -p TestApropos.py
  --
  Exit Code: -6
  
  Command Output (stdout):
  --
  lldb version 12.0.0 (https://github.com/llvm/llvm-project.git revision 
703ef17e7a0a0f51e1d000bb1f71ad437a9933e4)
clang revision 703ef17e7a0a0f51e1d000bb1f71ad437a9933e4
llvm revision 703ef17e7a0a0f51e1d000bb1f71ad437a9933e4
  
  --
  Command Output (stderr):
  --
  Fatal Python error: Aborted
  
  Current thread 0x7f1541aea740 (most recent call first):
File 
"/home/rupprecht/src/llvm-build/dev/lib/python2.7/dist-packages/lldb/__init__.py",
 line 3352 in HandleCommand
File 
"/home/rupprecht/src/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2129 in runCmd
File 
"/home/rupprecht/src/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1949 in setUp
File 
"/home/rupprecht/src/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
 line 377 in run
File 
"/home/rupprecht/src/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
 line 458 in __call__
File 
"/home/rupprecht/src/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
 line 117 in _wrapped_run
File 
"/home/rupprecht/src/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
 line 115 in _wrapped_run
File 
"/home/rupprecht/src/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
 line 85 in run
File 
"/home/rupprecht/src/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
 line 66 in __call__
File 
"/home/rupprecht/src/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/runner.py",
 line 165 in run
File 
"/home/rupprecht/src/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py",
 line 1013 in run_suite
File "/home/rupprecht/src/llvm-project/lldb/test/API/dotest.py", line 7 in 

  
  --
  
  
  
  Failed Tests (1):
lldb-api :: commands/apropos/basic/TestApropos.py

With `registerFaulthandler()` commented out:

  $ ninja check-lldb-api-commands-apropos-basic
  [2/3] Running lit suite 
/home/rupprecht/src/llvm-project/lldb/test/API/commands/apropos/basic
  FAIL: lldb-api :: commands/apropos/basic/TestApropos.py (1 of 1)
   TEST 'lldb-api :: commands/apropos/basic/TestApropos.py' 
FAILED 
  Script:
  --
  /usr/bin/python3.8 /home/rupprecht/src/llvm-project/lldb/test/API/dotest.py 
<...> -p TestApropos.py
  --
  Exit Code: -6
  
  Command Output (stdout):
  --
  lldb version 12.0.0 (https://github.com/llvm/llvm-project.git revision 
703ef17e7a0a0f51e1d000bb1f71ad437a9933e4)
clang revision 703ef17e7a0a0f51e1d000bb1f71ad437a9933e4
llvm revision 703ef17e7a0a0f51e1d000bb1f71ad437a9933e4
  
  --
  
  
  
  Failed Tests (1):
lldb-api :: commands/apropos/basic/TestApropos.py

So, it doesn't seem like the LLVM signal handler is being enabled, at least not 
by default -- maybe it has something to do with my cmake config.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87637

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


[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest

2020-11-13 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

My cmake config appears to be correct. I tried adding this to 
`CommandInterpreter::HandleCommand`:

  lldbassert(ENABLE_BACKTRACES && "back traces are not enabled!");
  lldbassert(false && "crash!");

Running LLDB directly does what you describe:

  $ bin/lldb
  (lldb) help
  lldb: 
/home/rupprecht/src/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1655:
 bool lldb_private::CommandInterpreter::HandleCommand(const char *, 
lldb_private::LazyBool, lldb_private::CommandReturnObject &, 
lldb_private::ExecutionContext *, bool, bool): Assertion `false && "crash!"' 
failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
  Stack dump:
  0.  Program arguments: bin/lldb 
   #0 0x003a283a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:11
   #1 0x003a2a0b PrintStackTraceSignalHandler(void*) 
/home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:630:1
   #2 0x003a102b llvm::sys::RunSignalHandlers() 
/home/rupprecht/src/llvm-project/llvm/lib/Support/Signals.cpp:70:5

However, when I disable the faulthandler added here and run the lldb tests, I 
only see the "Assertion `false && "crash!"' failed" part. So: yes, something in 
the lldb test suite is messing with the signal handler, but it's not this (or 
it's not *only* this).
I recall running across other signal handling code in the lldb test framework 
(in the unittest2 bits), I'll see if I can find that again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87637

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


[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest

2020-11-13 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D87637#2395246 , @teemperor wrote:

> I'm late to the party, but I actually don't think this is a good change as it 
> disables the normal LLDB backtraces. The current test errors we see on Green 
> Dragon look now like this:
>
>   Assertion failed: (size() >= N && "Dropping more elements than exist"), 
> function drop_front, file 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/ADT/StringRef.h,
>  line 655.
>   Fatal Python error: Aborted
>   
>   Current thread 0x00010e0f9dc0 (most recent call first):
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lib/python3.7/site-packages/lldb/__init__.py",
>  line 2717 in HandleCommand
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
>  line 2129 in runCmd
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py",
>  line 43 in test_apropos_with_process
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
>  line 413 in runMethod
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
>  line 383 in run
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/case.py",
>  line 458 in __call__
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
>  line 117 in _wrapped_run
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
>  line 115 in _wrapped_run
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
>  line 85 in run
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/suite.py",
>  line 66 in __call__
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/third_party/Python/module/unittest2/unittest2/runner.py",
>  line 165 in run
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py",
>  line 1017 in run_suite
> File 
> "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/dotest.py",
>  line 7 in 
>
> It's practically impossible to say from the backtrace which commit is to 
> blame for the crash as I only know we run the command `apropos env` and then 
> we crash in StringRef.
>
> Do we have a way of getting both the LLVM and the Python backtrace?

I'm not really sure what you mean by the LLDB backtrace or how this is 
inhibiting it.

IIUC, the faulthandler here is triggered when the test *receives* a signal 
killing it (e.g. if it hangs and lit or whatever kills it after some timeout). 
If the LLDB process that this calls crashes, it shouldn't affect that. SWIG 
maybe is complicating things here.

Do you have a way to reproduce the issue you're talking about? e.g. "git 
checkout  && ninja check-lldb-api"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87637

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


[Lldb-commits] [PATCH] D91835: [lldb] Add Python bindings to print stack traces on crashes.

2020-11-19 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

I ran manual tests for this, but I did so by introducing an intentional crash 
in a place that obviously can't be checked in. Does LLDB have any kind of 
intentional-crash-for-test mechanism that could be used for a test?

Also, I picked `SBDebugger` for this as it seems like a very global option, but 
I'm happy to put it somewhere else. Not sure where though?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91835

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


[Lldb-commits] [PATCH] D91835: [lldb] Add Python bindings to print stack traces on crashes.

2020-11-19 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added reviewers: teemperor, JDevlieghere, labath, vsk.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.

As noticed in D87637 , when LLDB crashes, we 
only print stack traces if LLDB is directly executed, not when used via Python 
bindings. Enabling this by default may be undesirable (libraries shouldn't be 
messing with signal handlers), so make this an explicit opt-in.

When adding an `abort()` to `CommandInterpreter::HandleCommand()`, this prints:

  $ ninja check-lldb-api-commands-apropos-basic
  FAIL: lldb-api :: commands/apropos/basic/TestApropos.py (1 of 1)
   TEST 'lldb-api :: commands/apropos/basic/TestApropos.py' 
FAILED 
  ...
  Command Output (stderr):
  --
  python3.8: 
/home/rupprecht/src/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1655:
 bool lldb_private::CommandInterpreter::HandleCommand(const char *, 
lldb_private::LazyBool, lldb_private::CommandReturnObject &, 
lldb_private::ExecutionContext *, bool, bool): Assertion `false && "crash!"' 
failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
  Stack dump:
  0.  HandleCommand(command = "settings clear -all")
   #0 0x7f1e9a0ff4ea llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:11
   #1 0x7f1e9a0ff6bb PrintStackTraceSignalHandler(void*) 
/home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:630:1
   #2 0x7f1e9a0fdcdb llvm::sys::RunSignalHandlers() 
/home/rupprecht/src/llvm-project/llvm/lib/Support/Signals.cpp:70:5
   #3 0x7f1e9a0ffded SignalHandler(int) 
/home/rupprecht/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:405:1
  ...
   #9 0x7f1e997e6228 
/home/rupprecht/src/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1655:3


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91835

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


Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -56,6 +56,8 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -166,6 +168,14 @@
   return LLDB_RECORD_RESULT(error);
 }
 
+void SBDebugger::PrintStackTraceOnError() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, PrintStackTraceOnError);
+  llvm::EnablePrettyStackTrace();
+  // We don't have a meaningful argv[0] to use, so use "SBDebugger" as a
+  // substitute.
+  llvm::sys::PrintStackTraceOnErrorSignal("SBDebugger");
+}
+
 void SBDebugger::Terminate() {
   LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Terminate);
 
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -880,6 +880,9 @@
 lldbconfig.INITIALIZE = False
 import lldb
 
+# Print stack traces from coming from inside lldb.
+lldb.SBDebugger.PrintStackTraceOnError()
+
 if configuration.capture_path:
 lldb.SBReproducer.Capture(configuration.capture_path)
 lldb.SBReproducer.SetAutoGenerate(True)
Index: lldb/include/lldb/API/SBDebugger.h
===
--- lldb/include/lldb/API/SBDebugger.h
+++ lldb/include/lldb/API/SBDebugger.h
@@ -47,6 +47,8 @@
 
   static lldb::SBError InitializeWithErrorHandling();
 
+  static void PrintStackTraceOnError();
+
   static void Terminate();
 
   // Deprecated, use the one that takes a source_init_files bool.
Index: lldb/bindings/interface/SBDebugger.i
===
--- lldb/bindings/interface/SBDebugger.i
+++ lldb/bindings/interface/SBDebugger.i
@@ -124,6 +124,8 @@
 static SBError
 InitializeWithErrorHandling();
 
+static void PrintStackTraceOnError();
+
 static void
 Terminate();
 


Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -56,6 +56,8 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -166,6 +168,14 @@
   return LLDB_RECORD_RESULT(error);
 }
 
+void 

[Lldb-commits] [PATCH] D87637: [lldb/test] Enable faulthandler in dotest

2020-11-16 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D87637#2395603 , @teemperor wrote:

> Yeah I don't think this revision is to blame as just disabling the code here 
> doesn't bring back the backtraces. Doesn't explain what happened to them, but 
> that's probably on me to figure out. Really sorry for the noise, closing this 
> again.

No worries, this is an entirely reasonable change to suspect.

Not sure if you saw, but further on down there is also:

  # Install the control-c handler.
  unittest2.signals.installHandler()

However, removing that in addition to this still does not seem to get the C++ 
backtraces working. I'm guessing there's a call to `EnablePrettyStackTrace` 
that used to be happening and was accidentally removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87637

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


[Lldb-commits] [PATCH] D94888: [lldb] Add -Wl, -rpath to make tests run with fresh built libc++

2021-01-20 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D94888#2506140 , @labath wrote:

> In D94888#2506000 , @MaskRay wrote:
>
>> In D94888#2505992 , @labath wrote:
>>
>>> It looks like this is removing the ability to build libc++ tests with gcc 
>>> (as it does not have the `-stdlib` option). While having that ability would 
>>> be nice, I don't believe there's anyone currently using that configuration, 
>>> so it shouldn't stand in the way of other things. But we should also update 
>>> the python detection code then (in `canRunLibcxxTests` in 
>>> `packages/Python/lldbsuite/test/dotest.py` -- I guess you just need to 
>>> remove the `if os.path.isdir("/usr/include/c++/v1"):` blurb)
>>>
>>> As for testing against the system libc++ with clang, I guess that should 
>>> still work, as the extra rpath will be just ignored in that case...
>>
>> I do not know whether the following few lines D9426 
>>  were intentional.
>
> I am pretty sure they were. This flag is needed to use (system) libc++ with 
> gcc, and this was happening at a time when we were running the test suite 
> with gcc, as it was still the default compiler for android.

Is anyone running tests in this build mode (gcc + libc++) still? Should we keep 
this support around?




Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:765-770
 cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", 
f.name, "-"]
 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
 _, stderr = p.communicate("#include \nint main() {}")
 if not p.returncode:
 return True, "Compiling with -stdlib=libc++ works"
 return False, "Compiling with -stdlib=libc++ fails with the error: 
%s" % stderr

I don't know if this is the right place to do it, but it would be good to also 
check somewhere that binaries built w/ libc++ actually run. That would help 
with the error you were seeing. Maybe something like this would work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94888

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


[Lldb-commits] [PATCH] D102993: [lldb] Disable minimal import mode for RecordDecls that back FieldDecls

2021-06-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

This commit seems to be causing an LLDB crash. I'm still working on gathering 
info and reducing it, but maybe the crash reason is obvious to you given this 
stack trace:

  $ lldb -b -o "b ChromeMain" -o "r" -o "v" -o "p chrome_main_delegate" 
~/src/chromium/src/out/Default/chrome
  assert.h assertion failed at llvm-project/clang/lib/AST/ASTImporter.cpp:1874 
in llvm::Error clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext *, 
bool): ToDC == ToD->getLexicalDeclContext() && ToDC->containsDecl(ToD)
  ...
  Stack dump:
  0.  Program arguments: lldb -b -o "b ChromeMain" -o r -o v -o "p 
chrome_main_delegate" /home/rupprecht/src/chromium/src/out/Default/chrome
  1.  HandleCommand(command = "p chrome_main_delegate")^@
  2.  :45:51: current parser token ';'
  3.  :44:1: parsing function body '$__lldb_expr'
  4.  :44:1: in compound statement ('{}')
  ...
   #13 0x55646a128c66 
clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) 
llvm-project/clang/lib/AST/ASTImporter.cpp:1874:9
   #14 0x55646a15cc0d clang::ASTImporter::ImportDefinition(clang::Decl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:9098:19
   #15 0x55646789e47d 
lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(clang::Decl*) 
llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp:916:25
   #16 0x55646a157235 clang::ASTImporter::Import(clang::Decl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8412:8
   #17 0x55646789ac8a 
lldb_private::ClangASTImporter::CopyDecl(clang::ASTContext*, clang::Decl*) 
llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp:79:8
   #18 0x5564679c4205 lldb_private::ClangASTSource::CopyDecl(clang::Decl*) 
llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:1720:3
   #19 0x5564679c415e 
lldb_private::ClangASTSource::FindExternalLexicalDecls(clang::DeclContext 
const*, llvm::function_ref, 
llvm::SmallVectorImpl&) 
llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:492:5
   #20 0x5564679a6b6a 
lldb_private::ClangASTSource::ClangASTSourceProxy::FindExternalLexicalDecls(clang::DeclContext
 const*, llvm::function_ref, 
llvm::SmallVectorImpl&) 
llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h:223:7
   #21 0x55646a30d9b2 
clang::ExternalASTSource::FindExternalLexicalDecls(clang::DeclContext const*, 
llvm::SmallVectorImpl&) 
llvm-project/clang/include/clang/AST/ExternalASTSource.h:186:3
   #22 0x55646a30ae60 
clang::DeclContext::LoadLexicalDeclsFromExternalStorage() const 
llvm-project/clang/lib/AST/DeclBase.cpp:1353:7
   #23 0x55646a30bec2 clang::DeclContext::buildLookup() 
llvm-project/clang/lib/AST/DeclBase.cpp:1582:32
   #24 0x55646a30bc4f 
clang::DeclContext::makeDeclVisibleInContextWithFlags(clang::NamedDecl*, bool, 
bool) llvm-project/clang/lib/AST/DeclBase.cpp:1859:5
   #25 0x55646a30bd99 clang::DeclContext::addDeclInternal(clang::Decl*) 
llvm-project/clang/lib/AST/DeclBase.cpp:1559:1
   #26 0x55646a12c1f0 
clang::ASTNodeImporter::VisitTypedefNameDecl(clang::TypedefNameDecl*, bool) 
llvm-project/clang/lib/AST/ASTImporter.cpp:0:16
   #27 0x55646a12c4cd 
clang::ASTNodeImporter::VisitTypedefDecl(clang::TypedefDecl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:2552:10
   #28 0x55646a171e3a clang::declvisitor::Base >::Visit(clang::Decl*) 
llvm-project/clang/include/clang/AST/DeclNodes.inc:335:1
   #29 0x55646a15619d clang::ASTImporter::ImportImpl(clang::Decl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8240:19
   #30 0x55646789e55c 
lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(clang::Decl*) 
llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp:0:23
   #31 0x55646a157235 clang::ASTImporter::Import(clang::Decl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8412:8

The class definition for the expression being evaluated can be found here: 
https://source.chromium.org/chromium/chromium/src/+/master:chrome/app/chrome_main.cc;l=85;drc=83bf8a5bbe7f9af4f4531b65662cfeb0c232b583

(It crashes in the same-ish w/o assertions too; this is just the more helpful 
stack trace :) )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102993

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


[Lldb-commits] [PATCH] D102993: [lldb] Disable minimal import mode for RecordDecls that back FieldDecls

2021-06-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D102993#2811337 , @teemperor wrote:

> Sure I can take a look, but I don't see the immediate problem when looking at 
> the backtrace.
>
> I assume it takes some time to reduce the bug in Chrome? If you could get me 
> the `dump()` output for the Decls `D`, `(Decl*)ToDC`, `FromRD`, `ToD`, 
> `(Decl*)ToD->getLexicalDeclContext()` and whether the left or the right side 
> of the `&&` is true/false then maybe it becomes more obvious what's going 
> wrong here.

This is probably not going to be useful:

- `D->dump()`: `FieldDecl 0x169993f9fbd0 <>  __r_ 
'std::__compressed_pair, 
std::allocator >::__rep, std::allocator >'`
- `((Decl*)ToDC)->dump()` - prints:

  a decl that inherits DeclContext isn't handled
  UNREACHABLE executed at llvm-project/clang/lib/AST/DeclBase.cpp:928!

- `FromRD->dump()` prints something wy to long to include here :)

  ClassTemplateSpecializationDecl 0x169983fc2b98 <>  class basic_string definition
  |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init
  | |-DefaultConstructor exists non_trivial user_provided
  | |-CopyConstructor non_trivial user_declared has_const_param 
needs_overload_resolution implicit_has_const_param
  | |-MoveConstructor exists non_trivial user_declared 
  | |-CopyAssignment non_trivial has_const_param user_declared 
needs_overload_resolution implicit_has_const_param
  | |-MoveAssignment exists non_trivial user_declared
  | `-Destructor non_trivial user_declared
  |-private 'std::__basic_string_common'
  |-TemplateArgument type 'char'
  | `-BuiltinType 0x1695c0305860 'char'
  ...



- `((Decl*)ToD)->getLexicalDeclContext()` errors: `error: Execution was 
interrupted, reason: signal SIGSEGV: address access protected (fault address: 
0x55e26400).` (ToD is nonnull: 0x1699897a5e00)

I'm running out of time today & I'm off tomorrow, but I should be able to post 
something on Monday. I have a suspicion it's dependent on whatever flags chrome 
is building with, so I'll try to figure that out too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102993

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


[Lldb-commits] [PATCH] D102993: [lldb] Disable minimal import mode for RecordDecls that back FieldDecls

2021-06-22 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D102993#2811902 , @rupprecht wrote:

> In D102993#2811337 , @teemperor 
> wrote:
>
>> Sure I can take a look, but I don't see the immediate problem when looking 
>> at the backtrace.
>>
>> I assume it takes some time to reduce the bug in Chrome? If you could get me 
>> the `dump()` output for the Decls `D`, `(Decl*)ToDC`, `FromRD`, `ToD`, 
>> `(Decl*)ToD->getLexicalDeclContext()` and whether the left or the right side 
>> of the `&&` is true/false then maybe it becomes more obvious what's going 
>> wrong here.
>
> This is probably not going to be useful:
>
> - `D->dump()`: `FieldDecl 0x169993f9fbd0 <>  __r_ 
> 'std::__compressed_pair, 
> std::allocator >::__rep, std::allocator >'`
> - `((Decl*)ToDC)->dump()` - prints:
>
>   a decl that inherits DeclContext isn't handled
>   UNREACHABLE executed at llvm-project/clang/lib/AST/DeclBase.cpp:928!

`ToDC->getDeclKindName()` is "ClassTemplateSpecialization". Does that explain 
the unreachable error message? Maybe it needs a special case somewhere?

> - `FromRD->dump()` prints something wy to long to include here :)
>
>   ClassTemplateSpecializationDecl 0x169983fc2b98 <>  sloc> class basic_string definition
>   |-DefinitionData standard_layout has_user_declared_ctor 
> can_const_default_init
>   | |-DefaultConstructor exists non_trivial user_provided
>   | |-CopyConstructor non_trivial user_declared has_const_param 
> needs_overload_resolution implicit_has_const_param
>   | |-MoveConstructor exists non_trivial user_declared 
>   | |-CopyAssignment non_trivial has_const_param user_declared 
> needs_overload_resolution implicit_has_const_param
>   | |-MoveAssignment exists non_trivial user_declared
>   | `-Destructor non_trivial user_declared
>   |-private 'std::__basic_string_common'
>   |-TemplateArgument type 'char'
>   | `-BuiltinType 0x1695c0305860 'char'
>   ...
>
>
>
> - `((Decl*)ToD)->getLexicalDeclContext()` errors: `error: Execution was 
> interrupted, reason: signal SIGSEGV: address access protected (fault address: 
> 0x55e26400).` (ToD is nonnull: 0x1699897a5e00)
>
> I'm running out of time today & I'm off tomorrow, but I should be able to 
> post something on Monday. I have a suspicion it's dependent on whatever flags 
> chrome is building with, so I'll try to figure that out too.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102993

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


[Lldb-commits] [PATCH] D100795: [lldb] Fix RichManglingContext::FromCxxMethodName() leak

2021-04-21 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb5e11f460b1: [lldb] Fix 
RichManglingContext::FromCxxMethodName() leak (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100795

Files:
  lldb/include/lldb/Core/RichManglingContext.h
  lldb/source/Core/RichManglingContext.cpp


Index: lldb/source/Core/RichManglingContext.cpp
===
--- lldb/source/Core/RichManglingContext.cpp
+++ lldb/source/Core/RichManglingContext.cpp
@@ -19,7 +19,12 @@
 using namespace lldb_private;
 
 // RichManglingContext
-void RichManglingContext::ResetProvider(InfoProvider new_provider) {
+RichManglingContext::~RichManglingContext() {
+  std::free(m_ipd_buf);
+  ResetCxxMethodParser();
+}
+
+void RichManglingContext::ResetCxxMethodParser() {
   // If we want to support parsers for other languages some day, we need a
   // switch here to delete the correct parser type.
   if (m_cxx_method_parser.hasValue()) {
@@ -27,6 +32,10 @@
 delete get(m_cxx_method_parser);
 m_cxx_method_parser.reset();
   }
+}
+
+void RichManglingContext::ResetProvider(InfoProvider new_provider) {
+  ResetCxxMethodParser();
 
   assert(new_provider != None && "Only reset to a valid provider");
   m_provider = new_provider;
Index: lldb/include/lldb/Core/RichManglingContext.h
===
--- lldb/include/lldb/Core/RichManglingContext.h
+++ lldb/include/lldb/Core/RichManglingContext.h
@@ -29,7 +29,7 @@
 m_ipd_buf[0] = '\0';
   }
 
-  ~RichManglingContext() { std::free(m_ipd_buf); }
+  ~RichManglingContext();
 
   /// Use the ItaniumPartialDemangler to obtain rich mangling information from
   /// the given mangled name.
@@ -77,6 +77,9 @@
 
   /// Members for ItaniumPartialDemangler
   llvm::ItaniumPartialDemangler m_ipd;
+  /// Note: m_ipd_buf is a raw pointer due to being resized by realloc via
+  /// ItaniumPartialDemangler. It should be managed with malloc/free, not
+  /// new/delete.
   char *m_ipd_buf;
   size_t m_ipd_buf_size;
 
@@ -86,6 +89,9 @@
   /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
   llvm::Any m_cxx_method_parser;
 
+  /// Clean up memory when using PluginCxxLanguage
+  void ResetCxxMethodParser();
+
   /// Clean up memory and set a new info provider for this instance.
   void ResetProvider(InfoProvider new_provider);
 


Index: lldb/source/Core/RichManglingContext.cpp
===
--- lldb/source/Core/RichManglingContext.cpp
+++ lldb/source/Core/RichManglingContext.cpp
@@ -19,7 +19,12 @@
 using namespace lldb_private;
 
 // RichManglingContext
-void RichManglingContext::ResetProvider(InfoProvider new_provider) {
+RichManglingContext::~RichManglingContext() {
+  std::free(m_ipd_buf);
+  ResetCxxMethodParser();
+}
+
+void RichManglingContext::ResetCxxMethodParser() {
   // If we want to support parsers for other languages some day, we need a
   // switch here to delete the correct parser type.
   if (m_cxx_method_parser.hasValue()) {
@@ -27,6 +32,10 @@
 delete get(m_cxx_method_parser);
 m_cxx_method_parser.reset();
   }
+}
+
+void RichManglingContext::ResetProvider(InfoProvider new_provider) {
+  ResetCxxMethodParser();
 
   assert(new_provider != None && "Only reset to a valid provider");
   m_provider = new_provider;
Index: lldb/include/lldb/Core/RichManglingContext.h
===
--- lldb/include/lldb/Core/RichManglingContext.h
+++ lldb/include/lldb/Core/RichManglingContext.h
@@ -29,7 +29,7 @@
 m_ipd_buf[0] = '\0';
   }
 
-  ~RichManglingContext() { std::free(m_ipd_buf); }
+  ~RichManglingContext();
 
   /// Use the ItaniumPartialDemangler to obtain rich mangling information from
   /// the given mangled name.
@@ -77,6 +77,9 @@
 
   /// Members for ItaniumPartialDemangler
   llvm::ItaniumPartialDemangler m_ipd;
+  /// Note: m_ipd_buf is a raw pointer due to being resized by realloc via
+  /// ItaniumPartialDemangler. It should be managed with malloc/free, not
+  /// new/delete.
   char *m_ipd_buf;
   size_t m_ipd_buf_size;
 
@@ -86,6 +89,9 @@
   /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
   llvm::Any m_cxx_method_parser;
 
+  /// Clean up memory when using PluginCxxLanguage
+  void ResetCxxMethodParser();
+
   /// Clean up memory and set a new info provider for this instance.
   void ResetProvider(InfoProvider new_provider);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D97786: LLDB: Use path relative to binary, not relative to debugger CWD, for finding .dwo files.

2021-04-23 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D97786#2693410 , @jingham wrote:

> In D97786#2693381 , @cmtice wrote:
>
>> I had to revert this change because the test case broke the windows builder. 
>>  What's the right way to update/mark the test case so that it is only run on 
>> appropriate architectures & operating systems?
>
> You add the python skipIfWindows "decorator" before each test case 
> definition.  Just grep around in the test/API directory and you'll see plenty 
> of instances of its use.

Since this is a shell (lit) test, I think you mean adding `# REQUIRES: windows` 
at the top of the test?

> This does seem like it should work on Windows, however.  Maybe some path 
> handling problem?

This would be my guess too. But the APIs used here seem to handle file paths 
generically...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97786

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


[Lldb-commits] [PATCH] D101153: [lldb][NFC] Specify guidelines for API tests

2021-04-23 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

LGTM too, thanks for writing this up!




Comment at: lldb/docs/resources/test.rst:264
+::
+self.expect("expr 1 - 1", substrs=["0"])
+

shafik wrote:
> Maybe some more examples with alternatives would be helpful here.
Also mentioning why this check is bad would help spell it out. IIUC, it's 
because the full output will include `$0` (if it's the first expression, as 
noted); in which case, a stronger example is something that's clearly wrong:

```
(lldb) expr 5-3
(int) $0 = 2
```

In which case, `self.expect("expr 5 - 3", substrs=["0"])` passes, but shouldn't.



Comment at: lldb/docs/resources/test.rst:279-280
+self.assertTrue(expected_string in list_of_results)
+# Good. Will print expected_string and the contents of list_of_results.
+self.assertIn(expected_string, list_of_results) # Good.
+

nit: extra "# Good"


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

https://reviews.llvm.org/D101153

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


[Lldb-commits] [PATCH] D96202: [lldb/test] Automatically find debug servers to test

2021-02-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py:75-79
-if "LLDB_DEBUGSERVER_PATH" in os.environ:
-return os.environ["LLDB_DEBUGSERVER_PATH"]
 
-return _get_debug_monitor_from_lldb(
-lldbtest_config.lldbExec, "lldb-server")

labath wrote:
> @rupprecht : I'm adding you mainly because my last attempt to change this 
> function broke some google integration stuff.
Thanks, patching this in now! (Sorry for the delay, I was out a couple days)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96202

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


[Lldb-commits] [PATCH] D96202: [lldb/test] Automatically find debug servers to test

2021-02-10 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht accepted this revision.
rupprecht added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py:75-79
-if "LLDB_DEBUGSERVER_PATH" in os.environ:
-return os.environ["LLDB_DEBUGSERVER_PATH"]
 
-return _get_debug_monitor_from_lldb(
-lldbtest_config.lldbExec, "lldb-server")

labath wrote:
> rupprecht wrote:
> > labath wrote:
> > > @rupprecht : I'm adding you mainly because my last attempt to change this 
> > > function broke some google integration stuff.
> > Thanks, patching this in now! (Sorry for the delay, I was out a couple days)
> Sure, np. Let me know how it works out.
Everything I've tried to throw this against seems to be working. I'm not sure 
exactly what the problem was before though. Seems fine to land and I can take a 
closer look if something fails later. Thanks for the heads up!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96202

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


[Lldb-commits] [PATCH] D100048: [lldb][Editline] Fix crash when navigating through empty command history.

2021-04-07 Thread Jordan Rupprecht via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf49a4440d38a: [lldb][Editline] Fix crash when navigating 
through empty command history. (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100048

Files:
  lldb/source/Host/common/Editline.cpp
  
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py


Index: 
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
===
--- 
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
+++ 
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
@@ -69,3 +69,26 @@
 self.child.expect_exact("(int) $0 = 334")
 
 self.quit()
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316')
+def test_nav_arrow_up_empty_pr49845(self):
+"""Tests that navigating with the up arrow doesn't crash."""
+self.launch()
+
+# Create an empty history session by only entering a newline.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send("\n")
+self.expect_prompt()
+
+# Send just the up arrow in the expression evaluator. This should 
bring up the previous empty expression.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send(self.arrow_up)
+self.child.expect_exact("1: ")
+self.child.send("\n")
+self.expect_prompt()
+
+self.quit()
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -153,6 +153,11 @@
 result.push_back(input.substr(start, end - start));
 start = end + 1;
   }
+  // Treat an empty history session as a single command of zero-length instead
+  // of returning an empty vector.
+  if (result.empty()) {
+result.emplace_back();
+  }
   return result;
 }
 


Index: lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
===
--- lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
+++ lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
@@ -69,3 +69,26 @@
 self.child.expect_exact("(int) $0 = 334")
 
 self.quit()
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316')
+def test_nav_arrow_up_empty_pr49845(self):
+"""Tests that navigating with the up arrow doesn't crash."""
+self.launch()
+
+# Create an empty history session by only entering a newline.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send("\n")
+self.expect_prompt()
+
+# Send just the up arrow in the expression evaluator. This should bring up the previous empty expression.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send(self.arrow_up)
+self.child.expect_exact("1: ")
+self.child.send("\n")
+self.expect_prompt()
+
+self.quit()
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -153,6 +153,11 @@
 result.push_back(input.substr(start, end - start));
 start = end + 1;
   }
+  // Treat an empty history session as a single command of zero-length instead
+  // of returning an empty vector.
+  if (result.empty()) {
+result.emplace_back();
+  }
   return result;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D100048: [lldb][Editline] Fix crash when navigating through empty command history.

2021-04-07 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
rupprecht added a reviewer: JDevlieghere.
rupprecht requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

An empty history entry can happen by entering the expression evaluator an 
immediately hitting enter:

  $ lldb
  (lldb) e
  Enter expressions, then terminate with an empty line to evaluate:
1:  

The next time the user enters the expression evaluator, if they hit the up 
arrow to load the previous expression, lldb crashes. This patch treats empty 
history sessions as a single expression of zero length, instead of an empty 
list of expressions.

Fixes http://llvm.org/PR49845.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100048

Files:
  lldb/source/Host/common/Editline.cpp
  
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py


Index: 
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
===
--- 
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
+++ 
lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
@@ -69,3 +69,26 @@
 self.child.expect_exact("(int) $0 = 334")
 
 self.quit()
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316')
+def test_nav_arrow_up_empty_pr49845(self):
+"""Tests that navigating with the up arrow doesn't crash."""
+self.launch()
+
+# Create an empty history session by only entering a newline.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send("\n")
+self.expect_prompt()
+
+# Send just the up arrow in the expression evaluator. This should 
bring up the previous empty expression.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send(self.arrow_up)
+self.child.expect_exact("1: ")
+self.child.send("\n")
+self.expect_prompt()
+
+self.quit()
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -153,6 +153,11 @@
 result.push_back(input.substr(start, end - start));
 start = end + 1;
   }
+  // Treat an empty history session as a single command of zero-length instead
+  // of returning an empty vector.
+  if (result.empty()) {
+result.emplace_back();
+  }
   return result;
 }
 


Index: lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
===
--- lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
+++ lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
@@ -69,3 +69,26 @@
 self.child.expect_exact("(int) $0 = 334")
 
 self.quit()
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316')
+def test_nav_arrow_up_empty_pr49845(self):
+"""Tests that navigating with the up arrow doesn't crash."""
+self.launch()
+
+# Create an empty history session by only entering a newline.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send("\n")
+self.expect_prompt()
+
+# Send just the up arrow in the expression evaluator. This should bring up the previous empty expression.
+self.child.sendline("expr")
+self.child.expect_exact("terminate with an empty line to evaluate")
+self.child.send(self.arrow_up)
+self.child.expect_exact("1: ")
+self.child.send("\n")
+self.expect_prompt()
+
+self.quit()
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -153,6 +153,11 @@
 result.push_back(input.substr(start, end - start));
 start = end + 1;
   }
+  // Treat an empty history session as a single command of zero-length instead
+  // of returning an empty vector.
+  if (result.empty()) {
+result.emplace_back();
+  }
   return result;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D100508: [lldb] Simplify output for skipped categories in dotest.py

2021-04-15 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

> The motivation for this change is that sometimes engineers misidentify the 
> output of these messages as the cause for a test failure

I have worked on one these checks and *still* gotten confused by the message, 
so thanks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100508

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


[Lldb-commits] [PATCH] D100795: [lldb] Fix RichManglingContext::FromCxxMethodName() leak

2021-04-19 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht updated this revision to Diff 338665.
rupprecht added a comment.

- Refactor cleanup of m_cxx_method_parser


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100795

Files:
  lldb/include/lldb/Core/RichManglingContext.h
  lldb/source/Core/RichManglingContext.cpp


Index: lldb/source/Core/RichManglingContext.cpp
===
--- lldb/source/Core/RichManglingContext.cpp
+++ lldb/source/Core/RichManglingContext.cpp
@@ -19,14 +19,23 @@
 using namespace lldb_private;
 
 // RichManglingContext
-void RichManglingContext::ResetProvider(InfoProvider new_provider) {
-  // If we want to support parsers for other languages some day, we need a
-  // switch here to delete the correct parser type.
+RichManglingContext::~RichManglingContext() {
+  std::free(m_ipd_buf);
+  ResetCxxMethodParser();
+}
+
+void RichManglingContext::ResetCxxMethodParser() {
   if (m_cxx_method_parser.hasValue()) {
 assert(m_provider == PluginCxxLanguage);
 delete get(m_cxx_method_parser);
 m_cxx_method_parser.reset();
   }
+}
+
+void RichManglingContext::ResetProvider(InfoProvider new_provider) {
+  // If we want to support parsers for other languages some day, we need a
+  // switch here to delete the correct parser type.
+  ResetCxxMethodParser();
 
   assert(new_provider != None && "Only reset to a valid provider");
   m_provider = new_provider;
Index: lldb/include/lldb/Core/RichManglingContext.h
===
--- lldb/include/lldb/Core/RichManglingContext.h
+++ lldb/include/lldb/Core/RichManglingContext.h
@@ -29,7 +29,7 @@
 m_ipd_buf[0] = '\0';
   }
 
-  ~RichManglingContext() { std::free(m_ipd_buf); }
+  ~RichManglingContext();
 
   /// Use the ItaniumPartialDemangler to obtain rich mangling information from
   /// the given mangled name.
@@ -86,6 +86,9 @@
   /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
   llvm::Any m_cxx_method_parser;
 
+  /// Clean up memory when using PluginCxxLanguage
+  void ResetCxxMethodParser();
+
   /// Clean up memory and set a new info provider for this instance.
   void ResetProvider(InfoProvider new_provider);
 


Index: lldb/source/Core/RichManglingContext.cpp
===
--- lldb/source/Core/RichManglingContext.cpp
+++ lldb/source/Core/RichManglingContext.cpp
@@ -19,14 +19,23 @@
 using namespace lldb_private;
 
 // RichManglingContext
-void RichManglingContext::ResetProvider(InfoProvider new_provider) {
-  // If we want to support parsers for other languages some day, we need a
-  // switch here to delete the correct parser type.
+RichManglingContext::~RichManglingContext() {
+  std::free(m_ipd_buf);
+  ResetCxxMethodParser();
+}
+
+void RichManglingContext::ResetCxxMethodParser() {
   if (m_cxx_method_parser.hasValue()) {
 assert(m_provider == PluginCxxLanguage);
 delete get(m_cxx_method_parser);
 m_cxx_method_parser.reset();
   }
+}
+
+void RichManglingContext::ResetProvider(InfoProvider new_provider) {
+  // If we want to support parsers for other languages some day, we need a
+  // switch here to delete the correct parser type.
+  ResetCxxMethodParser();
 
   assert(new_provider != None && "Only reset to a valid provider");
   m_provider = new_provider;
Index: lldb/include/lldb/Core/RichManglingContext.h
===
--- lldb/include/lldb/Core/RichManglingContext.h
+++ lldb/include/lldb/Core/RichManglingContext.h
@@ -29,7 +29,7 @@
 m_ipd_buf[0] = '\0';
   }
 
-  ~RichManglingContext() { std::free(m_ipd_buf); }
+  ~RichManglingContext();
 
   /// Use the ItaniumPartialDemangler to obtain rich mangling information from
   /// the given mangled name.
@@ -86,6 +86,9 @@
   /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp.
   llvm::Any m_cxx_method_parser;
 
+  /// Clean up memory when using PluginCxxLanguage
+  void ResetCxxMethodParser();
+
   /// Clean up memory and set a new info provider for this instance.
   void ResetProvider(InfoProvider new_provider);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   3   >