[Lldb-commits] [PATCH] D91056: [lldb] [test] Skip ObjC-based tests via 'objc' category

2020-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for cleaning this up, it's really appreciated!




Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:839
+def checkObjcSupport():
+from . import lldbplatformutil
+if not lldbplatformutil.platformIsDarwin():

nit: we do `from lldbsuite.test import lldbplatformutil` in the surrounding 
code, so that seems more consistent.



Comment at: lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py:16
 
 @expectedFailureAll(
 oslist=["linux"],

mgorny wrote:
> This one's curious. I'm wondering why it's explicitly marked for all the 
> platforms while it.s clearly a `.m` file ;-).
For the record: I think those XFails were just copied to all sanitizers tests 
that were failing on Linux (independently of whether the issue was lacking 
sanitizer support on Linux or as here Obj-C support missing).


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

https://reviews.llvm.org/D91056

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


[Lldb-commits] [PATCH] D91056: [lldb] [test] Skip ObjC-based tests via 'objc' category

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:839
+def checkObjcSupport():
+from . import lldbplatformutil
+if not lldbplatformutil.platformIsDarwin():

teemperor wrote:
> nit: we do `from lldbsuite.test import lldbplatformutil` in the surrounding 
> code, so that seems more consistent.
Thanks, will fix it in place.


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

https://reviews.llvm.org/D91056

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


[Lldb-commits] [lldb] 203b477 - [lldb][ObjectFile] Relocate sections for in-memory objects (e.g. received via JITLoaderGDB)

2020-11-10 Thread Stefan Gränitz via lldb-commits

Author: Stefan Gränitz
Date: 2020-11-10T11:37:53+01:00
New Revision: 203b4774b88322de22c99881a3e1e4c78a9d5a0e

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

LOG: [lldb][ObjectFile] Relocate sections for in-memory objects (e.g. received 
via JITLoaderGDB)

Part 2 of a fix for JITed code debugging. This has been a regression from 5.0 
to 6.0 and it's still reproducible on current master: 
https://bugs.llvm.org/show_bug.cgi?id=36209 Part 1 was D61611 a while ago.

The in-memory object files we obtain from JITLoaderGDB are not yet relocated. 
It looks like this used to happen on the LLDB side and my guess is that it 
broke with D38142. (However, it's hard to tell because the whole thing was 
broken already due to the bug in part 1.) The patch moved relocation resolution 
to a later point in time and didn't apply it to in-memory objects. I am not 
aware of any reason why we wouldn't resolve relocations per-se, so I made it 
unconditional here. On Debian, it fixes the bug for me and all tests in 
`check-lldb` are still fine.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Symbol/ObjectFile.cpp
lldb/test/Shell/Breakpoint/jitbp_elf.test

Removed: 




diff  --git a/lldb/source/Symbol/ObjectFile.cpp 
b/lldb/source/Symbol/ObjectFile.cpp
index 6b552dd0c19e..79683284f36a 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -503,6 +503,9 @@ size_t ObjectFile::ReadSectionData(Section *section,
 return section->GetObjectFile()->ReadSectionData(section, section_offset,
  dst, dst_len);
 
+  if (!section->IsRelocated())
+RelocateSection(section);
+
   if (IsInMemory()) {
 ProcessSP process_sp(m_process_wp.lock());
 if (process_sp) {
@@ -514,9 +517,6 @@ size_t ObjectFile::ReadSectionData(Section *section,
   dst_len, error);
 }
   } else {
-if (!section->IsRelocated())
-  RelocateSection(section);
-
 const lldb::offset_t section_file_size = section->GetFileSize();
 if (section_offset < section_file_size) {
   const size_t section_bytes_left = section_file_size - section_offset;
@@ -547,6 +547,9 @@ size_t ObjectFile::ReadSectionData(Section *section,
   if (section->GetObjectFile() != this)
 return section->GetObjectFile()->ReadSectionData(section, section_data);
 
+  if (!section->IsRelocated())
+RelocateSection(section);
+
   if (IsInMemory()) {
 ProcessSP process_sp(m_process_wp.lock());
 if (process_sp) {
@@ -563,17 +566,12 @@ size_t ObjectFile::ReadSectionData(Section *section,
 }
   }
 }
-return GetData(section->GetFileOffset(), section->GetFileSize(),
-   section_data);
-  } else {
-// The object file now contains a full mmap'ed copy of the object file
-// data, so just use this
-if (!section->IsRelocated())
-  RelocateSection(section);
-
-return GetData(section->GetFileOffset(), section->GetFileSize(),
-   section_data);
   }
+
+  // The object file now contains a full mmap'ed copy of the object file
+  // data, so just use this
+  return GetData(section->GetFileOffset(), section->GetFileSize(),
+  section_data);
 }
 
 bool ObjectFile::SplitArchivePathWithObject(llvm::StringRef path_with_object,

diff  --git a/lldb/test/Shell/Breakpoint/jitbp_elf.test 
b/lldb/test/Shell/Breakpoint/jitbp_elf.test
index 1dc5fa97005e..c637dba75b05 100644
--- a/lldb/test/Shell/Breakpoint/jitbp_elf.test
+++ b/lldb/test/Shell/Breakpoint/jitbp_elf.test
@@ -7,5 +7,8 @@
 # CHECK: Breakpoint 1: no locations (pending).
 # CHECK: (lldb) run -jit-kind=mcjit {{.*}}/jitbp_elf.test.tmp.ll
 # CHECK: Process {{.*}} stopped
-# CHECK: JIT(0x{{.*}})`jitbp:
+# CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15
+# CHECK: -> 1int jitbp() { return 0; }
+# CHECK:   ^
+# CHECK:2int main() { return jitbp(); }
 # CHECK: Process {{.*}} launched: {{.*}}



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


[Lldb-commits] [PATCH] D90769: [lldb][ObjectFile] Relocate sections for in-memory objects (e.g. received via JITLoaderGDB)

2020-11-10 Thread Stefan Gränitz 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 rG203b4774b883: [lldb][ObjectFile] Relocate sections for 
in-memory objects (e.g. received via… (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90769

Files:
  lldb/source/Symbol/ObjectFile.cpp
  lldb/test/Shell/Breakpoint/jitbp_elf.test


Index: lldb/test/Shell/Breakpoint/jitbp_elf.test
===
--- lldb/test/Shell/Breakpoint/jitbp_elf.test
+++ lldb/test/Shell/Breakpoint/jitbp_elf.test
@@ -7,5 +7,8 @@
 # CHECK: Breakpoint 1: no locations (pending).
 # CHECK: (lldb) run -jit-kind=mcjit {{.*}}/jitbp_elf.test.tmp.ll
 # CHECK: Process {{.*}} stopped
-# CHECK: JIT(0x{{.*}})`jitbp:
+# CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15
+# CHECK: -> 1int jitbp() { return 0; }
+# CHECK:   ^
+# CHECK:2int main() { return jitbp(); }
 # CHECK: Process {{.*}} launched: {{.*}}
Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -503,6 +503,9 @@
 return section->GetObjectFile()->ReadSectionData(section, section_offset,
  dst, dst_len);
 
+  if (!section->IsRelocated())
+RelocateSection(section);
+
   if (IsInMemory()) {
 ProcessSP process_sp(m_process_wp.lock());
 if (process_sp) {
@@ -514,9 +517,6 @@
   dst_len, error);
 }
   } else {
-if (!section->IsRelocated())
-  RelocateSection(section);
-
 const lldb::offset_t section_file_size = section->GetFileSize();
 if (section_offset < section_file_size) {
   const size_t section_bytes_left = section_file_size - section_offset;
@@ -547,6 +547,9 @@
   if (section->GetObjectFile() != this)
 return section->GetObjectFile()->ReadSectionData(section, section_data);
 
+  if (!section->IsRelocated())
+RelocateSection(section);
+
   if (IsInMemory()) {
 ProcessSP process_sp(m_process_wp.lock());
 if (process_sp) {
@@ -563,17 +566,12 @@
 }
   }
 }
-return GetData(section->GetFileOffset(), section->GetFileSize(),
-   section_data);
-  } else {
-// The object file now contains a full mmap'ed copy of the object file
-// data, so just use this
-if (!section->IsRelocated())
-  RelocateSection(section);
-
-return GetData(section->GetFileOffset(), section->GetFileSize(),
-   section_data);
   }
+
+  // The object file now contains a full mmap'ed copy of the object file
+  // data, so just use this
+  return GetData(section->GetFileOffset(), section->GetFileSize(),
+  section_data);
 }
 
 bool ObjectFile::SplitArchivePathWithObject(llvm::StringRef path_with_object,


Index: lldb/test/Shell/Breakpoint/jitbp_elf.test
===
--- lldb/test/Shell/Breakpoint/jitbp_elf.test
+++ lldb/test/Shell/Breakpoint/jitbp_elf.test
@@ -7,5 +7,8 @@
 # CHECK: Breakpoint 1: no locations (pending).
 # CHECK: (lldb) run -jit-kind=mcjit {{.*}}/jitbp_elf.test.tmp.ll
 # CHECK: Process {{.*}} stopped
-# CHECK: JIT(0x{{.*}})`jitbp:
+# CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15
+# CHECK: -> 1int jitbp() { return 0; }
+# CHECK:   ^
+# CHECK:2int main() { return jitbp(); }
 # CHECK: Process {{.*}} launched: {{.*}}
Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -503,6 +503,9 @@
 return section->GetObjectFile()->ReadSectionData(section, section_offset,
  dst, dst_len);
 
+  if (!section->IsRelocated())
+RelocateSection(section);
+
   if (IsInMemory()) {
 ProcessSP process_sp(m_process_wp.lock());
 if (process_sp) {
@@ -514,9 +517,6 @@
   dst_len, error);
 }
   } else {
-if (!section->IsRelocated())
-  RelocateSection(section);
-
 const lldb::offset_t section_file_size = section->GetFileSize();
 if (section_offset < section_file_size) {
   const size_t section_bytes_left = section_file_size - section_offset;
@@ -547,6 +547,9 @@
   if (section->GetObjectFile() != this)
 return section->GetObjectFile()->ReadSectionData(section, section_data);
 
+  if (!section->IsRelocated())
+RelocateSection(section);
+
   if (IsInMemory()) {
 ProcessSP process_sp(m_process_wp.lock());
 if (process_sp) {
@@ -563,17 +566,12 @@
 }
   }
 }
-return GetData(section->GetFileOffset(), section->GetFileSize(),
-   section_data);
-  } else {
-   

[Lldb-commits] [lldb] 311cca8 - [lldb] [test] Rename '.categories' to 'categories'

2020-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-11-10T12:02:38+01:00
New Revision: 311cca8bbf882cd93124d5ee9f40ee47f5e1f57d

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

LOG: [lldb] [test] Rename '.categories' to 'categories'

Make category-specifying files visible.  There is really no good reason
to keep them hidden, and having them visible increases the chances
that someone will actually spot them.

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

Added: 
lldb/test/API/api/multiple-debuggers/categories
lldb/test/API/commands/command/categories
lldb/test/API/commands/expression/categories
lldb/test/API/commands/expression/completion/categories
lldb/test/API/commands/expression/import-std-module/categories
lldb/test/API/commands/frame/recognizer/categories
lldb/test/API/commands/watchpoints/categories
lldb/test/API/functionalities/abbreviation/categories
lldb/test/API/functionalities/alias/categories
lldb/test/API/functionalities/asan/categories
lldb/test/API/functionalities/backticks/categories
lldb/test/API/functionalities/completion/categories
lldb/test/API/functionalities/darwin_log/categories
lldb/test/API/functionalities/data-formatter/categories
lldb/test/API/functionalities/data-formatter/data-formatter-objc/categories
lldb/test/API/functionalities/load_unload/categories
lldb/test/API/functionalities/load_using_paths/categories
lldb/test/API/functionalities/mtc/categories
lldb/test/API/functionalities/thread/step_until/categories
lldb/test/API/functionalities/tsan/categories
lldb/test/API/functionalities/ubsan/categories
lldb/test/API/functionalities/wrong_commands/categories
lldb/test/API/lang/c/step-target/categories
lldb/test/API/lang/cpp/char1632_t/categories
lldb/test/API/lang/cpp/wchar_t/categories
lldb/test/API/lang/objc/categories
lldb/test/API/lang/objc/objc-dyn-sbtype/categories
lldb/test/API/lang/objcxx/categories
lldb/test/API/macosx/nslog/categories
lldb/test/API/python_api/categories
lldb/test/API/python_api/watchpoint/categories
lldb/test/API/tools/lldb-server/categories
lldb/test/API/tools/lldb-vscode/categories

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

Removed: 
lldb/test/API/api/multiple-debuggers/.categories
lldb/test/API/commands/command/.categories
lldb/test/API/commands/expression/.categories
lldb/test/API/commands/expression/completion/.categories
lldb/test/API/commands/expression/import-std-module/.categories
lldb/test/API/commands/frame/recognizer/.categories
lldb/test/API/commands/watchpoints/.categories
lldb/test/API/functionalities/abbreviation/.categories
lldb/test/API/functionalities/alias/.categories
lldb/test/API/functionalities/asan/.categories
lldb/test/API/functionalities/backticks/.categories
lldb/test/API/functionalities/completion/.categories
lldb/test/API/functionalities/darwin_log/.categories
lldb/test/API/functionalities/data-formatter/.categories
lldb/test/API/functionalities/data-formatter/data-formatter-objc/.categories
lldb/test/API/functionalities/load_unload/.categories
lldb/test/API/functionalities/load_using_paths/.categories
lldb/test/API/functionalities/mtc/.categories
lldb/test/API/functionalities/thread/step_until/.categories
lldb/test/API/functionalities/tsan/.categories
lldb/test/API/functionalities/ubsan/.categories
lldb/test/API/functionalities/wrong_commands/.categories
lldb/test/API/lang/c/step-target/.categories
lldb/test/API/lang/cpp/char1632_t/.categories
lldb/test/API/lang/cpp/wchar_t/.categories
lldb/test/API/lang/objc/.categories
lldb/test/API/lang/objc/objc-dyn-sbtype/.categories
lldb/test/API/lang/objcxx/.categories
lldb/test/API/macosx/nslog/.categories
lldb/test/API/python_api/.categories
lldb/test/API/python_api/watchpoint/.categories
lldb/test/API/tools/lldb-server/.categories
lldb/test/API/tools/lldb-vscode/.categories



diff  --git a/lldb/packages/Python/lldbsuite/test/test_result.py 
b/lldb/packages/Python/lldbsuite/test/test_result.py
index cab446d95e6d..ff01b21a561a 100644
--- a/lldb/packages/Python/lldbsuite/test/test_result.py
+++ b/lldb/packages/Python/lldbsuite/test/test_result.py
@@ -112,7 +112,7 @@ def _getTestPath(self, test):
 def _getFileBasedCategories(self, test):
 """
 Returns the list of categories to which this test case belongs by
-collecting values of ".categories" files. We start at the folder the 
test is in
+collecting values of "categories" files. We start at the folder the 
test is in
 and traverse the hierarchy upwards until the test-suite root directory.
  

[Lldb-commits] [PATCH] D91065: [lldb] [test] Rename '.categories' to 'categories'

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG311cca8bbf88: [lldb] [test] Rename '.categories' 
to 'categories' (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91065

Files:
  lldb/packages/Python/lldbsuite/test/test_result.py
  lldb/test/API/api/multiple-debuggers/.categories
  lldb/test/API/api/multiple-debuggers/categories
  lldb/test/API/commands/command/.categories
  lldb/test/API/commands/command/categories
  lldb/test/API/commands/expression/.categories
  lldb/test/API/commands/expression/categories
  lldb/test/API/commands/expression/completion/.categories
  lldb/test/API/commands/expression/completion/categories
  lldb/test/API/commands/expression/import-std-module/.categories
  lldb/test/API/commands/expression/import-std-module/categories
  lldb/test/API/commands/frame/recognizer/.categories
  lldb/test/API/commands/frame/recognizer/categories
  lldb/test/API/commands/watchpoints/.categories
  lldb/test/API/commands/watchpoints/categories
  lldb/test/API/functionalities/abbreviation/.categories
  lldb/test/API/functionalities/abbreviation/categories
  lldb/test/API/functionalities/alias/.categories
  lldb/test/API/functionalities/alias/categories
  lldb/test/API/functionalities/asan/.categories
  lldb/test/API/functionalities/asan/categories
  lldb/test/API/functionalities/backticks/.categories
  lldb/test/API/functionalities/backticks/categories
  lldb/test/API/functionalities/completion/.categories
  lldb/test/API/functionalities/completion/categories
  lldb/test/API/functionalities/darwin_log/.categories
  lldb/test/API/functionalities/darwin_log/categories
  lldb/test/API/functionalities/data-formatter/.categories
  lldb/test/API/functionalities/data-formatter/categories
  lldb/test/API/functionalities/data-formatter/data-formatter-objc/.categories
  lldb/test/API/functionalities/data-formatter/data-formatter-objc/categories
  lldb/test/API/functionalities/load_unload/.categories
  lldb/test/API/functionalities/load_unload/categories
  lldb/test/API/functionalities/load_using_paths/.categories
  lldb/test/API/functionalities/load_using_paths/categories
  lldb/test/API/functionalities/mtc/.categories
  lldb/test/API/functionalities/mtc/categories
  lldb/test/API/functionalities/thread/step_until/.categories
  lldb/test/API/functionalities/thread/step_until/categories
  lldb/test/API/functionalities/tsan/.categories
  lldb/test/API/functionalities/tsan/categories
  lldb/test/API/functionalities/ubsan/.categories
  lldb/test/API/functionalities/ubsan/categories
  lldb/test/API/functionalities/wrong_commands/.categories
  lldb/test/API/functionalities/wrong_commands/categories
  lldb/test/API/lang/c/step-target/.categories
  lldb/test/API/lang/c/step-target/categories
  lldb/test/API/lang/cpp/char1632_t/.categories
  lldb/test/API/lang/cpp/char1632_t/categories
  lldb/test/API/lang/cpp/wchar_t/.categories
  lldb/test/API/lang/cpp/wchar_t/categories
  lldb/test/API/lang/objc/.categories
  lldb/test/API/lang/objc/categories
  lldb/test/API/lang/objc/objc-dyn-sbtype/.categories
  lldb/test/API/lang/objc/objc-dyn-sbtype/categories
  lldb/test/API/lang/objcxx/.categories
  lldb/test/API/lang/objcxx/categories
  lldb/test/API/macosx/nslog/.categories
  lldb/test/API/macosx/nslog/categories
  lldb/test/API/python_api/.categories
  lldb/test/API/python_api/categories
  lldb/test/API/python_api/watchpoint/.categories
  lldb/test/API/python_api/watchpoint/categories
  lldb/test/API/tools/lldb-server/.categories
  lldb/test/API/tools/lldb-server/categories
  lldb/test/API/tools/lldb-vscode/.categories
  lldb/test/API/tools/lldb-vscode/categories


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
@@ -112,7 +112,7 @@
 def _getFileBasedCategories(self, test):
 """
 Returns the list of categories to which this test case belongs by
-collecting values of ".categories" files. We start at the folder the 
test is in
+collecting values of "categories" files. We start at the folder the 
test is in
 and traverse the hierarchy upwards until the test-suite root directory.
 """
 start_path = self._getTestPath(test)
@@ -126,7 +126,7 @@
 
 categories = set()
 while not os.path.samefile(folder, test_root):
-categories_file_name = os.path.join(folder, ".categories")
+categories_file_name = os.path.join(folder, "categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
 categories_str = categories_file.readline().strip()


Index: lldb/packages/Python/lldbsuite/test/test_resu

[Lldb-commits] [PATCH] D91056: [lldb] [test] Skip ObjC-based tests via 'objc' category

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
mgorny marked an inline comment as done.
Closed by commit rGa852cf66ea5d: [lldb] [test] Skip ObjC-based tests via 
'objc' category (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D91056?vs=303800&id=304122#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91056

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
  lldb/test/API/commands/expression/context-object-objc/TestContextObjectObjc.py
  lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
  
lldb/test/API/commands/expression/import_builtin_fileid/TestImportBuiltinFileID.py
  
lldb/test/API/commands/expression/namespace_local_var_same_name_obj_c/TestNamespaceLocalVarSameNameObjC.py
  
lldb/test/API/commands/expression/persist_objc_pointeetype/TestPersistObjCPointeeType.py
  lldb/test/API/commands/expression/po_verbosity/TestPoVerbosity.py
  
lldb/test/API/commands/expression/two-files/TestObjCTypeQueryFromOtherCompileUnit.py
  lldb/test/API/commands/frame/recognizer/.categories
  lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCExpr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCKVO.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSBundle.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSData.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSURL.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCPlain.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjNSException.py
  lldb/test/API/functionalities/set-data/TestSetData.py
  lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
  lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
  lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py
  lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py
  lldb/test/API/lang/objc/direct-dispatch-step/TestObjCDirectDispatchStepping.py
  lldb/test/API/lang/objc/exceptions/TestObjCExceptions.py
  lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
  lldb/test/API/lang/objc/foundation/TestConstStrings.py
  lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py
  lldb/test/API/lang/objc/foundation/TestObjCMethods.py
  lldb/test/API/lang/objc/foundation/TestObjCMethods2.py
  lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py
  lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py
  lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py
  lldb/test/API/lang/objc/foundation/TestObjectDescriptionAPI.py
  lldb/test/API/lang/objc/foundation/TestRuntimeTypes.py
  lldb/test/API/lang/objc/foundation/TestSymbolTable.py
  lldb/test/API/lang/objc/global_ptrs/TestGlobalObjects.py
  lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
  lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
  lldb/test/API/lang/objc/modules-app-update/TestClangModulesAppUpdate.py
  lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
  lldb/test/API/lang/objc/modules-cache/TestClangModulesCache.py
  lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
  lldb/test/API/lang/objc/modules-hash-mismatch/TestClangModulesHashMismatch.py
  lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py
  lldb/test/API/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
  
lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
  lldb/test/API/lang/objc/modules-update/TestClangModulesUpdate.py
  lldb/test/API/lang/objc/modules/TestObjCModules.py
  lldb/test/API/lang/objc/objc++/TestObjCXX.py
  lldb/test/API/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py
  lldb/test/API/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py
  lldb/test/API/lang/objc/objc-checker/TestObjCCheckers.py
  lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py
  lldb/test/API/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py
  lldb/test/API/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
  lldb/test/API/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py
  lldb/test/API/lang/objc/objc-ivar-offs

[Lldb-commits] [lldb] a852cf6 - [lldb] [test] Skip ObjC-based tests via 'objc' category

2020-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-11-10T12:02:38+01:00
New Revision: a852cf66ea5d130a09cd796b97b15c18059e95cd

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

LOG: [lldb] [test] Skip ObjC-based tests via 'objc' category

Replace the plethora of ObjC-implied 'skipUnlessDarwin' decorators
with marking tests as 'objc' category (whenever missing), and skip all
ObjC tests on non-Darwin platforms.  I have used '.categories' file
wherever it was present already or all (>1) tests were relying on ObjC,
and explicit add_test_categories() where there was only one test.

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

Added: 
lldb/test/API/commands/frame/recognizer/.categories
lldb/test/API/lang/objcxx/.categories
lldb/test/API/macosx/nslog/.categories

Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py

lldb/test/API/commands/expression/context-object-objc/TestContextObjectObjc.py
lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py

lldb/test/API/commands/expression/import_builtin_fileid/TestImportBuiltinFileID.py

lldb/test/API/commands/expression/namespace_local_var_same_name_obj_c/TestNamespaceLocalVarSameNameObjC.py

lldb/test/API/commands/expression/persist_objc_pointeetype/TestPersistObjCPointeeType.py
lldb/test/API/commands/expression/po_verbosity/TestPoVerbosity.py

lldb/test/API/commands/expression/two-files/TestObjCTypeQueryFromOtherCompileUnit.py
lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCExpr.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCKVO.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSBundle.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSData.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSURL.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCPlain.py

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjNSException.py
lldb/test/API/functionalities/set-data/TestSetData.py
lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py
lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py

lldb/test/API/lang/objc/direct-dispatch-step/TestObjCDirectDispatchStepping.py
lldb/test/API/lang/objc/exceptions/TestObjCExceptions.py
lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
lldb/test/API/lang/objc/foundation/TestConstStrings.py
lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py
lldb/test/API/lang/objc/foundation/TestObjCMethods.py
lldb/test/API/lang/objc/foundation/TestObjCMethods2.py
lldb/test/API/lang/objc/foundation/TestObjCMethodsNSArray.py
lldb/test/API/lang/objc/foundation/TestObjCMethodsNSError.py
lldb/test/API/lang/objc/foundation/TestObjCMethodsString.py
lldb/test/API/lang/objc/foundation/TestObjectDescriptionAPI.py
lldb/test/API/lang/objc/foundation/TestRuntimeTypes.py
lldb/test/API/lang/objc/foundation/TestSymbolTable.py
lldb/test/API/lang/objc/global_ptrs/TestGlobalObjects.py
lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py
lldb/test/API/lang/objc/modules-app-update/TestClangModulesAppUpdate.py
lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
lldb/test/API/lang/objc/modules-cache/TestClangModulesCache.py
lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py

lldb/test/API/lang/objc/modules-hash-mismatch/TestClangModulesHashMismatch.py
lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py

lldb/test/API/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py

lldb/test/API/lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
lldb/test/API/lang/objc/modules-update/TestClangModulesUpdate.py
lldb/test/API/lang/objc/modules/TestObjCModules.py
lldb/test/API/lang/objc/objc++/TestObjCXX.py
lldb/test/API/lang/objc/objc-b

[Lldb-commits] [PATCH] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-10 Thread Nathan James via Phabricator via lldb-commits
njames93 updated this revision to Diff 304126.
njames93 added a comment.

Add `isReformatFixit` method to `FixItHint` to better express intent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Tooling/Core/Replacement.h
  clang/lib/Frontend/DiagnosticRenderer.cpp
  clang/lib/Frontend/Rewrite/FixItRewriter.cpp
  clang/lib/Tooling/Core/Replacement.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1167,9 +1167,10 @@
   // This is cobbed from clang::Rewrite::FixItRewriter.
   if (fixit.CodeToInsert.empty()) {
 if (fixit.InsertFromRange.isValid()) {
-  commit.insertFromRange(fixit.RemoveRange.getBegin(),
- fixit.InsertFromRange, /*afterToken=*/false,
- fixit.BeforePreviousInsertions);
+  if (!fixit.isReformatFixit())
+commit.insertFromRange(fixit.RemoveRange.getBegin(),
+   fixit.InsertFromRange, /*afterToken=*/false,
+   fixit.BeforePreviousInsertions);
   return;
 }
 commit.remove(fixit.RemoveRange);
Index: clang/lib/Tooling/Core/Replacement.cpp
===
--- clang/lib/Tooling/Core/Replacement.cpp
+++ clang/lib/Tooling/Core/Replacement.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/RewriteBuffer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -42,32 +43,57 @@
 
 static const char * const InvalidLocation = "";
 
-Replacement::Replacement() : FilePath(InvalidLocation) {}
+FileRange::FileRange() : FilePath(InvalidLocation), RangeInFile(0, 0) {}
+
+FileRange::FileRange(StringRef FilePath, Range RangeInFile)
+: FilePath(FilePath), RangeInFile(RangeInFile) {}
+FileRange::FileRange(StringRef FilePath, unsigned Offset, unsigned Length)
+: FileRange(FilePath, Range(Offset, Length)) {}
+
+FileRange::FileRange(const SourceManager &Sources, SourceLocation Start,
+ unsigned Length) {
+  setFromSourceLocation(Sources, Start, Length);
+}
+
+FileRange::FileRange(const SourceManager &Sources, const CharSourceRange &Range,
+ const LangOptions &LangOpts) {
+  setFromSourceRange(Sources, Range, LangOpts);
+}
+
+bool FileRange::isValid() const { return FilePath != InvalidLocation; }
+
+void FileRange::setFromSourceLocation(const SourceManager &Sources,
+  SourceLocation Start, unsigned Length) {
+  const std::pair DecomposedLocation =
+  Sources.getDecomposedLoc(Start);
+  const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
+  this->FilePath = std::string(Entry ? Entry->getName() : InvalidLocation);
+  this->RangeInFile = {DecomposedLocation.second, Length};
+}
+
+Replacement::Replacement() : ReplacementRange() {}
+
+Replacement::Replacement(FileRange FileRange, StringRef ReplacementText)
+: ReplacementRange(FileRange), ReplacementText(ReplacementText) {}
 
 Replacement::Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
  StringRef ReplacementText)
-: FilePath(std::string(FilePath)), ReplacementRange(Offset, Length),
-  ReplacementText(std::string(ReplacementText)) {}
+: Replacement(FileRange(FilePath, Offset, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager &Sources, SourceLocation Start,
- unsigned Length, StringRef ReplacementText) {
-  setFromSourceLocation(Sources, Start, Length, ReplacementText);
-}
+ unsigned Length, StringRef ReplacementText)
+: Replacement(FileRange(Sources, Start, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager &Sources,
  const CharSourceRange &Range,
- StringRef ReplacementText,
- const LangOptions &LangOpts) {
-  setFromSourceRange(Sources, Range, ReplacementText, LangOpts);
-}
+ StringRef ReplacementText, const LangOptions &LangOpts)
+: Replacement(FileRange(Sources, Range, LangOpts), ReplacementText) {}
 
-bool Replacement::isApplicable() const {
-  return FilePath != InvalidLocation;
-}
+bool Replacement::isApplicable() const { r

[Lldb-commits] [PATCH] D91007: [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 304135.
mgorny added a comment.

clang-format


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

https://reviews.llvm.org/D91007

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/test/API/functionalities/signal/raise/TestRaise.py


Index: lldb/test/API/functionalities/signal/raise/TestRaise.py
===
--- lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -30,7 +30,6 @@
 self.signal_test('SIGRTMIN', True)
 
 @skipIfNetBSD  # Hangs on NetBSD
-@skipIfFreeBSD  # hangs
 def test_sigtrap(self):
 self.build()
 self.signal_test('SIGTRAP', True)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -192,7 +192,8 @@
   }
   assert(info.pl_event == PL_EVENT_SIGNAL);
 
-  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}", pid, info.pl_lwpid);
+  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, flags = {2:x}", pid,
+   info.pl_lwpid, info.pl_flags);
   NativeThreadFreeBSD *thread = nullptr;
 
   if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
@@ -240,6 +241,8 @@
 
   if (info.pl_flags & PL_FLAG_SI) {
 assert(info.pl_siginfo.si_signo == SIGTRAP);
+LLDB_LOG(log, "SIGTRAP siginfo: si_code = {0}, pid = {1}",
+ info.pl_siginfo.si_code, info.pl_siginfo.si_pid);
 
 switch (info.pl_siginfo.si_code) {
 case TRAP_BRKPT:
@@ -248,7 +251,7 @@
 FixupBreakpointPCAsNeeded(*thread);
   }
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 case TRAP_TRACE:
   if (thread) {
 auto ®ctx = static_cast(
@@ -272,9 +275,14 @@
   }
 
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 }
   }
+
+  // Either user-generated SIGTRAP or an unknown event that would
+  // otherwise leave the debugger hanging.
+  LLDB_LOG(log, "unknown SIGTRAP, passing to generic handler");
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {


Index: lldb/test/API/functionalities/signal/raise/TestRaise.py
===
--- lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -30,7 +30,6 @@
 self.signal_test('SIGRTMIN', True)
 
 @skipIfNetBSD  # Hangs on NetBSD
-@skipIfFreeBSD  # hangs
 def test_sigtrap(self):
 self.build()
 self.signal_test('SIGTRAP', True)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -192,7 +192,8 @@
   }
   assert(info.pl_event == PL_EVENT_SIGNAL);
 
-  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}", pid, info.pl_lwpid);
+  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, flags = {2:x}", pid,
+   info.pl_lwpid, info.pl_flags);
   NativeThreadFreeBSD *thread = nullptr;
 
   if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
@@ -240,6 +241,8 @@
 
   if (info.pl_flags & PL_FLAG_SI) {
 assert(info.pl_siginfo.si_signo == SIGTRAP);
+LLDB_LOG(log, "SIGTRAP siginfo: si_code = {0}, pid = {1}",
+ info.pl_siginfo.si_code, info.pl_siginfo.si_pid);
 
 switch (info.pl_siginfo.si_code) {
 case TRAP_BRKPT:
@@ -248,7 +251,7 @@
 FixupBreakpointPCAsNeeded(*thread);
   }
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 case TRAP_TRACE:
   if (thread) {
 auto ®ctx = static_cast(
@@ -272,9 +275,14 @@
   }
 
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 }
   }
+
+  // Either user-generated SIGTRAP or an unknown event that would
+  // otherwise leave the debugger hanging.
+  LLDB_LOG(log, "unknown SIGTRAP, passing to generic handler");
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-10 Thread Nathan James via Phabricator via lldb-commits
njames93 added a comment.

An example of this in action is D91149 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

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


[Lldb-commits] [PATCH] D91032: [lldb] [Process/FreeBSDRemote] Explicitly copy dbregs to new threads

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 304138.
mgorny added a comment.

clang-format


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

https://reviews.llvm.org/D91032

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
  
lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py

Index: lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
===
--- lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
+++ lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
@@ -22,7 +22,6 @@
 """Test that we can hit a watchpoint we set before starting another thread"""
 self.do_watchpoint_test("Before running the thread")
 
-@expectedFailureAll(oslist=["freebsd"])
 def test_watchpoint_after_thread_launch(self):
 """Test that we can hit a watchpoint we set after launching another thread"""
 self.do_watchpoint_test("After launching the thread")
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -64,7 +64,7 @@
   void SetRunning();
   void SetStepping();
 
-  Status CopyWatchpointsFrom(NativeThreadFreeBSD &source);
+  llvm::Error CopyWatchpointsFrom(NativeThreadFreeBSD &source);
 
   // Member Variables
   lldb::StateType m_state;
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -165,14 +165,14 @@
 }
 if (error != 0) {
   len = 0;
-  LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}", GetID(),
-   m_state, strerror(errno));
+  LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}",
+   GetID(), m_state, strerror(errno));
 }
 kp.resize(len / sizeof(struct kinfo_proc));
 break;
   }
 
-  for (auto& procinfo : kp) {
+  for (auto &procinfo : kp) {
 if (procinfo.ki_tid == static_cast(GetID()))
   return procinfo.ki_tdname;
   }
@@ -273,3 +273,14 @@
 
   return Status("Clearing hardware breakpoint failed.");
 }
+
+llvm::Error
+NativeThreadFreeBSD::CopyWatchpointsFrom(NativeThreadFreeBSD &source) {
+  llvm::Error s = GetRegisterContext().CopyHardwareWatchpointsFrom(
+  source.GetRegisterContext());
+  if (!s) {
+m_watchpoint_index_map = source.m_watchpoint_index_map;
+m_hw_break_index_map = source.m_hw_break_index_map;
+  }
+  return s;
+}
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
@@ -50,6 +50,9 @@
 
   Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
 
+  llvm::Error
+  CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD &source) override;
+
 private:
   // Private member types.
   enum { GPRegSet, FPRegSet, XSaveRegSet, DBRegSet };
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -1169,4 +1169,19 @@
   }
 }
 
+llvm::Error NativeRegisterContextFreeBSD_x86_64::CopyHardwareWatchpointsFrom(
+NativeRegisterContextFreeBSD &source) {
+  auto &r_source = static_cast(source);
+  Status res = r_source.ReadRegisterSet(DBRegSet);
+  if (!res.Fail()) {
+// copy dbregs only if any watchpoints were set
+if ((r_source.m_dbr.dr[7] & 0xFF) == 0)
+  return llvm::Error::success();
+
+m_dbr = r_source.m_dbr;
+res = WriteRegisterSet(DBRegSet);
+  }
+  return res.ToError();
+}
+
 #endif // defined(__x86_64__)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
+++ lldb/source/Plugins/Pr

[Lldb-commits] [PATCH] D91032: [lldb] [Process/FreeBSDRemote] Explicitly copy dbregs to new threads

2020-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:214
+  llvm::Error error = t.CopyWatchpointsFrom(
+  static_cast(*GetCurrentThread()));
+  if (error) {

maybe this cast could be inside `GetCurrentThread`? Linux has it that way...


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

https://reviews.llvm.org/D91032

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


[Lldb-commits] [PATCH] D91032: [lldb] [Process/FreeBSDRemote] Explicitly copy dbregs to new threads

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:214
+  llvm::Error error = t.CopyWatchpointsFrom(
+  static_cast(*GetCurrentThread()));
+  if (error) {

labath wrote:
> maybe this cast could be inside `GetCurrentThread`? Linux has it that way...
I suppose that makes sense. I'll try it in a followup commit.


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

https://reviews.llvm.org/D91032

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


[Lldb-commits] [PATCH] D91076: [lldb] [Process/FreeBSDRemote] Correct DS/ES/FS/GS register sizes

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG194c5accb2be: [lldb] [Process/FreeBSDRemote] Correct 
DS/ES/FS/GS register sizes (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91076

Files:
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp


Index: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
===
--- 
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -595,19 +595,19 @@
 reg_value = (uint64_t)m_gpr.r_cs;
 break;
   case lldb_fs_x86_64:
-reg_value = (uint64_t)m_gpr.r_fs;
+reg_value = (uint16_t)m_gpr.r_fs;
 break;
   case lldb_gs_x86_64:
-reg_value = (uint64_t)m_gpr.r_gs;
+reg_value = (uint16_t)m_gpr.r_gs;
 break;
   case lldb_ss_x86_64:
 reg_value = (uint64_t)m_gpr.r_ss;
 break;
   case lldb_ds_x86_64:
-reg_value = (uint64_t)m_gpr.r_ds;
+reg_value = (uint16_t)m_gpr.r_ds;
 break;
   case lldb_es_x86_64:
-reg_value = (uint64_t)m_gpr.r_es;
+reg_value = (uint16_t)m_gpr.r_es;
 break;
 #else
   case lldb_rax_x86_64:
@@ -644,19 +644,19 @@
 reg_value = (uint32_t)m_gpr.r_cs;
 break;
   case lldb_fs_x86_64:
-reg_value = (uint32_t)m_gpr.r_fs;
+reg_value = (uint16_t)m_gpr.r_fs;
 break;
   case lldb_gs_x86_64:
-reg_value = (uint32_t)m_gpr.r_gs;
+reg_value = (uint16_t)m_gpr.r_gs;
 break;
   case lldb_ss_x86_64:
 reg_value = (uint32_t)m_gpr.r_ss;
 break;
   case lldb_ds_x86_64:
-reg_value = (uint32_t)m_gpr.r_ds;
+reg_value = (uint16_t)m_gpr.r_ds;
 break;
   case lldb_es_x86_64:
-reg_value = (uint32_t)m_gpr.r_es;
+reg_value = (uint16_t)m_gpr.r_es;
 break;
 #endif
 #if defined(__x86_64__)
@@ -905,19 +905,19 @@
 m_gpr.r_cs = reg_value.GetAsUInt64();
 break;
   case lldb_fs_x86_64:
-m_gpr.r_fs = reg_value.GetAsUInt64();
+m_gpr.r_fs = reg_value.GetAsUInt16();
 break;
   case lldb_gs_x86_64:
-m_gpr.r_gs = reg_value.GetAsUInt64();
+m_gpr.r_gs = reg_value.GetAsUInt16();
 break;
   case lldb_ss_x86_64:
 m_gpr.r_ss = reg_value.GetAsUInt64();
 break;
   case lldb_ds_x86_64:
-m_gpr.r_ds = reg_value.GetAsUInt64();
+m_gpr.r_ds = reg_value.GetAsUInt16();
 break;
   case lldb_es_x86_64:
-m_gpr.r_es = reg_value.GetAsUInt64();
+m_gpr.r_es = reg_value.GetAsUInt16();
 break;
 #else
   case lldb_rax_x86_64:
@@ -954,19 +954,19 @@
 m_gpr.r_cs = reg_value.GetAsUInt32();
 break;
   case lldb_fs_x86_64:
-m_gpr.r_fs = reg_value.GetAsUInt32();
+m_gpr.r_fs = reg_value.GetAsUInt16();
 break;
   case lldb_gs_x86_64:
-m_gpr.r_gs = reg_value.GetAsUInt32();
+m_gpr.r_gs = reg_value.GetAsUInt16();
 break;
   case lldb_ss_x86_64:
 m_gpr.r_ss = reg_value.GetAsUInt32();
 break;
   case lldb_ds_x86_64:
-m_gpr.r_ds = reg_value.GetAsUInt32();
+m_gpr.r_ds = reg_value.GetAsUInt16();
 break;
   case lldb_es_x86_64:
-m_gpr.r_es = reg_value.GetAsUInt32();
+m_gpr.r_es = reg_value.GetAsUInt16();
 break;
 #endif
   case lldb_fctrl_x86_64:


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -595,19 +595,19 @@
 reg_value = (uint64_t)m_gpr.r_cs;
 break;
   case lldb_fs_x86_64:
-reg_value = (uint64_t)m_gpr.r_fs;
+reg_value = (uint16_t)m_gpr.r_fs;
 break;
   case lldb_gs_x86_64:
-reg_value = (uint64_t)m_gpr.r_gs;
+reg_value = (uint16_t)m_gpr.r_gs;
 break;
   case lldb_ss_x86_64:
 reg_value = (uint64_t)m_gpr.r_ss;
 break;
   case lldb_ds_x86_64:
-reg_value = (uint64_t)m_gpr.r_ds;
+reg_value = (uint16_t)m_gpr.r_ds;
 break;
   case lldb_es_x86_64:
-reg_value = (uint64_t)m_gpr.r_es;
+reg_value = (uint16_t)m_gpr.r_es;
 break;
 #else
   case lldb_rax_x86_64:
@@ -644,19 +644,19 @@
 reg_value = (uint32_t)m_gpr.r_cs;
 break;
   case lldb_fs_x86_64:
-reg_value = (uint32_t)m_gpr.r_fs;
+reg_value = (uint16_t)m_gpr.r_fs;
 break;
   case lldb_gs_x86_64:
-reg_value = (uint32_t)m_gpr.r_gs;
+reg_value = (uint16_t)m_gpr.r_gs;
 break;
   case lldb_ss_x86_64:
 reg_value = (uint32_t)m_gpr.r_ss;
 break;
   case lldb_ds_x86_64:
-reg_value = (uint32_t)m_gpr.r_ds;
+reg_value = (uint16_t)m_gpr.r_ds;
 break;
   case lldb_es_x86_64:
-reg_value = (uint32_t)m_gpr.r_es;
+reg_value = (uint16_t)m_gpr.r_es;
 break;
 #endif
 

[Lldb-commits] [lldb] e637602 - [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP

2020-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-11-10T14:18:03+01:00
New Revision: e637602e7ac9bb5721dbe079fa783cee891139b4

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

LOG: [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP

Update the SIGTRAP handler to account for the possibility of SIGTRAP
being generated by the user, i.e. not having any specific debugging
event associated with it, as well as receiving unknown SIGTRAPs.  These
instances of SIGTRAP are passed to the regular signal handler.

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

Added: 


Modified: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
lldb/test/API/functionalities/signal/raise/TestRaise.py

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
index 5c10c9c8cd07..8f0936c169b9 100644
--- a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -192,7 +192,8 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
   }
   assert(info.pl_event == PL_EVENT_SIGNAL);
 
-  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}", pid, info.pl_lwpid);
+  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, flags = {2:x}", pid,
+   info.pl_lwpid, info.pl_flags);
   NativeThreadFreeBSD *thread = nullptr;
 
   if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
@@ -240,6 +241,8 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
 
   if (info.pl_flags & PL_FLAG_SI) {
 assert(info.pl_siginfo.si_signo == SIGTRAP);
+LLDB_LOG(log, "SIGTRAP siginfo: si_code = {0}, pid = {1}",
+ info.pl_siginfo.si_code, info.pl_siginfo.si_pid);
 
 switch (info.pl_siginfo.si_code) {
 case TRAP_BRKPT:
@@ -248,7 +251,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
 FixupBreakpointPCAsNeeded(*thread);
   }
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 case TRAP_TRACE:
   if (thread) {
 auto ®ctx = static_cast(
@@ -272,9 +275,14 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) 
{
   }
 
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 }
   }
+
+  // Either user-generated SIGTRAP or an unknown event that would
+  // otherwise leave the debugger hanging.
+  LLDB_LOG(log, "unknown SIGTRAP, passing to generic handler");
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {

diff  --git a/lldb/test/API/functionalities/signal/raise/TestRaise.py 
b/lldb/test/API/functionalities/signal/raise/TestRaise.py
index 93df3b1f93a9..70271e43cff5 100644
--- a/lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ b/lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -30,7 +30,6 @@ def test_sigsigrtmin(self):
 self.signal_test('SIGRTMIN', True)
 
 @skipIfNetBSD  # Hangs on NetBSD
-@skipIfFreeBSD  # hangs
 def test_sigtrap(self):
 self.build()
 self.signal_test('SIGTRAP', True)



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


[Lldb-commits] [PATCH] D91007: [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe637602e7ac9: [lldb] [Process/FreeBSDRemote] Fix handling 
user-generated SIGTRAP (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91007

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/test/API/functionalities/signal/raise/TestRaise.py


Index: lldb/test/API/functionalities/signal/raise/TestRaise.py
===
--- lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -30,7 +30,6 @@
 self.signal_test('SIGRTMIN', True)
 
 @skipIfNetBSD  # Hangs on NetBSD
-@skipIfFreeBSD  # hangs
 def test_sigtrap(self):
 self.build()
 self.signal_test('SIGTRAP', True)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -192,7 +192,8 @@
   }
   assert(info.pl_event == PL_EVENT_SIGNAL);
 
-  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}", pid, info.pl_lwpid);
+  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, flags = {2:x}", pid,
+   info.pl_lwpid, info.pl_flags);
   NativeThreadFreeBSD *thread = nullptr;
 
   if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
@@ -240,6 +241,8 @@
 
   if (info.pl_flags & PL_FLAG_SI) {
 assert(info.pl_siginfo.si_signo == SIGTRAP);
+LLDB_LOG(log, "SIGTRAP siginfo: si_code = {0}, pid = {1}",
+ info.pl_siginfo.si_code, info.pl_siginfo.si_pid);
 
 switch (info.pl_siginfo.si_code) {
 case TRAP_BRKPT:
@@ -248,7 +251,7 @@
 FixupBreakpointPCAsNeeded(*thread);
   }
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 case TRAP_TRACE:
   if (thread) {
 auto ®ctx = static_cast(
@@ -272,9 +275,14 @@
   }
 
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 }
   }
+
+  // Either user-generated SIGTRAP or an unknown event that would
+  // otherwise leave the debugger hanging.
+  LLDB_LOG(log, "unknown SIGTRAP, passing to generic handler");
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {


Index: lldb/test/API/functionalities/signal/raise/TestRaise.py
===
--- lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -30,7 +30,6 @@
 self.signal_test('SIGRTMIN', True)
 
 @skipIfNetBSD  # Hangs on NetBSD
-@skipIfFreeBSD  # hangs
 def test_sigtrap(self):
 self.build()
 self.signal_test('SIGTRAP', True)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -192,7 +192,8 @@
   }
   assert(info.pl_event == PL_EVENT_SIGNAL);
 
-  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}", pid, info.pl_lwpid);
+  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, flags = {2:x}", pid,
+   info.pl_lwpid, info.pl_flags);
   NativeThreadFreeBSD *thread = nullptr;
 
   if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
@@ -240,6 +241,8 @@
 
   if (info.pl_flags & PL_FLAG_SI) {
 assert(info.pl_siginfo.si_signo == SIGTRAP);
+LLDB_LOG(log, "SIGTRAP siginfo: si_code = {0}, pid = {1}",
+ info.pl_siginfo.si_code, info.pl_siginfo.si_pid);
 
 switch (info.pl_siginfo.si_code) {
 case TRAP_BRKPT:
@@ -248,7 +251,7 @@
 FixupBreakpointPCAsNeeded(*thread);
   }
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 case TRAP_TRACE:
   if (thread) {
 auto ®ctx = static_cast(
@@ -272,9 +275,14 @@
   }
 
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 }
   }
+
+  // Either user-generated SIGTRAP or an unknown event that would
+  // otherwise leave the debugger hanging.
+  LLDB_LOG(log, "unknown SIGTRAP, passing to generic handler");
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4c54399 - [lldb] [Process/FreeBSDRemote] Explicitly copy dbregs to new threads

2020-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-11-10T14:18:03+01:00
New Revision: 4c54399b7eaa487e91c32a0d9c2537611c25aee7

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

LOG: [lldb] [Process/FreeBSDRemote] Explicitly copy dbregs to new threads

Explicitly copy dbregs to new threads to ensure that watchpoints
are propagated properly.  Fixes the test failure due to apparent kernel
race between reporting a new thread and resuming main thread execution
that makes implicit inheritance of dbregs unreliable.  By copying them
explicitly, we ensure that the new thread correctly respects watchpoints
that were set after the thread was created but before it was reported.

The code is copied from the NetBSD plugin and modernized to use
llvm::Error.

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

Added: 


Modified: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h

lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
index 8f0936c169b9..fd3c05ab411e 100644
--- a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -199,7 +199,25 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) 
{
   if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
 if (info.pl_flags & PL_FLAG_BORN) {
   LLDB_LOG(log, "monitoring new thread, tid = {0}", info.pl_lwpid);
-  AddThread(info.pl_lwpid);
+  NativeThreadFreeBSD &t = AddThread(info.pl_lwpid);
+
+  // Technically, the FreeBSD kernel copies the debug registers to new
+  // threads.  However, there is a non-negligible delay between acquiring
+  // the DR values and reporting the new thread during which the user may
+  // establish a new watchpoint.  In order to ensure that watchpoints
+  // established during this period are propagated to new threads,
+  // explicitly copy the DR value at the time the new thread is reported.
+  //
+  // See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250954
+
+  llvm::Error error = t.CopyWatchpointsFrom(
+  static_cast(*GetCurrentThread()));
+  if (error) {
+LLDB_LOG(log, "failed to copy watchpoints to new thread {0}: {1}",
+ info.pl_lwpid, llvm::toString(std::move(error)));
+SetState(StateType::eStateInvalid);
+return;
+  }
 } else /*if (info.pl_flags & PL_FLAG_EXITED)*/ {
   LLDB_LOG(log, "thread exited, tid = {0}", info.pl_lwpid);
   RemoveThread(info.pl_lwpid);

diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
index 47201cf16777..484beac9 100644
--- a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
@@ -29,6 +29,8 @@ class NativeRegisterContextFreeBSD
   static NativeRegisterContextFreeBSD *
   CreateHostNativeRegisterContextFreeBSD(const ArchSpec &target_arch,
  NativeThreadProtocol &native_thread);
+  virtual llvm::Error
+  CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD &source) = 0;
 
 protected:
   virtual NativeProcessFreeBSD &GetProcess();

diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
index 4e0fb280ceff..fc1ef0381f78 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -1169,4 +1169,19 @@ int NativeRegisterContextFreeBSD_x86_64::GetDR(int num) 
const {
   }
 }
 
+llvm::Error NativeRegisterContextFreeBSD_x86_64::CopyHardwareWatchpointsFrom(
+NativeRegisterContextFreeBSD &source) {
+  auto &r_source = static_cast(source);
+  Status res = r_source.ReadRegisterSet(DBRegSet);
+  if (!res.Fail()) {
+// copy dbregs only if any watchpoints were set
+if ((r_source.m_dbr.dr[7] & 0xFF) == 0)
+  return llvm::Error::success();
+
+m_dbr = r_source.m_dbr;
+ 

[Lldb-commits] [PATCH] D91032: [lldb] [Process/FreeBSDRemote] Explicitly copy dbregs to new threads

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c54399b7eaa: [lldb] [Process/FreeBSDRemote] Explicitly copy 
dbregs to new threads (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91032

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
  
lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py

Index: lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
===
--- lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
+++ lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
@@ -22,7 +22,6 @@
 """Test that we can hit a watchpoint we set before starting another thread"""
 self.do_watchpoint_test("Before running the thread")
 
-@expectedFailureAll(oslist=["freebsd"])
 def test_watchpoint_after_thread_launch(self):
 """Test that we can hit a watchpoint we set after launching another thread"""
 self.do_watchpoint_test("After launching the thread")
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -64,7 +64,7 @@
   void SetRunning();
   void SetStepping();
 
-  Status CopyWatchpointsFrom(NativeThreadFreeBSD &source);
+  llvm::Error CopyWatchpointsFrom(NativeThreadFreeBSD &source);
 
   // Member Variables
   lldb::StateType m_state;
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -165,14 +165,14 @@
 }
 if (error != 0) {
   len = 0;
-  LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}", GetID(),
-   m_state, strerror(errno));
+  LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}",
+   GetID(), m_state, strerror(errno));
 }
 kp.resize(len / sizeof(struct kinfo_proc));
 break;
   }
 
-  for (auto& procinfo : kp) {
+  for (auto &procinfo : kp) {
 if (procinfo.ki_tid == static_cast(GetID()))
   return procinfo.ki_tdname;
   }
@@ -273,3 +273,14 @@
 
   return Status("Clearing hardware breakpoint failed.");
 }
+
+llvm::Error
+NativeThreadFreeBSD::CopyWatchpointsFrom(NativeThreadFreeBSD &source) {
+  llvm::Error s = GetRegisterContext().CopyHardwareWatchpointsFrom(
+  source.GetRegisterContext());
+  if (!s) {
+m_watchpoint_index_map = source.m_watchpoint_index_map;
+m_hw_break_index_map = source.m_hw_break_index_map;
+  }
+  return s;
+}
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
@@ -50,6 +50,9 @@
 
   Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
 
+  llvm::Error
+  CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD &source) override;
+
 private:
   // Private member types.
   enum { GPRegSet, FPRegSet, XSaveRegSet, DBRegSet };
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -1169,4 +1169,19 @@
   }
 }
 
+llvm::Error NativeRegisterContextFreeBSD_x86_64::CopyHardwareWatchpointsFrom(
+NativeRegisterContextFreeBSD &source) {
+  auto &r_source = static_cast(source);
+  Status res = r_source.ReadRegisterSet(DBRegSet);
+  if (!res.Fail()) {
+// copy dbregs only if any watchpoints were set
+if ((r_source.m_dbr.dr[7] & 0xFF) == 0)
+  return llvm::Error::success();
+
+m_dbr = r_source.m_dbr;
+res = WriteRegisterSet(DBRegSet);
+  }
+  return res.ToError();
+}
+
 #endif // defined(__x86_64__)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterCont

[Lldb-commits] [lldb] 194c5ac - [lldb] [Process/FreeBSDRemote] Correct DS/ES/FS/GS register sizes

2020-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-11-10T14:18:03+01:00
New Revision: 194c5accb2be0dab75085f8f5c9c488d1cee7606

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

LOG: [lldb] [Process/FreeBSDRemote] Correct DS/ES/FS/GS register sizes

Fix DS/ES/FS/GS register sizes in getter/setter for FreeBSD.  Apparently
only CS and SS registers are specified as 64/32-bit in LLDB, while
the others are specified as 16-bit.  This fixes the failing
StandardStartupTest.TestStopReplyContainsThreadPcs lldb-server unittest.

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

Added: 


Modified: 

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
index 8a58e8ff2181..4e0fb280ceff 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -595,19 +595,19 @@ NativeRegisterContextFreeBSD_x86_64::ReadRegister(const 
RegisterInfo *reg_info,
 reg_value = (uint64_t)m_gpr.r_cs;
 break;
   case lldb_fs_x86_64:
-reg_value = (uint64_t)m_gpr.r_fs;
+reg_value = (uint16_t)m_gpr.r_fs;
 break;
   case lldb_gs_x86_64:
-reg_value = (uint64_t)m_gpr.r_gs;
+reg_value = (uint16_t)m_gpr.r_gs;
 break;
   case lldb_ss_x86_64:
 reg_value = (uint64_t)m_gpr.r_ss;
 break;
   case lldb_ds_x86_64:
-reg_value = (uint64_t)m_gpr.r_ds;
+reg_value = (uint16_t)m_gpr.r_ds;
 break;
   case lldb_es_x86_64:
-reg_value = (uint64_t)m_gpr.r_es;
+reg_value = (uint16_t)m_gpr.r_es;
 break;
 #else
   case lldb_rax_x86_64:
@@ -644,19 +644,19 @@ NativeRegisterContextFreeBSD_x86_64::ReadRegister(const 
RegisterInfo *reg_info,
 reg_value = (uint32_t)m_gpr.r_cs;
 break;
   case lldb_fs_x86_64:
-reg_value = (uint32_t)m_gpr.r_fs;
+reg_value = (uint16_t)m_gpr.r_fs;
 break;
   case lldb_gs_x86_64:
-reg_value = (uint32_t)m_gpr.r_gs;
+reg_value = (uint16_t)m_gpr.r_gs;
 break;
   case lldb_ss_x86_64:
 reg_value = (uint32_t)m_gpr.r_ss;
 break;
   case lldb_ds_x86_64:
-reg_value = (uint32_t)m_gpr.r_ds;
+reg_value = (uint16_t)m_gpr.r_ds;
 break;
   case lldb_es_x86_64:
-reg_value = (uint32_t)m_gpr.r_es;
+reg_value = (uint16_t)m_gpr.r_es;
 break;
 #endif
 #if defined(__x86_64__)
@@ -905,19 +905,19 @@ Status NativeRegisterContextFreeBSD_x86_64::WriteRegister(
 m_gpr.r_cs = reg_value.GetAsUInt64();
 break;
   case lldb_fs_x86_64:
-m_gpr.r_fs = reg_value.GetAsUInt64();
+m_gpr.r_fs = reg_value.GetAsUInt16();
 break;
   case lldb_gs_x86_64:
-m_gpr.r_gs = reg_value.GetAsUInt64();
+m_gpr.r_gs = reg_value.GetAsUInt16();
 break;
   case lldb_ss_x86_64:
 m_gpr.r_ss = reg_value.GetAsUInt64();
 break;
   case lldb_ds_x86_64:
-m_gpr.r_ds = reg_value.GetAsUInt64();
+m_gpr.r_ds = reg_value.GetAsUInt16();
 break;
   case lldb_es_x86_64:
-m_gpr.r_es = reg_value.GetAsUInt64();
+m_gpr.r_es = reg_value.GetAsUInt16();
 break;
 #else
   case lldb_rax_x86_64:
@@ -954,19 +954,19 @@ Status NativeRegisterContextFreeBSD_x86_64::WriteRegister(
 m_gpr.r_cs = reg_value.GetAsUInt32();
 break;
   case lldb_fs_x86_64:
-m_gpr.r_fs = reg_value.GetAsUInt32();
+m_gpr.r_fs = reg_value.GetAsUInt16();
 break;
   case lldb_gs_x86_64:
-m_gpr.r_gs = reg_value.GetAsUInt32();
+m_gpr.r_gs = reg_value.GetAsUInt16();
 break;
   case lldb_ss_x86_64:
 m_gpr.r_ss = reg_value.GetAsUInt32();
 break;
   case lldb_ds_x86_64:
-m_gpr.r_ds = reg_value.GetAsUInt32();
+m_gpr.r_ds = reg_value.GetAsUInt16();
 break;
   case lldb_es_x86_64:
-m_gpr.r_es = reg_value.GetAsUInt32();
+m_gpr.r_es = reg_value.GetAsUInt16();
 break;
 #endif
   case lldb_fctrl_x86_64:



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


[Lldb-commits] [PATCH] D91032: [lldb] [Process/FreeBSDRemote] Explicitly copy dbregs to new threads

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:214
+  llvm::Error error = t.CopyWatchpointsFrom(
+  static_cast(*GetCurrentThread()));
+  if (error) {

mgorny wrote:
> labath wrote:
> > maybe this cast could be inside `GetCurrentThread`? Linux has it that way...
> I suppose that makes sense. I'll try it in a followup commit.
Actually, we're using this method exactly once, so I don't think it makes sense 
at this point. However, I'll keep it in mind in case it becomes used more 
frequently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91032

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


[Lldb-commits] [PATCH] D90490: [intel-pt][trace] Implement a "get supported trace type" packet

2020-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/docs/lldb-gdb-remote.txt:262
+send packet: jLLDBTraceSupportedType
+read packet: {"name": , "description", }/E
+

clayborg wrote:
> I know the deprecated trace packets allows an error code to be returned, but 
> since we already have JSON being used here, I would be a shame to not return 
> an error in the JSON with a string that is human readable instead of a EXX 
> where XX are two hex digits. can we say the response is either:
> ```
> {"name": , "description", }
> ```
> or
> ```
> {"error": }
> ```
> Or just have no error code? What would the error be able to tell us?
An error response might be suitable in case the client sends this packet 
without a running process.

I think we just stick to the established error code format, which already 
contains provisions for returning textual errors. I don't believe any of our 
existing json packets use json-encoded errors...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90490

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


[Lldb-commits] [PATCH] D90987: [lldb] Avoid confusing crashes during reproducer replay when initialization failed

2020-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D90987#2383141 , @JDevlieghere 
wrote:

> In D90987#2381853 , @labath wrote:
>
>> I wonder if there's a way to add some consistency checks into the (active) 
>> replay machinery. Like, maybe we could, for each function that returns an 
>> SBError, record a flag saying whether that error was in a success state or 
>> not. Then if this flag differs during replay, we know that we have started 
>> to diverge and can stop replaying (or at least give a very loud warning 
>> about it).
>
> On the one hand I like the idea of detecting divergence early, but on the 
> other hand I don't like special-casing something for SBError. There's a bunch 
> of function that return a boolean and some that got error handling after the 
> fact through and overload with an in-out parameter. A more generic approach 
> could be a way to checkpoint the "object registry" an give (some of) the SB 
> classes a private method that returns a "hash" (whatever that means for the 
> reproducers, for an SBError that could be success or not, but for a target or 
> a process it could be whether it's connected) and then have the reproducers 
> periodically compare the state of the registry against that in the reproducer.

I like that idea.




Comment at: lldb/source/API/SystemInitializerFull.cpp:46
+if (repro::Reproducer::Instance().IsReplaying())
+  std::_Exit(EXIT_FAILURE);
+return error;

labath wrote:
> Print the error that has happened? maybe via `report_fatal_error` ?
Btw, there's a new report_fatal_error overload taking an llvm::Error -- I meant 
to use that one :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90987

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


[Lldb-commits] [lldb] c50faf5 - [lldb] Fix TestErrorMessages test on standalone builds by adding lldb-server substitution

2020-11-10 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-11-10T15:26:19+01:00
New Revision: c50faf5c9d7ca7a62cd59516c7de305b73f2455c

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

LOG: [lldb] Fix TestErrorMessages test on standalone builds by adding 
lldb-server substitution

It seems that TestErrorMessages.test is failing on the standalone + Xcode builds
as lldb-server executable can't be found by lit's default PATH search. I assume
invoking lldb-server via a lit substitution gets this working again as
everything else is working, so that's what this patch is doing.

I had to add the lldb-server substitution as the test seems lldb-server specific
and we don't want it to default to debugserver on Darwin.

Using a substitution also seems in general like a good idea so that the commands
lit is printing on failure are using the full path to lldb-server and can be
re-run in a terminal.

Reviewed By: labath

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

Added: 


Modified: 
lldb/test/Shell/helper/toolchain.py
lldb/test/Shell/lldb-server/TestErrorMessages.test

Removed: 




diff  --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index 9b85da01f822..c7374e06c272 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -54,6 +54,10 @@ def use_lldb_substitutions(config):
   command=FindTool('lldb'),
   extra_args=['-S', lldb_init],
   unresolved='fatal'),
+ToolSubst('%lldb-server',
+  command=FindTool("lldb-server"),
+  extra_args=[],
+  unresolved='ignore'),
 ToolSubst('%debugserver',
   command=FindTool(dsname),
   extra_args=dsargs,

diff  --git a/lldb/test/Shell/lldb-server/TestErrorMessages.test 
b/lldb/test/Shell/lldb-server/TestErrorMessages.test
index ef64ec6e5aba..b9689fb1e467 100644
--- a/lldb/test/Shell/lldb-server/TestErrorMessages.test
+++ b/lldb/test/Shell/lldb-server/TestErrorMessages.test
@@ -1,13 +1,13 @@
-RUN: lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
+RUN: %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
 FD1: error: --fd: missing argument
 
-RUN: lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,ALL %s
+RUN: %lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,ALL %s
 FD2: error: invalid '--fd' argument
 
-RUN: lldb-server gdbserver --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,ALL 
%s
+RUN: %lldb-server gdbserver --bogus 2>&1 | FileCheck 
--check-prefixes=BOGUS,ALL %s
 BOGUS: error: unknown argument '--bogus'
 
-RUN: lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
+RUN: %lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
 CONN: error: no connection arguments
 
 ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.



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


[Lldb-commits] [PATCH] D91155: [lldb] Fix TestErrorMessages test on standalone builds by adding lldb-server substitution

2020-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc50faf5c9d7c: [lldb] Fix TestErrorMessages test on 
standalone builds by adding lldb-server… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91155

Files:
  lldb/test/Shell/helper/toolchain.py
  lldb/test/Shell/lldb-server/TestErrorMessages.test


Index: lldb/test/Shell/lldb-server/TestErrorMessages.test
===
--- lldb/test/Shell/lldb-server/TestErrorMessages.test
+++ lldb/test/Shell/lldb-server/TestErrorMessages.test
@@ -1,13 +1,13 @@
-RUN: lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
+RUN: %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
 FD1: error: --fd: missing argument
 
-RUN: lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,ALL %s
+RUN: %lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,ALL %s
 FD2: error: invalid '--fd' argument
 
-RUN: lldb-server gdbserver --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,ALL 
%s
+RUN: %lldb-server gdbserver --bogus 2>&1 | FileCheck 
--check-prefixes=BOGUS,ALL %s
 BOGUS: error: unknown argument '--bogus'
 
-RUN: lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
+RUN: %lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
 CONN: error: no connection arguments
 
 ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -54,6 +54,10 @@
   command=FindTool('lldb'),
   extra_args=['-S', lldb_init],
   unresolved='fatal'),
+ToolSubst('%lldb-server',
+  command=FindTool("lldb-server"),
+  extra_args=[],
+  unresolved='ignore'),
 ToolSubst('%debugserver',
   command=FindTool(dsname),
   extra_args=dsargs,


Index: lldb/test/Shell/lldb-server/TestErrorMessages.test
===
--- lldb/test/Shell/lldb-server/TestErrorMessages.test
+++ lldb/test/Shell/lldb-server/TestErrorMessages.test
@@ -1,13 +1,13 @@
-RUN: lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
+RUN: %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
 FD1: error: --fd: missing argument
 
-RUN: lldb-server gdbserver --fd three 2>&1 | FileCheck --check-prefixes=FD2,ALL %s
+RUN: %lldb-server gdbserver --fd three 2>&1 | FileCheck --check-prefixes=FD2,ALL %s
 FD2: error: invalid '--fd' argument
 
-RUN: lldb-server gdbserver --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,ALL %s
+RUN: %lldb-server gdbserver --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,ALL %s
 BOGUS: error: unknown argument '--bogus'
 
-RUN: lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
+RUN: %lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
 CONN: error: no connection arguments
 
 ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -54,6 +54,10 @@
   command=FindTool('lldb'),
   extra_args=['-S', lldb_init],
   unresolved='fatal'),
+ToolSubst('%lldb-server',
+  command=FindTool("lldb-server"),
+  extra_args=[],
+  unresolved='ignore'),
 ToolSubst('%debugserver',
   command=FindTool(dsname),
   extra_args=dsargs,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 9b0578d - [lldb] Reinstate TestGdbserverPort.test

2020-11-10 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-11-10T15:51:15+01:00
New Revision: 9b0578d54631b763a3af26bb3a94cad3b0fc220e

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

LOG: [lldb] Reinstate TestGdbserverPort.test

This test was deleted by accident in the great lldb-mi removal:
37fed664022e07c2293b674e9c9d2b50aac547ba

Added: 
lldb/test/Shell/lldb-server/TestGdbserverPort.test

Modified: 


Removed: 




diff  --git a/lldb/test/Shell/lldb-server/TestGdbserverPort.test 
b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
new file mode 100644
index ..04facfec831c
--- /dev/null
+++ b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
@@ -0,0 +1,4 @@
+# Windows does not build lldb-server.
+# UNSUPPORTED: system-windows
+# RUN: %platformserver --server --listen :1234 --min-gdbserver-port 1234 
--max-gdbserver-port 1234 2>&1 | FileCheck %s
+# CHECK: error: --min-gdbserver-port (1234) is not lower than 
--max-gdbserver-port (1234)



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


[Lldb-commits] [PATCH] D91155: [lldb] Fix TestErrorMessages test on standalone builds by adding lldb-server substitution

2020-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: lldb/test/Shell/helper/toolchain.py:65-68
 ToolSubst('%platformserver',
   command=FindTool('lldb-server'),
   extra_args=['platform'],
   unresolved='ignore'),

labath wrote:
> I guess we don't need this then, as one can just write `%lldb-server 
> platform`. It also seems to be unused.
It seems the test that was using this substitution was accidentally deleted in 
the lldb-mi removal, so I reinstated that test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91155

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


[Lldb-commits] [PATCH] D82863: [LLDB] Add support to resize SVE registers at run-time

2020-11-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D82863#2375525 , @omjavaid wrote:

> GDB does not have pseudo registers as part of xml register description. GDB 
> is managing pseudo registers on client side and independent of rest of the 
> register set. In case of SVE Z registers, GDB describes a composite type kind 
> of a union of (Z, V, D and S) which helps in giving registers a view in terms 
> of V, S and D which are not actually register.
>
> As invalidate_regs and value_regs are totally LLDB specific so we can put 
> information about LLDB speicific pseudo registers in those lists which we 
> actually do by the way. Taking advantage of that I have S, V and D registers 
> in invalidate_reg list of a Z register which share the same starting offset 
> as the corresponding Z register but are size restricted to 4, 8 or 16 bytes.
>
> For the sake of clarity here is the scheme:
>
> We have two types of registers:
>
> 1. Primary registers
>
> Includes 64 bit GPRs Xn regs, PC etc
> Also includes V registers for all non-sve targets
> Includes Z, P, FFR and VG for SVE targets.
>
> All primary registers have value_regs list set to nullptr
> All primary registers have invalidate_regs list which is a list of registers 
> which share same starting offset as the corresponding primary registers.
>
> 2. Pseudo registers
>
> Includes 32 bit GPRs Wn regs
> Includes D and S registers for all non SVE targets
> Also includes V, D and S registers for all SVE targets
>
> All pseudo register have a value register which can be found in value_regs 
> list of that register.
> All pseudo registers have invalidate_regs list which is a list of registers 
> which share same starting offset as the corresponding primary registers.
>
> On start of debug session we exchange qRegisterInfo or target XML packet 
> registers on client side are numbered in sequence they are received in 
> qRegisterInfo or their placement location in XML description. We receive 
> register offset field populated in case we are talking to lldb-server.

Up to here, everything makes sense to me.  Thanks for summarizing that.

> This offset will be ignored in case of AArch64 target with SVE and it will be 
> recalculated in DynamicRegisterInfo::Finalize function.

Didn't we say we were going to make lldb-server stop sending offsets in the SVE 
(or even aarch64 in general) case?

> Moreover, whenever we stop we get register VG in expedited registers list. we 
> call GDBRemoteRegisterContext::AArch64SVEReconfigure function which will 
> evaluate if we need to update offsets. In case VG has been updated whole 
> register list will be traversed in sequence and new offsets will be assigned 
> according to updated register sizes.

Ideally, I'd want to structure this in a way so that it does not depend on 
whether lldb-server expedites any particular register. The idea is, that after 
every stop, the client would check the value of the VG register (and update 
stuff if it changed). If the register was expedited, then this access would be 
satisfied from the expedited cache. But if the server did not send it for any 
reason, (and this is structured correctly) the client should just transparently 
request the updated register value from the server.




Comment at: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp:543
 
+  // On AArch64 architecture with SVE support enabled we set offsets on client
+  // side based on register size and its position in m_regs.

We should already have code somewhere which sets the register offsets in case 
the server did not provide them. We should merge the two. Ideally, this 
wouldn't even require any special logic, as the server will just not send any 
offsets for SVE.



Comment at: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp:717
   m_reg_data_byte_size = 0;
+  m_per_thread_reginfo = false;
   m_finalized = false;

This fields is out of place here, as this class doesn't know anything about 
threads. I guess what it really means is "can the size of these registers be 
changed at runtime".

A natural consequence of this would then be that its users would need to keep a 
copy of each class for each thread...



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp.rej:1
+--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
 lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp

?



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp:734
 
+bool GDBRemoteRegisterContext::AArch64SVEReconfigure(void) {
+  if (!m_reg_info_sp)

`(void)` is a c-ism.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:1769-1770
+  const ArchSpec &arch = GetTarget().GetArchitecture();
+  if (arch.IsValid() && (arch.GetMachine() == llvm::Triple::aarch64 ||
+  

[Lldb-commits] [PATCH] D90840: [lldb/DWARF] Fix sizes of DW_OP_const[1248][us] and DW_OP_litN results

2020-11-10 Thread Pavel Labath 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 rG4edb7e34f824: [lldb/DWARF] Fix sizes of 
DW_OP_const[1248][us] and DW_OP_litN results (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90840

Files:
  lldb/include/lldb/Utility/Scalar.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -75,6 +75,37 @@
llvm::Failed());
 }
 
+TEST(DWARFExpression, DW_OP_const) {
+  // Extend to address size.
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1u, 0x88}), llvm::HasValue(0x88));
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1s, 0x88}),
+   llvm::HasValue(0xff88));
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x47, 0x88}),
+   llvm::HasValue(0x8847));
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2s, 0x47, 0x88}),
+   llvm::HasValue(0x8847));
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const4u, 0x44, 0x42, 0x47, 0x88}),
+   llvm::HasValue(0x88474244));
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const4s, 0x44, 0x42, 0x47, 0x88}),
+   llvm::HasValue(0x88474244));
+
+  // Truncate to address size.
+  EXPECT_THAT_EXPECTED(
+  Evaluate({DW_OP_const8u, 0x00, 0x11, 0x22, 0x33, 0x44, 0x42, 0x47, 0x88}),
+  llvm::HasValue(0x33221100));
+  EXPECT_THAT_EXPECTED(
+  Evaluate({DW_OP_const8s, 0x00, 0x11, 0x22, 0x33, 0x44, 0x42, 0x47, 0x88}),
+  llvm::HasValue(0x33221100));
+
+  // Don't truncate to address size for compatibility with clang (pr48087).
+  EXPECT_THAT_EXPECTED(
+  Evaluate({DW_OP_constu, 0x81, 0x82, 0x84, 0x88, 0x90, 0xa0, 0x40}),
+  llvm::HasValue(0x01010101010101));
+  EXPECT_THAT_EXPECTED(
+  Evaluate({DW_OP_consts, 0x81, 0x82, 0x84, 0x88, 0x90, 0xa0, 0x40}),
+  llvm::HasValue(0x010101010101));
+}
+
 TEST(DWARFExpression, DW_OP_convert) {
   /// Auxiliary debug info.
   const char *yamldata = R"(
@@ -157,22 +188,15 @@
   // Positive tests.
   //
 
-  // Truncate to default unspecified (pointer-sized) type.
-  EXPECT_THAT_EXPECTED(
-  t.Eval({DW_OP_const8u, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, //
-  DW_OP_convert, 0x00}),
-  llvm::HasValue(GetScalar(32, 0x44332211, not_signed)));
-  // Truncate to 32 bits.
-  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const8u, //
-   0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,//
+  // Leave as is.
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
DW_OP_convert, offs_uint32_t}),
-   llvm::HasValue(GetScalar(32, 0x44332211, not_signed)));
+   llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
 
-  // Leave as is.
-  EXPECT_THAT_EXPECTED(
-  t.Eval({DW_OP_const8u, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, //
-  DW_OP_convert, offs_uint64_t}),
-  llvm::HasValue(GetScalar(64, 0x8877665544332211, not_signed)));
+  // Zero-extend to 64 bits.
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
+   DW_OP_convert, offs_uint64_t}),
+   llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
 
   // Sign-extend to 64 bits.
   EXPECT_THAT_EXPECTED(
@@ -180,6 +204,18 @@
   DW_OP_convert, offs_sint64_t}),
   llvm::HasValue(GetScalar(64, 0xffeeddcc, is_signed)));
 
+  // Sign-extend, then truncate.
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
+   DW_OP_convert, offs_sint64_t,  //
+   DW_OP_convert, offs_uint32_t}),
+   llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
+
+  // Truncate to default unspecified (pointer-sized) type.
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
+   DW_OP_convert, offs_sint64_t,  //
+   DW_OP_convert, 0x00}),
+   llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
+
   // Truncate to 8 bits.
   EXPECT_THAT_EXPECTED(
   t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert, offs_uchar}),
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -941,6 +941,16 @@
   Value pieces; // Used for DW_OP_piece
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRE

[Lldb-commits] [lldb] 4edb7e3 - [lldb/DWARF] Fix sizes of DW_OP_const[1248][us] and DW_OP_litN results

2020-11-10 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-11-10T16:10:08+01:00
New Revision: 4edb7e34f824ca4adaa55d3668e050166bae2ad4

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

LOG: [lldb/DWARF] Fix sizes of DW_OP_const[1248][us] and DW_OP_litN results

Dwarf says (Section 2.5.1.1. of DWARF v5) that these operations should
push "generic" (pointer-sized) values. This was not the case for
DW_OP_const operations (which were pushing values based on the size of
arguments), nor DW_OP_litN (which were always pushing 64-bit values).

The practical effect of this that were were unable to display the values
of variables if the size of the DW_OP_const opcode was smaller than the
value of the variable it was describing. This would happen because we
would store this (small) result into a buffer and then would not be able
to read sufficient data out of it (in Value::GetValueAsData). Gcc emits
debug info like this.

Other (more subtle) effects are also possible.

The same fix should be applied to DW_OP_const[us] (leb128 versions), but
I'm not doing that right now, because that would cause us to display
wrong (truncated) values of variables on 32-bit targets (pr48087).

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

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 09d0f641e4d1..f797aaf99626 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -69,6 +69,8 @@ class Scalar {
   }
   Scalar(llvm::APInt v)
   : m_type(e_int), m_integer(std::move(v), false), m_float(0.0f) {}
+  Scalar(llvm::APSInt v)
+  : m_type(e_int), m_integer(std::move(v)), m_float(0.0f) {}
 
   bool SignExtend(uint32_t bit_pos);
 

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 9240956defc8..c30fdf565cd5 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -941,6 +941,16 @@ bool DWARFExpression::Evaluate(
   Value pieces; // Used for DW_OP_piece
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+  // A generic type is "an integral type that has the size of an address and an
+  // unspecified signedness". For now, just use the signedness of the operand.
+  // TODO: Implement a real typed stack, and store the genericness of the value
+  // there.
+  auto to_generic = [&](auto v) {
+bool is_signed = std::is_signed::value;
+return Scalar(llvm::APSInt(
+llvm::APInt(8 * opcodes.GetAddressByteSize(), v, is_signed),
+!is_signed));
+  };
 
   while (opcodes.ValidOffset(offset)) {
 const lldb::offset_t op_offset = offset;
@@ -1251,37 +1261,42 @@ bool DWARFExpression::Evaluate(
 // All DW_OP_constXXX opcodes have a single operand as noted below:
 //
 // Opcode   Operand 1
-// DW_OP_const1u1-byte unsigned integer constant DW_OP_const1s
-// 1-byte signed integer constant DW_OP_const2u2-byte unsigned integer
-// constant DW_OP_const2s2-byte signed integer constant DW_OP_const4u
-// 4-byte unsigned integer constant DW_OP_const4s4-byte signed integer
-// constant DW_OP_const8u8-byte unsigned integer constant DW_OP_const8s
-// 8-byte signed integer constant DW_OP_constu unsigned LEB128 integer
-// constant DW_OP_consts signed LEB128 integer constant
+// DW_OP_const1u1-byte unsigned integer constant
+// DW_OP_const1s1-byte signed integer constant
+// DW_OP_const2u2-byte unsigned integer constant
+// DW_OP_const2s2-byte signed integer constant
+// DW_OP_const4u4-byte unsigned integer constant
+// DW_OP_const4s4-byte signed integer constant
+// DW_OP_const8u8-byte unsigned integer constant
+// DW_OP_const8s8-byte signed integer constant
+// DW_OP_constu unsigned LEB128 integer constant
+// DW_OP_consts signed LEB128 integer constant
 case DW_OP_const1u:
-  stack.push_back(Scalar((uint8_t)opcodes.GetU8(&offset)));
+  stack.push_back(to_generic(opcodes.GetU8(&offset)));
   break;
 case DW_OP_const1s:
-  stack.push_back(Scalar((int8_t)opcodes.GetU8(&offset)));
+  stack.push_back(to_generic((int8_t)opcodes.GetU8(&offset)));
   break;
 case DW_OP_const2u:
-  stack.push_back(Scalar((uint16_t)opcodes.GetU16(&offset)));
+  stack.push_back(to_generic(opcodes.GetU16(&offset)));
   break;
 case DW_OP_const2s:
-  stack.push_back(Scalar((int16_t)opcodes.GetU16(&offset)));
+  stack.push_back(to_generic((int16_t)opcodes.GetU16(&of

[Lldb-commits] [PATCH] D90987: [lldb] Avoid confusing crashes during reproducer replay when initialization failed

2020-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/API/SystemInitializerFull.cpp:46
+if (repro::Reproducer::Instance().IsReplaying())
+  std::_Exit(EXIT_FAILURE);
+return error;

labath wrote:
> labath wrote:
> > Print the error that has happened? maybe via `report_fatal_error` ?
> Btw, there's a new report_fatal_error overload taking an llvm::Error -- I 
> meant to use that one :)
😍


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90987

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


[Lldb-commits] [PATCH] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-10 Thread Nathan James via Phabricator via lldb-commits
njames93 updated this revision to Diff 304198.
njames93 added a comment.
Herald added subscribers: usaxena95, kadircet, arphaman.

Teach clangd to ignore these fix-its.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Tooling/Core/Replacement.h
  clang/lib/Frontend/DiagnosticRenderer.cpp
  clang/lib/Frontend/Rewrite/FixItRewriter.cpp
  clang/lib/Tooling/Core/Replacement.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1167,9 +1167,10 @@
   // This is cobbed from clang::Rewrite::FixItRewriter.
   if (fixit.CodeToInsert.empty()) {
 if (fixit.InsertFromRange.isValid()) {
-  commit.insertFromRange(fixit.RemoveRange.getBegin(),
- fixit.InsertFromRange, /*afterToken=*/false,
- fixit.BeforePreviousInsertions);
+  if (!fixit.isReformatFixit())
+commit.insertFromRange(fixit.RemoveRange.getBegin(),
+   fixit.InsertFromRange, /*afterToken=*/false,
+   fixit.BeforePreviousInsertions);
   return;
 }
 commit.remove(fixit.RemoveRange);
Index: clang/lib/Tooling/Core/Replacement.cpp
===
--- clang/lib/Tooling/Core/Replacement.cpp
+++ clang/lib/Tooling/Core/Replacement.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/RewriteBuffer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -42,32 +43,57 @@
 
 static const char * const InvalidLocation = "";
 
-Replacement::Replacement() : FilePath(InvalidLocation) {}
+FileRange::FileRange() : FilePath(InvalidLocation), RangeInFile(0, 0) {}
+
+FileRange::FileRange(StringRef FilePath, Range RangeInFile)
+: FilePath(FilePath), RangeInFile(RangeInFile) {}
+FileRange::FileRange(StringRef FilePath, unsigned Offset, unsigned Length)
+: FileRange(FilePath, Range(Offset, Length)) {}
+
+FileRange::FileRange(const SourceManager &Sources, SourceLocation Start,
+ unsigned Length) {
+  setFromSourceLocation(Sources, Start, Length);
+}
+
+FileRange::FileRange(const SourceManager &Sources, const CharSourceRange &Range,
+ const LangOptions &LangOpts) {
+  setFromSourceRange(Sources, Range, LangOpts);
+}
+
+bool FileRange::isValid() const { return FilePath != InvalidLocation; }
+
+void FileRange::setFromSourceLocation(const SourceManager &Sources,
+  SourceLocation Start, unsigned Length) {
+  const std::pair DecomposedLocation =
+  Sources.getDecomposedLoc(Start);
+  const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
+  this->FilePath = std::string(Entry ? Entry->getName() : InvalidLocation);
+  this->RangeInFile = {DecomposedLocation.second, Length};
+}
+
+Replacement::Replacement() : ReplacementRange() {}
+
+Replacement::Replacement(FileRange FileRange, StringRef ReplacementText)
+: ReplacementRange(FileRange), ReplacementText(ReplacementText) {}
 
 Replacement::Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
  StringRef ReplacementText)
-: FilePath(std::string(FilePath)), ReplacementRange(Offset, Length),
-  ReplacementText(std::string(ReplacementText)) {}
+: Replacement(FileRange(FilePath, Offset, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager &Sources, SourceLocation Start,
- unsigned Length, StringRef ReplacementText) {
-  setFromSourceLocation(Sources, Start, Length, ReplacementText);
-}
+ unsigned Length, StringRef ReplacementText)
+: Replacement(FileRange(Sources, Start, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager &Sources,
  const CharSourceRange &Range,
- StringRef ReplacementText,
- const LangOptions &LangOpts) {
-  setFromSourceRange(Sources, Range, ReplacementText, LangOpts);
-}
+ StringRef ReplacementText, const LangOptions &LangOpts)
+: Replacement(FileRange(Sources, Range, LangOpts), ReplacementText) {}
 
-bool Replacement::isApplicable() const {
-  return FilePat

[Lldb-commits] [PATCH] D91167: [lldb] [Process/NetBSD] Copy the recent improvements from FreeBSD

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, labath.
Herald added subscribers: arichardson, emaste.
mgorny requested review of this revision.

Copy the recent improvements from the FreeBSDRemote plugin, notably:

- moving event reporting setup into SetupTrace() helper

- adding more debug info into SIGTRAP handling

- handling user-generated (and unknown) SIGTRAP events

- adding missing error handling to the generic signal handler

- fixing attaching to processes

- switching watchpoint helpers to use llvm::Error

- minor style and formatting changes

This fixes a number of tests, mostly related to fixed attaching.


https://reviews.llvm.org/D91167

Files:
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
  lldb/test/API/commands/process/attach/TestProcessAttach.py
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py
  lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py
  lldb/test/API/python_api/hello_world/TestHelloWorld.py
  lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
  lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
  lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
  lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Index: lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
===
--- lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -227,7 +227,6 @@
 self.set_inferior_startup_attach()
 self.attach_commandline_continue_app_exits()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_commandline_continue_app_exits_llgs(self):
 self.init_llgs_test()
@@ -480,7 +479,6 @@
 self.qThreadInfo_contains_thread()
 
 @expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
-@expectedFailureNetBSD
 @llgs_test
 def test_qThreadInfo_contains_thread_attach_llgs(self):
 self.init_llgs_test()
@@ -540,7 +538,6 @@
 self.qThreadInfo_matches_qC()
 
 @expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
-@expectedFailureNetBSD
 @llgs_test
 def test_qThreadInfo_matches_qC_attach_llgs(self):
 self.init_llgs_test()
@@ -688,7 +685,6 @@
 self.Hg_switches_to_3_threads()
 
 @expectedFailureAll(oslist=["windows"]) # expecting one more thread
-@expectedFailureNetBSD
 @llgs_test
 def test_Hg_switches_to_3_threads_attach_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
@@ -74,7 +74,6 @@
 self.set_inferior_startup_attach()
 self.attach_commandline_qProcessInfo_reports_correct_pid()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_commandline_qProcessInfo_reports_correct_pid_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
@@ -51,7 +51,6 @@
 self.set_inferior_startup_attach()
 self.attach_commandline_kill_after_initial_stop()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_commandline_kill_after_initial_stop_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
@@ -58,7 +58,6 @@
 self.set_inferior_startup_attach_manually()
 self.attach_with_vAttach()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_with_vAttach_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/python_api/hello_world/TestHelloWorld.py
===
--- lldb/test/API/python_api/hello_world/TestHelloWorld.py
+++ lldb/test/API/python_api/hello_world/TestHelloWorld.py
@@ -74,7 +74,6 @@
 
 @add_test_categories(['pyapi'])
 @skipIfiOSSimulator
-@expectedFailureNetBSD
 @skipIfReproducer # File synchronization is not supported during rep

[Lldb-commits] [lldb] 8da14fb - [lldb] Propagate llvm::Error to report_fatal_error

2020-11-10 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-11-10T08:19:47-08:00
New Revision: 8da14fb76c77471479a12e5c5e1acd7b57117062

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

LOG: [lldb] Propagate llvm::Error to report_fatal_error

Instead of having a custom error message, propagate the llvm::Error from
SystemInitializerCommon. I didn't realize we had this overload until
Pavel mentioned it in D90987 today.

Added: 


Modified: 
lldb/source/API/SystemInitializerFull.cpp

Removed: 




diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index cd5b464db04e..a6421d8f10d0 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -42,7 +42,7 @@ llvm::Error SystemInitializerFull::Initialize() {
 // this, we terminate here before the uninitialized debugger inevitably
 // crashes.
 if (repro::Reproducer::Instance().IsReplaying())
-  llvm::report_fatal_error("system initialization failed");
+  llvm::report_fatal_error(std::move(error));
 return error;
   }
 



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


[Lldb-commits] [PATCH] D91155: [lldb] Fix TestErrorMessages test on standalone builds by adding lldb-server substitution

2020-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere reopened this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Please add a `_disallow` to avoid accidental use of `lldb-server` without the 
`%`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91155

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


[Lldb-commits] [PATCH] D91118: Fix handling of bit-fields in a union

2020-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Should we maybe check that the offset is 0 instead of skipping the sanity 
check? Otherwise this LGTM.


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

https://reviews.llvm.org/D91118

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


[Lldb-commits] [PATCH] D90490: [intel-pt][trace] Implement a "get supported trace type" packet

2020-11-10 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 304232.
wallace added a comment.

Added a test that accounts for a custom error message from the gdb-server.
I decided to follow @labath's approach of using the existing error code format 
(;AAA). It works well and the GDBClient classes already have good support 
for that, specifically StringExtractorGDBRemote.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90490

Files:
  lldb/docs/lldb-gdb-remote.txt
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Trace.h
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/include/lldb/Utility/TraceOptions.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
  lldb/source/Plugins/Process/Linux/ProcessorTrace.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/source/Utility/TraceOptions.cpp
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -362,6 +362,63 @@
   EXPECT_FALSE(result.get().Success());
 }
 
+TEST_F(GDBRemoteCommunicationClientTest, SendTraceSupportedTypePacket) {
+  // Success response
+  {
+std::future> result = std::async(
+std::launch::async, [&] { return client.SendGetSupportedTraceType(); });
+
+HandlePacket(
+server, "jLLDBTraceSupportedType",
+R"({"name":"intel-pt","description":"Intel Processor Trace"}])");
+
+llvm::Expected trace_type_or_err = result.get();
+EXPECT_THAT_EXPECTED(trace_type_or_err, llvm::Succeeded());
+ASSERT_STREQ(trace_type_or_err->name.c_str(), "intel-pt");
+ASSERT_STREQ(trace_type_or_err->description.c_str(),
+ "Intel Processor Trace");
+  }
+
+  // Error response - wrong json
+  {
+std::future> result = std::async(
+std::launch::async, [&] { return client.SendGetSupportedTraceType(); });
+
+HandlePacket(server, "jLLDBTraceSupportedType", R"({"type":"intel-pt"}])");
+
+llvm::Expected trace_type_or_err = result.get();
+ASSERT_THAT_EXPECTED(
+trace_type_or_err,
+llvm::Failed(testing::Property(
+&StringError::getMessage,
+testing::HasSubstr("missing value at (root).name";
+  }
+
+  // Error response
+  {
+std::future> result = std::async(
+std::launch::async, [&] { return client.SendGetSupportedTraceType(); });
+
+HandlePacket(server, "jLLDBTraceSupportedType", "E23");
+llvm::Expected trace_type_or_err = result.get();
+ASSERT_THAT_EXPECTED(trace_type_or_err, llvm::Failed());
+  }
+
+  // Error response with error message
+  {
+std::future> result = std::async(
+std::launch::async, [&] { return client.SendGetSupportedTraceType(); });
+
+HandlePacket(server, "jLLDBTraceSupportedType",
+ "E23;50726F63657373206E6F742072756E6E696E672E");
+llvm::Expected trace_type_or_err = result.get();
+ASSERT_THAT_EXPECTED(trace_type_or_err,
+ llvm::Failed(testing::Property(
+ &StringError::getMessage,
+ testing::HasSubstr("Process not running.";
+  }
+}
+
 TEST_F(GDBRemoteCommunicationClientTest, SendStartTracePacket) {
   TraceOptions options;
   Status error;
Index: lldb/source/Utility/TraceOptions.cpp
===
--- /dev/null
+++ lldb/source/Utility/TraceOptions.cpp
@@ -0,0 +1,25 @@
+//===-- TraceOptions.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Utility/TraceOptions.h"
+
+using namespace lldb_private;
+
+namespace llvm {
+namespace json {
+
+bool fromJSON(const Value &value, TraceTypeInfo &info, Path path) {
+  ObjectMapper o(value, path);
+  if (!o)
+r

[Lldb-commits] [lldb] 7211604 - [lldb][NFC] Add lldb-server to the shell tests disallow list

2020-11-10 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-11-10T18:48:28+01:00
New Revision: 7211604220ae7de9d96abb3385248dc2fecc9777

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

LOG: [lldb][NFC] Add lldb-server to the shell tests disallow list

This prevents that one can write a test that referenced lldb-server (instead
of %lldb-server). Addresses review feedback from D91155.

Added: 


Modified: 
lldb/test/Shell/helper/toolchain.py

Removed: 




diff  --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index c7374e06c272..ebf9e03d81a0 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -75,6 +75,7 @@ def use_lldb_substitutions(config):
 ]
 
 _disallow(config, 'lldb')
+_disallow(config, 'lldb-server')
 _disallow(config, 'debugserver')
 _disallow(config, 'platformserver')
 



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


[Lldb-commits] [PATCH] D91155: [lldb] Fix TestErrorMessages test on standalone builds by adding lldb-server substitution

2020-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor closed this revision.
teemperor added a comment.

Added the disallow in rG7211604220ae 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91155

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


[Lldb-commits] [lldb] f21e704 - [lldb] [Process/NetBSD] Copy the recent improvements from FreeBSD

2020-11-10 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-11-10T20:20:44+01:00
New Revision: f21e704d4a2cc992faff46665b31daad290cc8b8

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

LOG: [lldb] [Process/NetBSD] Copy the recent improvements from FreeBSD

Copy the recent improvements from the FreeBSDRemote plugin, notably:

- moving event reporting setup into SetupTrace() helper

- adding more debug info into SIGTRAP handling

- handling user-generated (and unknown) SIGTRAP events

- adding missing error handling to the generic signal handler

- fixing attaching to processes

- switching watchpoint helpers to use llvm::Error

- minor style and formatting changes

This fixes a number of tests, mostly related to fixed attaching.

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

Added: 


Modified: 
lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
lldb/test/API/commands/process/attach/TestProcessAttach.py
lldb/test/API/commands/register/register/register_command/TestRegisters.py
lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py
lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py
lldb/test/API/python_api/hello_world/TestHelloWorld.py
lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Removed: 




diff  --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp 
b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
index be98a6386363..75d0d0a37fae 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -98,18 +98,7 @@ NativeProcessNetBSD::Factory::Launch(ProcessLaunchInfo 
&launch_info,
   pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), 
native_delegate,
   Info.GetArchitecture(), mainloop));
 
-  // Enable event reporting
-  ptrace_event_t events;
-  status = PtraceWrapper(PT_GET_EVENT_MASK, pid, &events, sizeof(events));
-  if (status.Fail())
-return status.ToError();
-  // TODO: PTRACE_FORK | PTRACE_VFORK | PTRACE_POSIX_SPAWN?
-  events.pe_set_event |= PTRACE_LWP_CREATE | PTRACE_LWP_EXIT;
-  status = PtraceWrapper(PT_SET_EVENT_MASK, pid, &events, sizeof(events));
-  if (status.Fail())
-return status.ToError();
-
-  status = process_up->ReinitializeThreads();
+  status = process_up->SetupTrace();
   if (status.Fail())
 return status.ToError();
 
@@ -218,10 +207,14 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) 
{
 
   // Get details on the signal raised.
   if (siginfo_err.Fail()) {
+LLDB_LOG(log, "PT_GET_SIGINFO failed {0}", siginfo_err);
 return;
   }
 
+  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, si_code = {2}", pid,
+   info.psi_lwpid, info.psi_siginfo.si_code);
   NativeThreadNetBSD* thread = nullptr;
+
   if (info.psi_lwpid > 0) {
 for (const auto &t : m_threads) {
   if (t->GetID() == static_cast(info.psi_lwpid)) {
@@ -243,12 +236,12 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) 
{
   FixupBreakpointPCAsNeeded(*thread);
 }
 SetState(StateType::eStateStopped, true);
-break;
+return;
   case TRAP_TRACE:
 if (thread)
   thread->SetStoppedByTrace();
 SetState(StateType::eStateStopped, true);
-break;
+return;
   case TRAP_EXEC: {
 Status error = ReinitializeThreads();
 if (error.Fail()) {
@@ -262,7 +255,8 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
 for (const auto &thread : m_threads)
   static_cast(*thread).SetStoppedByExec();
 SetState(StateType::eStateStopped, true);
-  } break;
+return;
+  }
   case TRAP_LWP: {
 ptrace_state_t pst;
 Status error = PtraceWrapper(PT_GET_PROCESS_STATE, pid, &pst, sizeof(pst));
@@ -296,11 +290,10 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) 
{
 }
 
 error = PtraceWrapper(PT_CONTINUE, pid, reinterpret_cast(1), 0);
-if (error.Fail()) {
+if (error.Fail())
   SetState(StateType::eStateInvalid);
-  return;
-}
-  } break;
+return;
+  }
   case TRAP_DBREG: {
 if (!thread)
   break;
@@ -318,19 +311,31 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) 
{
   thread->SetStoppe

[Lldb-commits] [PATCH] D91167: [lldb] [Process/NetBSD] Copy the recent improvements from FreeBSD

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf21e704d4a2c: [lldb] [Process/NetBSD] Copy the recent 
improvements from FreeBSD (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91167

Files:
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
  lldb/test/API/commands/process/attach/TestProcessAttach.py
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py
  lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py
  lldb/test/API/python_api/hello_world/TestHelloWorld.py
  lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
  lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
  lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
  lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Index: lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
===
--- lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -227,7 +227,6 @@
 self.set_inferior_startup_attach()
 self.attach_commandline_continue_app_exits()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_commandline_continue_app_exits_llgs(self):
 self.init_llgs_test()
@@ -480,7 +479,6 @@
 self.qThreadInfo_contains_thread()
 
 @expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
-@expectedFailureNetBSD
 @llgs_test
 def test_qThreadInfo_contains_thread_attach_llgs(self):
 self.init_llgs_test()
@@ -540,7 +538,6 @@
 self.qThreadInfo_matches_qC()
 
 @expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
-@expectedFailureNetBSD
 @llgs_test
 def test_qThreadInfo_matches_qC_attach_llgs(self):
 self.init_llgs_test()
@@ -688,7 +685,6 @@
 self.Hg_switches_to_3_threads()
 
 @expectedFailureAll(oslist=["windows"]) # expecting one more thread
-@expectedFailureNetBSD
 @llgs_test
 def test_Hg_switches_to_3_threads_attach_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
@@ -74,7 +74,6 @@
 self.set_inferior_startup_attach()
 self.attach_commandline_qProcessInfo_reports_correct_pid()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_commandline_qProcessInfo_reports_correct_pid_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteKill.py
@@ -51,7 +51,6 @@
 self.set_inferior_startup_attach()
 self.attach_commandline_kill_after_initial_stop()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_commandline_kill_after_initial_stop_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
@@ -58,7 +58,6 @@
 self.set_inferior_startup_attach_manually()
 self.attach_with_vAttach()
 
-@expectedFailureNetBSD
 @llgs_test
 def test_attach_with_vAttach_llgs(self):
 self.init_llgs_test()
Index: lldb/test/API/python_api/hello_world/TestHelloWorld.py
===
--- lldb/test/API/python_api/hello_world/TestHelloWorld.py
+++ lldb/test/API/python_api/hello_world/TestHelloWorld.py
@@ -74,7 +74,6 @@
 
 @add_test_categories(['pyapi'])
 @skipIfiOSSimulator
-@expectedFailureNetBSD
 @skipIfReproducer # File synchronization is not supported during replay.
 def test_with_attach_to_process_with_id_api(self):
 """Create target, spawn a process, and attach to it with process id."""
@@ -108,7 +107,6 @@
 @add_test_categories(['pyapi'])
 @skipIfiOSSimulator
 @skipIfAsan # FIXME: Hangs indefinitely.
-@expectedFailureNetBSD
 @skipIfReprod

[Lldb-commits] [PATCH] D90729: [trace][intel-pt] Scaffold the 'thread trace start | stop' commands

2020-11-10 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 304267.
wallace added a comment.

Address comments

- I didn't move the caching to Process.h, as creating the start command 
requires an Interpreter, which I don't know if I can assume as unique. Btw, I'm 
using weak pointers instead.
- I added an IsLiveDebugSession, as Greg suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90729

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Interpreter/CommandObjectDelegate.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/ProcessTrace.h
  lldb/include/lldb/Target/Trace.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/CommandObjectThreadUtil.cpp
  lldb/source/Commands/CommandObjectThreadUtil.h
  lldb/source/Core/PluginManager.cpp
  lldb/source/Interpreter/CMakeLists.txt
  lldb/source/Interpreter/CommandObject.cpp
  lldb/source/Interpreter/CommandObjectDelegate.cpp
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.h
  lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
  lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td
  lldb/source/Target/Process.cpp
  lldb/test/API/commands/trace/TestTraceDumpInstructions.py
  lldb/test/API/commands/trace/TestTraceStartStop.py

Index: lldb/test/API/commands/trace/TestTraceStartStop.py
===
--- /dev/null
+++ lldb/test/API/commands/trace/TestTraceStartStop.py
@@ -0,0 +1,73 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+
+class TestTraceLoad(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+if 'intel-pt' not in configuration.enabled_plugins:
+self.skipTest("The intel-pt test plugin is not enabled")
+
+def expectGenericHelpMessageForStartCommand(self):
+self.expect("help thread trace start",
+substrs=["Syntax: thread trace start []"])
+
+def testStartStopSessionFileThreads(self):
+# it should fail for processes from json session files
+self.expect("trace load -v " + os.path.join(self.getSourceDir(), "intelpt-trace", "trace.json"))
+self.expect("thread trace start", error=True,
+substrs=["error: tracing is not supported. Can't trace a non-live process"])
+
+# the help command should be the generic one, as it's not a live process
+self.expectGenericHelpMessageForStartCommand()
+
+# this should fail because 'trace stop' is not yet implemented
+self.expect("thread trace stop", error=True,
+substrs=["error: failed stopping thread 3842849"])
+
+@skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))
+def testStartStopLiveThreads(self):
+# The help command should be the generic one if there's no process running
+self.expectGenericHelpMessageForStartCommand()
+
+self.expect("thread trace start", error=True,
+substrs=["error: No process available"])
+
+self.expect("file " + os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
+self.expect("b main")
+
+self.expect("thread trace start", error=True,
+substrs=["error: No process available"])
+
+# The help command should be the generic one if there's still no process running
+self.expectGenericHelpMessageForStartCommand()
+
+self.expect("r")
+
+# the help command should be the intel-pt one now
+self.expect("help thread trace start",
+substrs=["Start tracing one or more threads with intel-pt.",
+ "Syntax: thread trace start [  ...] []"])
+
+self.expect("thread trace start",
+patterns=["would trace tid .* with size_in_kb 4 and custom_config 0"])
+
+self.expect("thread trace start --size 20 --custom-config 1",
+patterns=["would trace tid .* with size_in_kb 20 and custom_config 1"])
+
+# This fails because "trace stop" is not yet implemented.
+self.expect("thread trace stop", error=True,
+substrs=["error: Process is not being traced"])
+
+self.expect("c")
+# Now the process has finished, so the commands should fail
+self.expect("thread trace start", error=True,
+substrs=["error:

[Lldb-commits] [PATCH] D91193: [lldb] Fine tune expect() validation

2020-11-10 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: jingham, teemperor, aprantl, JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
kastiglione requested review of this revision.

Restore ability to call `expect()` with a message and no matcher.

After the changes in D88792 , `expect` can no 
longer be called as:

  self.expect("some command", "some message")

After speaking to @jingham, I now understand that an uncommon use case is to
check only that a command succeeds, without validating its output. The changes
in D88792  prevent such expectations.

This change restores the ability to call `expect` this way, but with the
requirement that the `msg` argument be a keyword argument. Requiring `msg` be a
keyword argument provides the ability to ensure `expect`'s arguments are
explict, and not ambiguous. Example:

  self.expect("some command", msg="some message")

When lldb supports only Python 3, the easy solution will be to change the
signature of `expect` by require all arguments be keyword ags using its `*`
syntax:

  def expect(
  self,
  str,
  *,
  msg=None,
  patterns=None,
  startstr=None,
  endstr=None,
  substrs=None,
  trace=False,
  error=False,
  ordered=True,
  matching=True,
  exe=True,
  inHistory=False):

But the `*` syntax is not supported in Python 2. To work around this, this 
change renames `expect` to `_expect_impl`, and implements `expect` as a 
separate function with a signature that separates positional args from keyword 
args, in order to perform validation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91193

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/assert_messages_test/TestAssertMessages.py


Index: lldb/test/API/assert_messages_test/TestAssertMessages.py
===
--- lldb/test/API/assert_messages_test/TestAssertMessages.py
+++ lldb/test/API/assert_messages_test/TestAssertMessages.py
@@ -122,10 +122,6 @@
 self.assert_expect_fails_with("any command",
 dict(substrs="some substring"),
 "substrs must be a collection of strings")
-# Prevent `self.expect("cmd", "substr")`
-self.assert_expect_fails_with("any command",
-dict(msg="some substring"),
-"expect() missing a matcher argument")
 # Prevent `self.expect("cmd", "msg", "substr")`
 self.assert_expect_fails_with("any command",
 dict(msg="a message", patterns="some substring"),
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2388,7 +2388,35 @@
 
 self.assertTrue(cmd_status == 0)
 
-def expect(
+
+def expect(self, str, *args, **kwargs):
+"Validate `expect` arguments before calling `_expect_impl`"
+# Support success/fail only checks like:
+# self.expect("lldb command")
+if not args and not kwargs:
+return self._expect(str)
+
+# Prevent this ambiguous mistake:
+# self.expect("lldb command", "some string")
+# Instead, this invocation must be changed to either:
+# self.expect("lldb command", msg="some string")
+# or use a matcher of some kind, such as:
+# self.expect("lldb command", substrs=["some string"])
+if args:
+needed = ("patterns", "startstr", "endstr", "substrs", "error")
+assert any(arg in kwargs for arg in needed), \
+"expect() requires a keyword argument"
+
+# Check `patterns` and `substrs` are not accidentally given as strings.
+assert not isinstance(kwargs.get("patterns"), six.string_types), \
+"patterns must be a collection of strings"
+assert not isinstance(kwargs.get("substrs"), six.string_types), \
+"substrs must be a collection of strings"
+
+return self._expect(str, **kwargs)
+
+
+def _expect_impl(
 self,
 str,
 msg=None,
@@ -2429,22 +2457,6 @@
 set to False, the 'str' is treated as a string to be 
matched/not-matched
 against the golden input.
 """
-# Catch cases where `expect` has been miscalled. Specifically, prevent
-# this easy to make mistake:
-# self.expect("lldb command", "some substr")
-# The `msg` parameter is used only when a failed match occurs. A failed
-# match can only occur when one of `patterns`, `startstr`, `endstr`, or
-# `substrs` has been given. Thus, if a `msg` is given, it's an error to
-# not also provide one of the matcher parameters.
-if

[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 304282.
JDevlieghere added a comment.

- Add fallback for finding the language
- Fix tests


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

https://reviews.llvm.org/D77153

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
  lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  lldb/test/API/lang/c/anonymous/TestAnonymous.py

Index: lldb/test/API/lang/c/anonymous/TestAnonymous.py
===
--- lldb/test/API/lang/c/anonymous/TestAnonymous.py
+++ lldb/test/API/lang/c/anonymous/TestAnonymous.py
@@ -62,7 +62,7 @@
 
 # These should display correctly.
 self.expect("expression pz", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=["(type_z *) $", " = 0x"])
+substrs=["(type_z *) $", " = nullptr"])
 
 self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY,
 substrs=["(type_y) $", "dummy = 2"])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
@@ -74,6 +74,7 @@
 std::u32string u32_string(U"🍄🍅🍆🍌");
 std::u32string u32_empty(U"");
 std::basic_string uchar(5, 'a');
+std::string *null_str = nullptr;
 
 #if _LIBCPP_ABI_VERSION == 1
 std::string garbage1, garbage2, garbage3, garbage4, garbage5;
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -77,6 +77,7 @@
 '(%s::u32string) u32_empty = ""'%ns,
 '(%s::basic_string, '
 '%s::allocator >) uchar = "a"'%(ns,ns,ns),
+'(%s::string *) null_str = nullptr'%ns,
 ])
 
 self.runCmd("n")
@@ -114,6 +115,7 @@
 '(%s::u32string) u32_empty = ""'%ns,
 '(%s::basic_string, '
 '%s::allocator >) uchar = "a"'%(ns,ns,ns),
+'(%s::string *) null_str = nullptr'%ns,
 ])
 
 # The test assumes that std::string is in its cap-size-data layout.
Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
@@ -39,4 +39,4 @@
 # Both `std::vector` and the type of the member have forward
 # declarations before their definitions.
 self.expect("expr --raw -- v",
-substrs=['(std::__1::vector) $0 = {', 'f = 0x', '}'])
+substrs=['(std::__1::vector) $0 = {', 'f = nullptr', '}'])
Index: lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
===
--- lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
+++ lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
@@ -27,6 +27,8 @@
 return lldb::eLanguageTypeObjC_plus_plus;
   }
 
+  llvm::StringRef NilReferenceSummaryString() override { return "nil"; }
+
   bool IsSourceFile(llvm::StringRef file_path) const override;
 
   const Highlighter *GetHighlighter() const override { return &m_highlighter; }
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -119,6 +119,8 @@
 
   bool IsNilReference(ValueObject &valobj) override;
 
+  llvm::StringRef NilReferenceSummaryString() override { return "nil"; }
+
   bool IsSourceFile(llvm::StringRef file_path) const override;
 
   const Highlighter *GetHighlighter() cons

[Lldb-commits] [PATCH] D91193: [lldb] Fine tune expect() validation

2020-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Isn't that what we use `runCmd` for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91193

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


[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-11-10 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

So this work for primitive types like `int*` etc?


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

https://reviews.llvm.org/D77153

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


[Lldb-commits] [PATCH] D91193: [lldb] Fine tune expect() validation

2020-11-10 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

@teemperor maybe? Do you mean validation should go in `runCmd`? Or do you mean 
something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91193

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


[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D77153#2386740 , @shafik wrote:

> So this work for primitive types like `int*` etc?

No, Jim probably know the details, but this only applies to composite types.


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

https://reviews.llvm.org/D77153

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


[Lldb-commits] [PATCH] D91193: [lldb] Fine tune expect() validation

2020-11-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D91193#2386832 , @kastiglione wrote:

> @teemperor maybe? Do you mean validation should go in `runCmd`? Or do you 
> mean something else?

I meant that to my knowledge command execution where the only expectation is 
that they succeed (so, no output checking) are supposed to be done via 
`runCmd`. `expect` is also documented as `Similar to runCmd; with additional 
expect style output matching ability.`, so if we allow calling `expect` without 
the additional `expect style matching ability`, then we might as well remove 
`runCmd`. So IMHO the current implementation of expect is just fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91193

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


[Lldb-commits] [PATCH] D91193: [lldb] Fine tune expect() validation

2020-11-10 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

That's much better. I'll change those callers can be changed to `runCmd`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91193

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


[Lldb-commits] [PATCH] D90729: [trace][intel-pt] Scaffold the 'thread trace start | stop' commands

2020-11-10 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 304317.
wallace added a comment.

nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90729

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Interpreter/CommandObjectDelegate.h
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/ProcessTrace.h
  lldb/include/lldb/Target/Trace.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/CommandObjectThreadUtil.cpp
  lldb/source/Commands/CommandObjectThreadUtil.h
  lldb/source/Core/PluginManager.cpp
  lldb/source/Interpreter/CMakeLists.txt
  lldb/source/Interpreter/CommandObject.cpp
  lldb/source/Interpreter/CommandObjectDelegate.cpp
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.h
  lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
  lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td
  lldb/source/Target/Process.cpp
  lldb/test/API/commands/trace/TestTraceDumpInstructions.py
  lldb/test/API/commands/trace/TestTraceStartStop.py

Index: lldb/test/API/commands/trace/TestTraceStartStop.py
===
--- /dev/null
+++ lldb/test/API/commands/trace/TestTraceStartStop.py
@@ -0,0 +1,73 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+
+class TestTraceLoad(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+if 'intel-pt' not in configuration.enabled_plugins:
+self.skipTest("The intel-pt test plugin is not enabled")
+
+def expectGenericHelpMessageForStartCommand(self):
+self.expect("help thread trace start",
+substrs=["Syntax: thread trace start []"])
+
+def testStartStopSessionFileThreads(self):
+# it should fail for processes from json session files
+self.expect("trace load -v " + os.path.join(self.getSourceDir(), "intelpt-trace", "trace.json"))
+self.expect("thread trace start", error=True,
+substrs=["error: tracing is not supported. Can't trace a non-live process"])
+
+# the help command should be the generic one, as it's not a live process
+self.expectGenericHelpMessageForStartCommand()
+
+# this should fail because 'trace stop' is not yet implemented
+self.expect("thread trace stop", error=True,
+substrs=["error: failed stopping thread 3842849"])
+
+@skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))
+def testStartStopLiveThreads(self):
+# The help command should be the generic one if there's no process running
+self.expectGenericHelpMessageForStartCommand()
+
+self.expect("thread trace start", error=True,
+substrs=["error: No process available"])
+
+self.expect("file " + os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
+self.expect("b main")
+
+self.expect("thread trace start", error=True,
+substrs=["error: No process available"])
+
+# The help command should be the generic one if there's still no process running
+self.expectGenericHelpMessageForStartCommand()
+
+self.expect("r")
+
+# the help command should be the intel-pt one now
+self.expect("help thread trace start",
+substrs=["Start tracing one or more threads with intel-pt.",
+ "Syntax: thread trace start [  ...] []"])
+
+self.expect("thread trace start",
+patterns=["would trace tid .* with size_in_kb 4 and custom_config 0"])
+
+self.expect("thread trace start --size 20 --custom-config 1",
+patterns=["would trace tid .* with size_in_kb 20 and custom_config 1"])
+
+# This fails because "trace stop" is not yet implemented.
+self.expect("thread trace stop", error=True,
+substrs=["error: Process is not being traced"])
+
+self.expect("c")
+# Now the process has finished, so the commands should fail
+self.expect("thread trace start", error=True,
+substrs=["error: Process must be launched."])
+
+self.expect("thread trace stop", error=True,
+substrs=["error: Process must be launched."])
Index: lldb/test/API/commands/trace/TestTraceDumpInstructions.py
===

[Lldb-commits] [PATCH] D91206: [lldb] Switch expect to runCmd in TestRecursiveTypes (NFC)

2020-11-10 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: aprantl, teemperor.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
kastiglione requested review of this revision.
Herald added a subscriber: JDevlieghere.

Following discussion in D91193 , a change made 
in D88792  was not quite right.
This restores the message argument, and switches from `expect` to `runCmd`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91206

Files:
  lldb/test/API/types/TestRecursiveTypes.py


Index: lldb/test/API/types/TestRecursiveTypes.py
===
--- lldb/test/API/types/TestRecursiveTypes.py
+++ lldb/test/API/types/TestRecursiveTypes.py
@@ -50,5 +50,5 @@
 
 self.runCmd("run", RUN_SUCCEEDED)
 
-self.expect("print tpi")
-self.expect("print *tpi")
+self.runCmd("print tpi", RUN_SUCCEEDED)
+self.runCmd("print *tpi", RUN_SUCCEEDED)


Index: lldb/test/API/types/TestRecursiveTypes.py
===
--- lldb/test/API/types/TestRecursiveTypes.py
+++ lldb/test/API/types/TestRecursiveTypes.py
@@ -50,5 +50,5 @@
 
 self.runCmd("run", RUN_SUCCEEDED)
 
-self.expect("print tpi")
-self.expect("print *tpi")
+self.runCmd("print tpi", RUN_SUCCEEDED)
+self.runCmd("print *tpi", RUN_SUCCEEDED)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D91216: [lldb] [Process/FreeBSDRemote] Access GPR via reginfo offsets

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
Herald added a subscriber: arichardson.
mgorny requested review of this revision.

Read and write registers from m_gpr using offsets from RegisterInfo
rather than explicit switch-case.  This eliminates a lot of redundant
code, and avoids mistakes such as type mismatches seen recently (wrt
segment registers).  The same logic will be extended to other register
sets in the future.

Make m_gpr an uint8_t std::array to ease accesses.  Ideally, we could
avoid including  entirely in the future and instead
get the correct GPR size from Utility/RegisterContextFreeBSD_* somehow.

While at it, modify register set logic to use an explicit enum with
llvm::Optional<>, making the code cleaner and at the same time enabling
compiler warnings for unhandled sets.

Since now we're fully relying on 'struct GPR' defined
in Utility/RegisterContextFreeBSD_* being entirely in sync with
the system structure, add a bunch of static_asserts to verify
the field offsets and sizes.  This also requires renaming 'struct dbreg'
in i386 context to 'struct DBR' (matching amd64) to avoid name
collisions with system headers.


https://reviews.llvm.org/D91216

Files:
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp

Index: lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
@@ -11,6 +11,10 @@
 #include "RegisterContextPOSIX_x86.h"
 #include 
 
+#if defined(__FreeBSD__) && defined(__x86_64__)
+#include 
+#endif
+
 using namespace lldb_private;
 using namespace lldb;
 
@@ -59,6 +63,44 @@
   DBG dbg;
 };
 
+#if defined(__FreeBSD__) && defined(__x86_64__)
+// if we're building natively, verify that the structs are correct
+#define ASSERT_GPR(regname)\
+  static_assert(offsetof(GPR, regname) == offsetof(reg, r_##regname),  \
+"GPR offset mismatch for " #regname);  \
+  static_assert(sizeof(GPR::regname) == sizeof(reg::r_##regname),  \
+"GPR size mismatch for " #regname);
+
+ASSERT_GPR(r15);
+ASSERT_GPR(r14);
+ASSERT_GPR(r13);
+ASSERT_GPR(r12);
+ASSERT_GPR(r11);
+ASSERT_GPR(r10);
+ASSERT_GPR(r9);
+ASSERT_GPR(r8);
+ASSERT_GPR(rdi);
+ASSERT_GPR(rsi);
+ASSERT_GPR(rbp);
+ASSERT_GPR(rbx);
+ASSERT_GPR(rdx);
+ASSERT_GPR(rcx);
+ASSERT_GPR(rax);
+ASSERT_GPR(trapno);
+ASSERT_GPR(fs);
+ASSERT_GPR(gs);
+ASSERT_GPR(err);
+ASSERT_GPR(es);
+ASSERT_GPR(ds);
+ASSERT_GPR(rip);
+ASSERT_GPR(cs);
+ASSERT_GPR(rflags);
+ASSERT_GPR(rsp);
+ASSERT_GPR(ss);
+
+#undef ASSERT_GPR
+#endif
+
 #define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
 
 // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
Index: lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
@@ -9,6 +9,10 @@
 #include "RegisterContextFreeBSD_i386.h"
 #include "RegisterContextPOSIX_x86.h"
 
+#if defined(__FreeBSD__) && (defined(__x86_64__) || defined(__i386__))
+#include 
+#endif
+
 using namespace lldb_private;
 using namespace lldb;
 
@@ -35,7 +39,7 @@
   uint32_t gs;
 };
 
-struct dbreg {
+struct DBG {
   uint32_t dr[8]; /* debug registers */
   /* Index 0-3: debug address registers */
   /* Index 4-5: reserved */
@@ -50,8 +54,44 @@
   FPR_i386 i387;
 };
 
+#if defined(__FreeBSD__) && (defined(__x86_64__) || defined(__i386__))
+#if defined(__i386__)
+#define reg32 reg
+#endif
+
+// if we're building natively, verify that the structs are correct
+#define ASSERT_GPR(regname)\
+  static_assert(offsetof(GPR, regname) == offsetof(reg32, r_##regname),\
+"GPR offset mismatch for " #regname);  \
+  static_assert(sizeof(GPR::regname) == sizeof(reg32::r_##regname),\
+"GPR size mismatch for " #regname);
+
+ASSERT_GPR(fs);
+ASSERT_GPR(es);
+ASSERT_GPR(ds);
+ASSERT_GPR(edi);
+ASSERT_GPR(esi);
+ASSERT_GPR(ebp);
+ASSERT_GPR(isp);
+ASSERT_GPR(ebx);
+ASSERT_GPR(edx);
+ASSERT_GPR(ecx);
+ASSERT_GPR(eax);
+ASSERT_GPR(trapno);
+ASSERT_GPR(err);
+ASSERT_GPR(eip);
+ASSERT_GPR(cs);
+ASSERT_GPR(eflags);
+ASSERT_GPR(esp);
+ASSERT_GPR(ss);
+ASSERT_GPR(gs);
+
+#undef reg32
+#undef ASSERT_GPR
+#endif
+
 #define DR_SIZE sizeof(uint

[Lldb-commits] [PATCH] D91220: [ThreadPlan] Add a test for `thread step-in -r`, NFC

2020-11-10 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added a reviewer: jingham.
Herald added a project: LLDB.
vsk requested review of this revision.
Herald added a subscriber: JDevlieghere.

Adds test coverage for ThreadPlanStepInRange::SetAvoidRegexp.

See:
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Target/ThreadPlanStepInRange.cpp.html#L309


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91220

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
  lldb/test/API/lang/c/stepping/main.c


Index: lldb/test/API/lang/c/stepping/main.c
===
--- lldb/test/API/lang/c/stepping/main.c
+++ lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 
Index: lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
===
--- /dev/null
+++ lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,52 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line1 = line_number(
+'main.c', '// frame select 2, thread step-out while stopped at 
"c(1)"')
+self.line2 = line_number(
+'main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# Create a breakpoint inside function 'c'.
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line1, num_expected_locations=1)
+
+# Now run the program.
+self.runCmd("run", RUN_SUCCEEDED)
+
+# The process should be stopped at this point.
+self.expect("process status", PROCESS_STOPPED,
+patterns=['Process .* stopped'])
+
+# The frame #0 should correspond to main.c:40, the first line of main.
+self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stop reason = breakpoint"],
+patterns=["frame #0.*main.c:%d" % self.line1])
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access 
exception"


Index: lldb/test/API/lang/c/stepping/main.c
===
--- lldb/test/API/lang/c/stepping/main.c
+++ lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 
Index: lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
===
--- /dev/null
+++ lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,52 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line1 = line_number(
+'main.c', '// frame select 2, thread step-out while stopped at "c(1)"')
+self.line2 = line_number(
+'main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+exe = sel

[Lldb-commits] [lldb] ba21376 - [Command] Fix accidental word concatenation in Options.td

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:13:39-08:00
New Revision: ba21376883d4527204ab6716597ca179e0b76157

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

LOG: [Command] Fix accidental word concatenation in Options.td

Split up words that appear to have been accidentally concatenated.

This looks to be exhaustive: to find these in vim, use:

/\v[^ ]"\n +"[^ ]

Added: 


Modified: 
lldb/source/Commands/Options.td

Removed: 




diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 0be497e4759e..7522f47ca57d 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -372,7 +372,7 @@ let Command = "expression" in {
 "top-level entities without a $ prefix.">;
   def expression_options_allow_jit : Option<"allow-jit", "j">, Groups<[1,2]>,
 Arg<"Boolean">,
-Desc<"Controls whether the expression can fall back to being JITted if 
it's"
+Desc<"Controls whether the expression can fall back to being JITted if 
it's "
 "not supported by the interpreter (defaults to true).">;
 }
 
@@ -952,7 +952,7 @@ let Command = "thread step scope" in {
 EnumArg<"RunMode", "TriRunningModes()">, Desc<"Determine how to run other "
 "threads while stepping the current thread.">;
   def thread_step_scope_step_over_regexp : Option<"step-over-regexp", "r">,
-Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that 
defines"
+Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that 
defines "
 "function names to not to stop at when stepping in.">;
   def thread_step_scope_step_in_target : Option<"step-in-target", "t">,
 Group<1>, Arg<"FunctionName">, Desc<"The name of the directly called "
@@ -965,10 +965,10 @@ let Command = "thread until" in {
   def thread_until_thread : Option<"thread", "t">, Group<1>, 
Arg<"ThreadIndex">,
 Desc<"Thread index for the thread for until operation">;
   def thread_until_run_mode : Option<"run-mode", "m">, Group<1>,
-EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other"
+EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other "
 "threads while stepping this one">;
   def thread_until_address : Option<"address", "a">, Group<1>,
-Arg<"AddressOrExpression">, Desc<"Run until we reach the specified 
address,"
+Arg<"AddressOrExpression">, Desc<"Run until we reach the specified 
address, "
 "or leave the function - can be specified multiple times.">;
 }
 
@@ -1158,7 +1158,7 @@ let Command = "watchpoint list" in {
 "brief description of the watchpoint (no location info).">;
   def watchpoint_list_full : Option<"full", "f">, Group<2>, Desc<"Give a full "
 "description of the watchpoint and its locations.">;
-  def watchpoint_list_verbose : Option<"verbose", "v">, Group<3>, 
Desc<"Explain"
+  def watchpoint_list_verbose : Option<"verbose", "v">, Group<3>, 
Desc<"Explain "
 "everything we know about the watchpoint (for debugging debugger bugs).">;
 }
 



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


[Lldb-commits] [lldb] 04cd6c6 - [ThreadPlan] Delete unused ThreadPlanStepInRange code, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:15:03-08:00
New Revision: 04cd6c62176ce027af2d343044b84ce5d317aee7

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

LOG: [ThreadPlan] Delete unused ThreadPlanStepInRange code, NFC

Added: 


Modified: 
lldb/include/lldb/Target/ThreadPlanStepInRange.h
lldb/source/Target/ThreadPlanStepInRange.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/ThreadPlanStepInRange.h 
b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
index 59b5721998b5..a26b0fb87b3a 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepInRange.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
@@ -26,13 +26,6 @@ class ThreadPlanStepInRange : public ThreadPlanStepRange,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info);
 
-  ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context,
-const char *step_into_function_name,
-lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
-LazyBool step_out_avoids_code_without_debug_info);
-
   ~ThreadPlanStepInRange() override;
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
@@ -78,17 +71,6 @@ class ThreadPlanStepInRange : public ThreadPlanStepRange,
   bool FrameMatchesAvoidCriteria();
 
 private:
-  friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOverRange(
-  bool abort_other_plans, const AddressRange &range,
-  const SymbolContext &addr_context, lldb::RunMode stop_others,
-  Status &status, LazyBool avoid_code_without_debug_info);
-  friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
-  bool abort_other_plans, const AddressRange &range,
-  const SymbolContext &addr_context, const char *step_in_target,
-  lldb::RunMode stop_others, Status &status,
-  LazyBool step_in_avoids_code_without_debug_info,
-  LazyBool step_out_avoids_code_without_debug_info);
-
   void SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
  LazyBool step_out_avoids_code_without_debug_info);
   // Need an appropriate marker for the current stack so we can tell step out

diff  --git a/lldb/source/Target/ThreadPlanStepInRange.cpp 
b/lldb/source/Target/ThreadPlanStepInRange.cpp
index c5f81d6665a1..a03bd93ac638 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -47,22 +47,6 @@ ThreadPlanStepInRange::ThreadPlanStepInRange(
 step_out_avoids_code_without_debug_info);
 }
 
-ThreadPlanStepInRange::ThreadPlanStepInRange(
-Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, const char *step_into_target,
-lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
-LazyBool step_out_avoids_code_without_debug_info)
-: ThreadPlanStepRange(ThreadPlan::eKindStepInRange,
-  "Step Range stepping in", thread, range, 
addr_context,
-  stop_others),
-  ThreadPlanShouldStopHere(this), m_step_past_prologue(true),
-  m_virtual_step(false), m_step_into_target(step_into_target) {
-  SetCallbacks();
-  SetFlagsToDefault();
-  SetupAvoidNoDebug(step_in_avoids_code_without_debug_info,
-step_out_avoids_code_without_debug_info);
-}
-
 ThreadPlanStepInRange::~ThreadPlanStepInRange() = default;
 
 void ThreadPlanStepInRange::SetupAvoidNoDebug(



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


[Lldb-commits] [lldb] 34d56b0 - [ThreadPlan] Reflow docs to fit the 80 column limit, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:14:52-08:00
New Revision: 34d56b05fd78f0d3043f7f02badf7067cecadb30

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

LOG: [ThreadPlan] Reflow docs to fit the 80 column limit, NFC

Added: 


Modified: 
lldb/include/lldb/Target/ThreadPlan.h

Removed: 




diff  --git a/lldb/include/lldb/Target/ThreadPlan.h 
b/lldb/include/lldb/Target/ThreadPlan.h
index 8c2f9776eeb3..f4cd2b18f01a 100644
--- a/lldb/include/lldb/Target/ThreadPlan.h
+++ b/lldb/include/lldb/Target/ThreadPlan.h
@@ -23,310 +23,260 @@
 namespace lldb_private {
 
 //  ThreadPlan:
+//
 //  This is the pure virtual base class for thread plans.
 //
-//  The thread plans provide the "atoms" of behavior that
-//  all the logical process control, either directly from commands or through
-//  more complex composite plans will rely on.
+//  The thread plans provide the "atoms" of behavior that all the logical
+//  process control, either directly from commands or through more complex
+//  composite plans will rely on.
 //
 //  Plan Stack:
 //
-//  The thread maintaining a thread plan stack, and you program the actions of 
a
-//  particular thread
-//  by pushing plans onto the plan stack.
-//  There is always a "Current" plan, which is the top of the plan stack,
-//  though in some cases
+//  The thread maintaining a thread plan stack, and you program the actions of
+//  a particular thread by pushing plans onto the plan stack.  There is always
+//  a "Current" plan, which is the top of the plan stack, though in some cases
 //  a plan may defer to plans higher in the stack for some piece of information
 //  (let us define that the plan stack grows downwards).
 //
 //  The plan stack is never empty, there is always a Base Plan which persists
-//  through the life
-//  of the running process.
+//  through the life of the running process.
 //
 //
 //  Creating Plans:
 //
-//  The thread plan is generally created and added to the plan stack through 
the
-//  QueueThreadPlanFor... API
-//  in lldb::Thread.  Those API's will return the plan that performs the named
-//  operation in a manner
-//  appropriate for the current process.  The plans in lldb/source/Target are
-//  generic
+//  The thread plan is generally created and added to the plan stack through
+//  the QueueThreadPlanFor... API in lldb::Thread.  Those API's will return the
+//  plan that performs the named operation in a manner appropriate for the
+//  current process.  The plans in lldb/source/Target are generic
 //  implementations, but a Process plugin can override them.
 //
 //  ValidatePlan is then called.  If it returns false, the plan is unshipped.
-//  This is a little
-//  convenience which keeps us from having to error out of the constructor.
+//  This is a little convenience which keeps us from having to error out of the
+//  constructor.
 //
 //  Then the plan is added to the plan stack.  When the plan is added to the
-//  plan stack its DidPush
-//  will get called.  This is useful if a plan wants to push any additional
-//  plans as it is constructed,
-//  since you need to make sure you're already on the stack before you push
-//  additional plans.
+//  plan stack its DidPush will get called.  This is useful if a plan wants to
+//  push any additional plans as it is constructed, since you need to make sure
+//  you're already on the stack before you push additional plans.
 //
 //  Completed Plans:
 //
-//  When the target process stops the plans are queried, among other things, 
for
-//  whether their job is done.
-//  If it is they are moved from the plan stack to the Completed Plan stack in
-//  reverse order from their position
-//  on the plan stack (since multiple plans may be done at a given stop.)  This
-//  is used primarily so that
-//  the lldb::Thread::StopInfo for the thread can be set properly.  If one plan
-//  pushes another to achieve part of
-//  its job, but it doesn't want that sub-plan to be the one that sets the
-//  StopInfo, then call SetPrivate on the
-//  sub-plan when you create it, and the Thread will pass over that plan in
-//  reporting the reason for the stop.
+//  When the target process stops the plans are queried, among other things,
+//  for whether their job is done.  If it is they are moved from the plan stack
+//  to the Completed Plan stack in reverse order from their position on the
+//  plan stack (since multiple plans may be done at a given stop.)  This is
+//  used primarily so that the lldb::Thread::StopInfo for the thread can be set
+//  properly.  If one plan pushes another to achieve part of its job, but it
+//  doesn't want that sub-plan to be the one that sets the StopInfo, then call
+//  SetPrivate on the sub-plan when you create it, and the Thread will pass
+//  over 

[Lldb-commits] [PATCH] D77153: [lldb/DataFormatters] Display null C++ pointers as nullptr

2020-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 304352.

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

https://reviews.llvm.org/D77153

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/DataFormatters/ValueObjectPrinter.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
  lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
  lldb/test/API/functionalities/data-formatter/data-formatter-cpp/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  lldb/test/API/lang/c/anonymous/TestAnonymous.py

Index: lldb/test/API/lang/c/anonymous/TestAnonymous.py
===
--- lldb/test/API/lang/c/anonymous/TestAnonymous.py
+++ lldb/test/API/lang/c/anonymous/TestAnonymous.py
@@ -62,7 +62,7 @@
 
 # These should display correctly.
 self.expect("expression pz", VARIABLES_DISPLAYED_CORRECTLY,
-substrs=["(type_z *) $", " = 0x"])
+substrs=["(type_z *) $", " = nullptr"])
 
 self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY,
 substrs=["(type_y) $", "dummy = 2"])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
@@ -74,6 +74,7 @@
 std::u32string u32_string(U"🍄🍅🍆🍌");
 std::u32string u32_empty(U"");
 std::basic_string uchar(5, 'a');
+std::string *null_str = nullptr;
 
 #if _LIBCPP_ABI_VERSION == 1
 std::string garbage1, garbage2, garbage3, garbage4, garbage5;
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -77,6 +77,7 @@
 '(%s::u32string) u32_empty = ""'%ns,
 '(%s::basic_string, '
 '%s::allocator >) uchar = "a"'%(ns,ns,ns),
+'(%s::string *) null_str = nullptr'%ns,
 ])
 
 self.runCmd("n")
@@ -114,6 +115,7 @@
 '(%s::u32string) u32_empty = ""'%ns,
 '(%s::basic_string, '
 '%s::allocator >) uchar = "a"'%(ns,ns,ns),
+'(%s::string *) null_str = nullptr'%ns,
 ])
 
 # The test assumes that std::string is in its cap-size-data layout.
Index: lldb/test/API/functionalities/data-formatter/data-formatter-cpp/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-cpp/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-cpp/main.cpp
@@ -63,6 +63,7 @@
 {
 
 int iAmInt = 1;
+	int* iAmIntPtr = 0;
 const float& IAmFloat = float(2.45);
 
 RealNumber RNILookChar = 3.14;
Index: lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -289,3 +289,6 @@
 matching=False,
 substrs=['(int) iAmInt = 0x0001'])
 self.expect("frame variable iAmInt", substrs=['(int) iAmInt = 1'])
+
+self.expect("frame variable iAmIntPtr",
+substrs=['(int*) iAmIntPtr = nullptr'])
Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
===
--- lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
+++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
@@ -39,4 +39,4 @@
 # Both `std::vector` and the type of the member have forward
 # declarations before their definitions.
 self.expect("expr --raw -- v",
-substrs=['(std::__1::vector) $

[Lldb-commits] [PATCH] D91220: [ThreadPlan] Add a test for `thread step-in -r`, NFC

2020-11-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

It's easier to read these tests if you use "lldbutil.run_to_source_breakpoint" 
to remove all that boilerplate.

Other than that LGTM.  Thanks for adding the test!




Comment at: lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py:27-45
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+# Create a breakpoint inside function 'c'.
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line1, num_expected_locations=1)
+

All this can be collapsed into

lldbutil.run_to_source_breakpoint("// frame select 2, thread step-out...", 
lldb.SBFileSpec("main.c"))

and it will do all the right checks for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91220

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


[Lldb-commits] [PATCH] D91118: Fix handling of bit-fields in a union

2020-11-10 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 304354.
shafik added a comment.

Add a check to make sure the bit offset is zero for fields in a union.


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

https://reviews.llvm.org/D91118

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
  lldb/test/API/lang/cpp/bitfields/main.cpp


Index: lldb/test/API/lang/cpp/bitfields/main.cpp
===
--- lldb/test/API/lang/cpp/bitfields/main.cpp
+++ lldb/test/API/lang/cpp/bitfields/main.cpp
@@ -57,7 +57,7 @@
   f.i = 1;
   f.j = 0;
   f.k = 1;
-} 
+}
   } clang_example;
 
   class B {
@@ -70,6 +70,18 @@
 uint32_t d_a : 1;
   } derived;
 
+  union union_with_bitfields {
+  unsigned int a : 8;
+  unsigned int b : 16;
+  unsigned int c : 32;
+  unsigned int x;
+  } uwbf;
+
+  union union_with_unnamed_bitfield {
+   unsigned int : 16, a : 24;
+   unsigned int x;
+  } uwubf;
+
   lba.a = 2;
 
   lbb.a = 1;
@@ -89,5 +101,8 @@
   derived.b_a = 2;
   derived.d_a = 1;
 
+  uwbf.x = 0x;
+  uwubf.x = 0x;
+
   return 0; // Set break point at this line.
 }
Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
===
--- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -46,6 +46,16 @@
 self.expect("expr (clang_example.f.a)", VARIABLES_DISPLAYED_CORRECTLY,
 substrs=['uint64_t', '1'])
 
+self.expect("expr uwbf",
+substrs=['a = 255',
+'b = 65535',
+'c = 4294967295',
+'x = 4294967295'] )
+
+self.expect("expr uwubf",
+substrs=['a = 16777215',
+'x = 4294967295'] )
+
 self.expect(
 "frame variable --show-types lba",
 VARIABLES_DISPLAYED_CORRECTLY,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2581,7 +2581,11 @@
   // The ObjC runtime knows the byte offset but we still need to 
provide
   // the bit-offset in the layout. It just means something different 
then
   // what it does in C and C++. So we skip this check for ObjC types.
+  //
+  // We also skip this for fields of a union since they will all have a
+  // zero offset.
   if (!TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type) 
&&
+  !(parent_die.Tag() == DW_TAG_union_type && 
this_field_info.bit_offset == 0) &&
   ((this_field_info.bit_offset >= parent_bit_size) ||
(last_field_info.IsBitfield() &&
 !last_field_info.NextBitfieldOffsetIsValid(


Index: lldb/test/API/lang/cpp/bitfields/main.cpp
===
--- lldb/test/API/lang/cpp/bitfields/main.cpp
+++ lldb/test/API/lang/cpp/bitfields/main.cpp
@@ -57,7 +57,7 @@
   f.i = 1;
   f.j = 0;
   f.k = 1;
-} 
+}
   } clang_example;
 
   class B {
@@ -70,6 +70,18 @@
 uint32_t d_a : 1;
   } derived;
 
+  union union_with_bitfields {
+  unsigned int a : 8;
+  unsigned int b : 16;
+  unsigned int c : 32;
+  unsigned int x;
+  } uwbf;
+
+  union union_with_unnamed_bitfield {
+   unsigned int : 16, a : 24;
+   unsigned int x;
+  } uwubf;
+
   lba.a = 2;
 
   lbb.a = 1;
@@ -89,5 +101,8 @@
   derived.b_a = 2;
   derived.d_a = 1;
 
+  uwbf.x = 0x;
+  uwubf.x = 0x;
+
   return 0; // Set break point at this line.
 }
Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
===
--- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -46,6 +46,16 @@
 self.expect("expr (clang_example.f.a)", VARIABLES_DISPLAYED_CORRECTLY,
 substrs=['uint64_t', '1'])
 
+self.expect("expr uwbf",
+substrs=['a = 255',
+'b = 65535',
+'c = 4294967295',
+'x = 4294967295'] )
+
+self.expect("expr uwubf",
+substrs=['a = 16777215',
+'x = 4294967295'] )
+
 self.expect(
 "frame variable --show-types lba",
 VARIABLES_DISPLAYED_CORRECTLY,
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2581,7 +2581,11 @@
   // The ObjC runtime knows the 

[Lldb-commits] [PATCH] D91220: [ThreadPlan] Add a test for `thread step-in -r`, NFC

2020-11-10 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 304355.
vsk added a comment.

Simplify, using run_to_source_breakpoint.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91220

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
  lldb/test/API/lang/c/stepping/main.c


Index: lldb/test/API/lang/c/stepping/main.c
===
--- lldb/test/API/lang/c/stepping/main.c
+++ lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 
Index: lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
===
--- /dev/null
+++ lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,33 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line2 = line_number('main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+lldbutil.run_to_source_breakpoint(self,
+'frame select 2, thread step-out while stopped',
+lldb.SBFileSpec('main.c'))
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access 
exception"


Index: lldb/test/API/lang/c/stepping/main.c
===
--- lldb/test/API/lang/c/stepping/main.c
+++ lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 
Index: lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
===
--- /dev/null
+++ lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,33 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line2 = line_number('main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+lldbutil.run_to_source_breakpoint(self,
+'frame select 2, thread step-out while stopped',
+lldb.SBFileSpec('main.c'))
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access exception"
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90729: [trace][intel-pt] Scaffold the 'thread trace start | stop' commands

2020-11-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Still wondering if we need to do caching in TracePluginCommandDelegate. How 
many times do we fetch the command object if we type "thread trace start"? I 
don't know how much performance is truly needed here at the expense of 
maintaining the caching code.




Comment at: lldb/include/lldb/Target/Process.h:1395
 
+  virtual bool IsLiveDebugSession() const = 0;
+

This should return true as a default implementation. Then only the 
ProcessTrace, and the ProcessMachCore, ProcessMinidump, and ProcessELFCore 
would need to override. We could make a ProcessCore base class that overrides 
this by returning false and then having all of the mentioned core file classes 
inherit from ProcessCore. We also need header documentation for this.

Having a default implementation will help make sure the buildbots stay clean 
for Process plug-ins that are not always built, like ProcessWindows, which we 
missed in this diff.





Comment at: lldb/include/lldb/Target/ProcessTrace.h:1
 //===-- ProcessTrace.h --*- C++ 
-*-===//
 //

Should ProcessTrace and ThreadTrace be moved to the Process plug-in directory?



Comment at: lldb/source/Commands/CommandObjectThread.cpp:2039-2040
+ProcessWP process_wp;
+CommandObjectSP command;
+std::string error;
+  } m_delegate = {};

Should we store the the "command" and "error" as:
```
llvm::Expected expected_command;
```
If so we need a destructor to consume the error, and a method to get the error 
as a string.




Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h:128
 
+  bool IsLiveDebugSession() const override { return true; }
+

we can get rid this and make "true" the default implementation. This will help 
make sure the buildbots stay clean for Process plug-ins that are not always 
built, like ProcessWindows.



Comment at: lldb/source/Plugins/Process/mach-core/ProcessMachCore.h:78
 
+  bool IsLiveDebugSession() const override { return false; }
+

It might be nice to create a Process subclass for core files and have 
ProcessMachCore, ProcessMinidump, ProcessTrace, and ProcessElfCore all inherit. 
They might have other functions we can refactor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90729

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


[Lldb-commits] [PATCH] D90490: [intel-pt][trace] Implement a "get supported trace type" packet

2020-11-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

LGTM with the  error string stuff included so we can get a nice string 
error message. Pavel, do you have anything?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90490

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


[Lldb-commits] [PATCH] D91220: [ThreadPlan] Add a test for `thread step-in -r`, NFC

2020-11-10 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae3640e386cc: [ThreadPlan] Add a test for `thread step-in 
-r`, NFC (authored by vsk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91220

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
  lldb/test/API/lang/c/stepping/main.c


Index: lldb/test/API/lang/c/stepping/main.c
===
--- lldb/test/API/lang/c/stepping/main.c
+++ lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 
Index: lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
===
--- /dev/null
+++ lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,33 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line2 = line_number('main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+lldbutil.run_to_source_breakpoint(self,
+'frame select 2, thread step-out while stopped',
+lldb.SBFileSpec('main.c'))
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access 
exception"


Index: lldb/test/API/lang/c/stepping/main.c
===
--- lldb/test/API/lang/c/stepping/main.c
+++ lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 
Index: lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
===
--- /dev/null
+++ lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,33 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line2 = line_number('main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+lldbutil.run_to_source_breakpoint(self,
+'frame select 2, thread step-out while stopped',
+lldb.SBFileSpec('main.c'))
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access exception"
___

[Lldb-commits] [lldb] 9922dde - [test] Delete redundant lldbutil import, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:37:47-08:00
New Revision: 9922dded4737ff640f046f62f83bf1d05f26d97d

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

LOG: [test] Delete redundant lldbutil import, NFC

Added: 


Modified: 
lldb/test/API/lang/c/stepping/TestThreadStepping.py

Removed: 




diff  --git a/lldb/test/API/lang/c/stepping/TestThreadStepping.py 
b/lldb/test/API/lang/c/stepping/TestThreadStepping.py
index 43ed10d8b1a8..c134c95cf485 100644
--- a/lldb/test/API/lang/c/stepping/TestThreadStepping.py
+++ b/lldb/test/API/lang/c/stepping/TestThreadStepping.py
@@ -5,7 +5,6 @@
 
 
 import lldb
-import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
 import lldbsuite.test.lldbutil as lldbutil
 



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


[Lldb-commits] [lldb] ae3640e - [ThreadPlan] Add a test for `thread step-in -r`, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:37:47-08:00
New Revision: ae3640e386ccfbe0e984cc8c4b0399006ed835c7

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

LOG: [ThreadPlan] Add a test for `thread step-in -r`, NFC

Adds test coverage for ThreadPlanStepInRange::SetAvoidRegexp.

See:
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Target/ThreadPlanStepInRange.cpp.html#L309

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

Added: 
lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py

Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/lang/c/stepping/main.c

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index f7d59a8a065c..89c25eb55516 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access 
exception"

diff  --git a/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py 
b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
new file mode 100644
index ..0b59f625bd69
--- /dev/null
+++ b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,33 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line2 = line_number('main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+lldbutil.run_to_source_breakpoint(self,
+'frame select 2, thread step-out while stopped',
+lldb.SBFileSpec('main.c'))
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])

diff  --git a/lldb/test/API/lang/c/stepping/main.c 
b/lldb/test/API/lang/c/stepping/main.c
index 43b5cfab183a..8237ebf984c9 100644
--- a/lldb/test/API/lang/c/stepping/main.c
+++ b/lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@ int main (int argc, char const *argv[])
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 



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


[Lldb-commits] [PATCH] D91130: [crashlog] Implement parser for JSON encoded crashlogs

2020-11-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

JSON crash logs are almost here??? I remember asking for those back when I was 
at Apple! Great news.

It would be nice to have a crash log from a small but real process we might be 
able to load as an end to end test?




Comment at: lldb/examples/python/crashlog.py:413-414
+self.parse_process_info(self.data)
+self.parse_images(self.data['usedImages'])
+self.parse_threads(self.data['threads'])
+

you ok with this raising throwing an exception when/if these key/value pairs 
are not in the file?


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

https://reviews.llvm.org/D91130

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


[Lldb-commits] [PATCH] D90729: [trace][intel-pt] Scaffold the 'thread trace start | stop' commands

2020-11-10 Thread walter erquinigo via Phabricator via lldb-commits
wallace planned changes to this revision.
wallace added a comment.

- After taking a second look I realized I don't need caching. For some reason I 
thought that autocompletion would be triggered with every keystroke, and that's 
why caching would be useful. But I was wrong all along! These queries will be 
rare and there's no need for caching.
- Good idea with the default implementation for IsLiveDebugSession


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90729

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


[Lldb-commits] [PATCH] D91220: [ThreadPlan] Add a test for `thread step-in -r`, NFC

2020-11-10 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

This test is failing on the Windows bot:

http://lab.llvm.org:8011/#/builders/83/builds/678


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91220

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


[Lldb-commits] [PATCH] D91130: [crashlog] Implement parser for JSON encoded crashlogs

2020-11-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

In D91130#2387390 , @clayborg wrote:

> JSON crash logs are almost here??? I remember asking for those back when I 
> was at Apple! Great news.

Yep! 🥳

> It would be nice to have a crash log from a small but real process we might 
> be able to load as an end to end test?

I'd be happy to, but is there a way to test the crashlog script without having 
a `dsymForUUID`?




Comment at: lldb/examples/python/crashlog.py:413-414
+self.parse_process_info(self.data)
+self.parse_images(self.data['usedImages'])
+self.parse_threads(self.data['threads'])
+

clayborg wrote:
> you ok with this raising throwing an exception when/if these key/value pairs 
> are not in the file?
Yeah, at least initially. It appears the format is still not locked down, so I 
hope this will give us more signal when things end up changing. But good point, 
long term we should be more defensive. 


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

https://reviews.llvm.org/D91130

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