[Lldb-commits] [lldb] 757ac4c - [lldb] Reword CompilerType docstring to not say "generic type"

2020-09-15 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2020-09-15T22:14:57-07:00
New Revision: 757ac4ccfb8b024454b4f445a2b5c8985da5dc8a

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

LOG: [lldb] Reword CompilerType docstring to not say "generic type"

Since "generic type" has a precise meaning in some languages, reword the 
docstring of `CompilerType` to avoid ambiguity.

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

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index c5e19773d51c..614373938165 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -20,7 +20,7 @@ namespace lldb_private {
 
 class DataExtractor;
 
-/// Represents a generic type in a programming language.
+/// Generic representation of a type in a programming language.
 ///
 /// This class serves as an abstraction for a type inside one of the 
TypeSystems
 /// implemented by the language plugins. It does not have any actual logic in 
it



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


[Lldb-commits] [PATCH] D87633: [lldb] Reword CompilerType docstring to not say "generic type"

2020-09-15 Thread Dave Lee 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 rG757ac4ccfb8b: [lldb] Reword CompilerType docstring to not 
say generic type (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87633

Files:
  lldb/include/lldb/Symbol/CompilerType.h


Index: lldb/include/lldb/Symbol/CompilerType.h
===
--- lldb/include/lldb/Symbol/CompilerType.h
+++ lldb/include/lldb/Symbol/CompilerType.h
@@ -20,7 +20,7 @@
 
 class DataExtractor;
 
-/// Represents a generic type in a programming language.
+/// Generic representation of a type in a programming language.
 ///
 /// This class serves as an abstraction for a type inside one of the 
TypeSystems
 /// implemented by the language plugins. It does not have any actual logic in 
it


Index: lldb/include/lldb/Symbol/CompilerType.h
===
--- lldb/include/lldb/Symbol/CompilerType.h
+++ lldb/include/lldb/Symbol/CompilerType.h
@@ -20,7 +20,7 @@
 
 class DataExtractor;
 
-/// Represents a generic type in a programming language.
+/// Generic representation of a type in a programming language.
 ///
 /// This class serves as an abstraction for a type inside one of the TypeSystems
 /// implemented by the language plugins. It does not have any actual logic in it
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D87626: Fix .debug_aranges parsing.

2020-09-15 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Wow :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87626

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


[Lldb-commits] [PATCH] D87730: [intel-pt] Pretty print the instruction list

2020-09-15 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 292060.
wallace added a comment.

remove whitespace changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87730

Files:
  lldb/include/lldb/Target/Trace.h
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/test/API/commands/trace/TestTraceDump.py
  lldb/test/API/commands/trace/intelpt-trace-multi-function/a.out
  lldb/test/API/commands/trace/intelpt-trace-multi-function/main.cpp
  lldb/test/API/commands/trace/intelpt-trace-multi-function/multi-function.trace
  lldb/test/API/commands/trace/intelpt-trace-multi-function/other.cpp
  lldb/test/API/commands/trace/intelpt-trace-multi-function/other.h
  lldb/test/API/commands/trace/intelpt-trace-multi-function/trace.json

Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/trace.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/trace.json
@@ -0,0 +1,31 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+{
+  "pid": 1234,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 1981309,
+  "traceFile": "multi-function.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x0040",
+  "uuid": "13A5952D-66DE-EE86-C44F-CD91816AE259-CD06AB8D"
+}
+  ]
+}
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/other.h
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/other.h
@@ -0,0 +1 @@
+int foo();
Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/other.cpp
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/other.cpp
@@ -0,0 +1,4 @@
+int foo() {
+  int x = 42;
+  return x;
+}
Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/main.cpp
@@ -0,0 +1,16 @@
+#include "other.h"
+
+int bar() {
+  int ret = 0;
+
+  for (int i = 0; i < 4; i++)
+ret += foo();
+
+  return ret;
+}
+
+int main() {
+  int ret = bar();
+
+  return ret > 0;
+}
Index: lldb/test/API/commands/trace/TestTraceDump.py
===
--- lldb/test/API/commands/trace/TestTraceDump.py
+++ lldb/test/API/commands/trace/TestTraceDump.py
@@ -51,51 +51,113 @@
 trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace2.json")
 self.expect("trace load " + trace_definition_file)
 
+# Dump the instructions of the currently selected thread in raw mode
+self.expect("trace dump -i -r", substrs=['''Instructions:
+pid: '2', tid: '21'
+  0x40052d
+  0x400529
+  0x400525
+  0x400521
+  0x40052d
+  0x400529
+  0x400525
+  0x400521
+  0x40052d
+  0x400529'''])
+
 # Dump the instructions of the currently selected thread
 self.expect("trace dump -i", substrs=['''Instructions:
 pid: '2', tid: '21'
-  4195629
-  4195625
-  4195621
-  4195617
-  4195629
-  4195625
-  4195621
-  4195617
-  4195629
-  4195625'''])
+  a.out`main
+  [21] 0x40052d <+32>: jle0x400521  ; <+20> at main.cpp:5
+  [20] 0x400529 <+28>: cmpl   $0x3, -0x8(%rbp)
+  [19] 0x400525 <+24>: addl   $0x1, -0x8(%rbp)
+  [18] 0x400521 <+20>: xorl   $0x1, -0x4(%rbp)
+  [17] 0x40052d <+32>: jle0x400521  ; <+20> at main.cpp:5
+  [16] 0x400529 <+28>: cmpl   $0x3, -0x8(%rbp)
+  [15] 0x400525 <+24>: addl   $0x1, -0x8(%rbp)
+  [14] 0x400521 <+20>: xorl   $0x1, -0x4(%rbp)
+  [13] 0x40052d <+32>: jle0x400521  ; <+20> at main.cpp:5
+  [12] 0x400529 <+28>: cmpl   $0x3, -0x8(%rbp)'''])
 
 # Dump the instructions of one specific thread
 self.expect("trace dump -i -t 22", substrs=['''Instructions:
 pid: '2', tid: '22'
-  4195629
-  4195625
-  4195621
-  4195617
-  4195629
-  4195625
-  4195621
-  4195617
-  4195629
-  4195625'''])
+  a.out`main
+  [21] 0x40052d <+32>: jle0x400521  ; <+20> at main.cpp:5
+  [20] 0x400529 <+28>: cmpl   $0x3, -0x8(%rbp)
+  [19] 0x400525 <+24>: addl   $0x1, -0x8(%rbp)
+  [18] 0x400521 <+20>: xorl   $0x1, -0x4(%rbp)
+  [17] 0x40052d <+32>: jle0x400521  ; <+20> at main.cpp:5
+  [16] 0x400529 <+28>: cmpl   $0x3, -0x8(%rbp)
+  [15] 0x400525 <+24>: addl   $0x1, -0x8(%rbp)
+  [14] 0x400521 <+20>: xorl   $0x1, -0x4(%rbp)
+  [13] 0x40052d 

[Lldb-commits] [PATCH] D87730: [intel-pt] Pretty print the instruction list

2020-09-15 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added a reviewer: clayborg.
Herald added subscribers: lldb-commits, dang.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLDB.
wallace requested review of this revision.

Depends on D87589 .

In D87589  I added the basic instruction 
decoding functionality and the Dump action was printing the raw strings. I'm 
now pretty printing the instructions, with an output like the following:

  pid: '1234', tid: '1981309'
a.out`main
[57] 0x400549 <+13>: movl   %eax, -0x4(%rbp)
a.out`bar()
[56] 0x40053b <+46>: retq
[55] 0x40053a <+45>: leave
[54] 0x400537 <+42>: movl   -0x4(%rbp), %eax
[53] 0x400535 <+40>: jle0x400525  ; <+24> at main.cpp:7
[52] 0x400531 <+36>: cmpl   $0x3, -0x8(%rbp)
[51] 0x40052d <+32>: addl   $0x1, -0x8(%rbp)
[50] 0x40052a <+29>: addl   %eax, -0x4(%rbp)
a.out`foo()
[49] 0x400567 <+15>: retq
[48] 0x400566 <+14>: popq   %rbp
[47] 0x400563 <+11>: movl   -0x4(%rbp), %eax
[46] 0x40055c <+4>: movl   $0x2a, -0x4(%rbp)
[45] 0x400559 <+1>: movq   %rsp, %rbp
[44] 0x400558 <+0>: pushq  %rbp

There's also a --raw flag that prints simply the instructions.

An important remark is that the decoder can fail to decode some instructions, 
which we are printing, for example:

pid: '1234', tid: '3842849'

  [4] 0x400529 <+28>: cmpl   $0x3, -0x8(%rbp)
  [3] error -13. 'no memory mapped at this address'
  [2] 0x40052d <+32>: jle0x400521  

As an implementation note, I'm using lldb's Disassembler. I couldn't move the 
entire printing logic to the disassembler because it assumes that all 
instuctions printed are valid, which conflicts with what the intel-pt decoder 
outputs.

Finally, the instruction dumping command is as follows:

  trace dump -i [-rv] [-c ] [-o ] [-t ]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87730

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/include/lldb/Target/Trace.h
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/test/API/commands/trace/TestTraceDump.py
  lldb/test/API/commands/trace/intelpt-trace-multi-function/a.out
  lldb/test/API/commands/trace/intelpt-trace-multi-function/main.cpp
  lldb/test/API/commands/trace/intelpt-trace-multi-function/multi-function.trace
  lldb/test/API/commands/trace/intelpt-trace-multi-function/other.cpp
  lldb/test/API/commands/trace/intelpt-trace-multi-function/other.h
  lldb/test/API/commands/trace/intelpt-trace-multi-function/trace.json

Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/trace.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/trace.json
@@ -0,0 +1,31 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+{
+  "pid": 1234,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 1981309,
+  "traceFile": "multi-function.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x0040",
+  "uuid": "13A5952D-66DE-EE86-C44F-CD91816AE259-CD06AB8D"
+}
+  ]
+}
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/other.h
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/other.h
@@ -0,0 +1 @@
+int foo();
Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/other.cpp
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/other.cpp
@@ -0,0 +1,4 @@
+int foo() {
+  int x = 42;
+  return x;
+}
Index: lldb/test/API/commands/trace/intelpt-trace-multi-function/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-function/main.cpp
@@ -0,0 +1,16 @@
+#include "other.h"
+
+int bar() {
+  int ret = 0;
+
+  for (int i = 0; i < 4; i++)
+ret += foo();
+
+  return ret;
+}
+
+int main() {
+  int ret = bar();
+
+  return ret > 0;
+}
Index: lldb/test/API/commands/trace/TestTraceDump.py
===
--- lldb/test/API/commands/trace/TestTraceDump.py
+++ lldb/test/API/commands/trace/TestTraceDump.py
@@ -51,51 +51,113 @@
 trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace2.json")
 self.expect("trace load " + trace_definition_file)
 
+# Dump the instructions of the currently selected thread in raw mode
+self.expect("trace dump -i -r", 

[Lldb-commits] [lldb] 79f22b1 - Fix .debug_aranges parsing.

2020-09-15 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2020-09-15T11:50:57-07:00
New Revision: 79f22b1f99fd72db9a45c387258d289791f2b9c0

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

LOG: Fix .debug_aranges parsing.

Code was added that used llvm error checking to parse .debug_aranges, but the 
error check after parsing the DWARFDebugArangesSet was reversed and was causing 
no error to be returned with no valid address ranges being actually used. This 
meant we always would fall back onto creating out own address ranges by parsing 
the compile unit's ranges. This was causing problems for cases where the 
DW_TAG_compile_unit had a single address range by using a DW_AT_low_pc and 
DW_AT_high_pc attribute pair (not using a DW_AT_ranges attribute), but the 
.debug_aranges had correct split ranges. In this case we would end up using the 
single range for the compile unit that encompassed all of the ranges from the 
.debug_aranges section and would cause address resolving issues in LLDB where 
address lookups would fail for certain addresses.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
index 7dc52c1e2df0..7062c9bfae23 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
@@ -39,7 +39,7 @@ DWARFDebugAranges::extract(const DWARFDataExtractor 
_aranges_data) {
   Range range;
   while (debug_aranges_data.ValidOffset(offset)) {
 llvm::Error error = set.extract(debug_aranges_data, );
-if (!error)
+if (error)
   return error;
 
 const uint32_t num_descriptors = set.NumDescriptors();

diff  --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp 
b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
index 8bf019ea9ed6..4898b94413ca 100644
--- a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -19,6 +19,7 @@
 #include "Plugins/SymbolFile/DWARF/DWARFDataExtractor.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugAranges.h"
 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
 #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
@@ -70,7 +71,7 @@ TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) {
 TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
   // Test that if we have a .debug_abbrev that contains ordered abbreviation
   // codes that start at 1, that we get O(1) access.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -81,7 +82,7 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(2); // Abbrev code 2
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -89,9 +90,9 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(0); // Abbrev code 0 (termination)
- 
+
   DWARFDataExtractor data;
   data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
   DWARFAbbreviationDeclarationSet abbrev_set;
@@ -101,7 +102,7 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
   // Make sure we have O(1) access to each abbreviation by making sure the
   // index offset is 1 and not UINT32_MAX
   EXPECT_EQ(abbrev_set.GetIndexOffset(), 1u);
-  
+
   auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(1);
   EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit);
   EXPECT_TRUE(abbrev1->HasChildren());
@@ -115,7 +116,7 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
 TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start5) {
   // Test that if we have a .debug_abbrev that contains ordered abbreviation
   // codes that start at 5, that we get O(1) access.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -126,7 +127,7 @@ TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start5) {
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(6); // Abbrev code 6
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -134,9 

[Lldb-commits] [PATCH] D87626: Fix .debug_aranges parsing.

2020-09-15 Thread Greg Clayton 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 rG79f22b1f99fd: Fix .debug_aranges parsing. (authored by 
clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87626

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -19,6 +19,7 @@
 #include "Plugins/SymbolFile/DWARF/DWARFDataExtractor.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugAranges.h"
 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
 #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
@@ -70,7 +71,7 @@
 TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start1) {
   // Test that if we have a .debug_abbrev that contains ordered abbreviation
   // codes that start at 1, that we get O(1) access.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -81,7 +82,7 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(2); // Abbrev code 2
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -89,9 +90,9 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(0); // Abbrev code 0 (termination)
- 
+
   DWARFDataExtractor data;
   data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
   DWARFAbbreviationDeclarationSet abbrev_set;
@@ -101,7 +102,7 @@
   // Make sure we have O(1) access to each abbreviation by making sure the
   // index offset is 1 and not UINT32_MAX
   EXPECT_EQ(abbrev_set.GetIndexOffset(), 1u);
-  
+
   auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(1);
   EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit);
   EXPECT_TRUE(abbrev1->HasChildren());
@@ -115,7 +116,7 @@
 TEST_F(SymbolFileDWARFTests, TestAbbrevOrder1Start5) {
   // Test that if we have a .debug_abbrev that contains ordered abbreviation
   // codes that start at 5, that we get O(1) access.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -126,7 +127,7 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(6); // Abbrev code 6
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -134,9 +135,9 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(0); // Abbrev code 0 (termination)
-  
+
   DWARFDataExtractor data;
   data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
   DWARFAbbreviationDeclarationSet abbrev_set;
@@ -146,7 +147,7 @@
   // Make sure we have O(1) access to each abbreviation by making sure the
   // index offset is 5 and not UINT32_MAX
   EXPECT_EQ(abbrev_set.GetIndexOffset(), 5u);
-  
+
   auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(5);
   EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit);
   EXPECT_TRUE(abbrev1->HasChildren());
@@ -160,7 +161,7 @@
 TEST_F(SymbolFileDWARFTests, TestAbbrevOutOfOrder) {
   // Test that if we have a .debug_abbrev that contains unordered abbreviation
   // codes, that we can access the information correctly.
-  
+
   const auto byte_order = eByteOrderLittle;
   const uint8_t addr_size = 4;
   StreamString encoder(Stream::eBinary, addr_size, byte_order);
@@ -171,7 +172,7 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(1); // Abbrev code 1
   encoder.PutULEB128(DW_TAG_subprogram);
   encoder.PutHex8(DW_CHILDREN_no);
@@ -179,9 +180,9 @@
   encoder.PutULEB128(DW_FORM_strp);
   encoder.PutULEB128(0);
   encoder.PutULEB128(0);
-  
+
   encoder.PutULEB128(0); // Abbrev code 0 (termination)
-  
+
   DWARFDataExtractor data;
   data.SetData(encoder.GetData(), encoder.GetSize(), byte_order);
   DWARFAbbreviationDeclarationSet abbrev_set;
@@ -191,7 +192,7 @@
   // Make sure we don't have O(1) access to each abbreviation by making sure
   // the index offset is UINT32_MAX
   EXPECT_EQ(abbrev_set.GetIndexOffset(), UINT32_MAX);
-  
+
   auto abbrev1 = abbrev_set.GetAbbreviationDeclaration(2);
   EXPECT_EQ(abbrev1->Tag(), DW_TAG_compile_unit);
   EXPECT_TRUE(abbrev1->HasChildren());
@@ -205,7 +206,7 @@
 TEST_F(SymbolFileDWARFTests, TestAbbrevInvalidNULLTag) {
   // 

[Lldb-commits] [PATCH] D86996: [lldb] Add -l/--language option to script command

2020-09-15 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: llvm/lib/Support/MemoryBuffer.cpp:460
 
-  if (shouldUseMmap(FD, FileSize, MapSize, Offset, RequiresNullTerminator,
-PageSize, IsVolatile)) {
+  if (false) {
 std::error_code EC;

I guess this was unintended. Fixed in 03f1516d6075f42dce95bcf9fde3f6fde97abd35


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86996

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


[Lldb-commits] [PATCH] D86996: [lldb] Add -l/--language option to script command

2020-09-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG127faae7529a: [lldb] Add -l/--language option to script 
command (authored by JDevlieghere).
Herald added subscribers: llvm-commits, hiraditya.
Herald added projects: LLDB, LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D86996?vs=290596=291960#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86996

Files:
  lldb/source/Commands/CommandObjectScript.cpp
  lldb/source/Commands/CommandObjectScript.h
  lldb/source/Commands/Options.td
  lldb/test/Shell/ScriptInterpreter/Lua/lua-python.test
  lldb/test/Shell/ScriptInterpreter/Lua/lua.test
  lldb/test/Shell/ScriptInterpreter/Python/python.test
  llvm/lib/Support/MemoryBuffer.cpp

Index: llvm/lib/Support/MemoryBuffer.cpp
===
--- llvm/lib/Support/MemoryBuffer.cpp
+++ llvm/lib/Support/MemoryBuffer.cpp
@@ -457,8 +457,7 @@
 MapSize = FileSize;
   }
 
-  if (shouldUseMmap(FD, FileSize, MapSize, Offset, RequiresNullTerminator,
-PageSize, IsVolatile)) {
+  if (false) {
 std::error_code EC;
 std::unique_ptr Result(
 new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile(
Index: lldb/test/Shell/ScriptInterpreter/Python/python.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/python.test
@@ -0,0 +1,13 @@
+# REQUIRES: python
+# RUN: %lldb --script-language python -o 'script print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s
+# RUN: %lldb --script-language python -o 'script -- print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s
+# RUN: %lldb --script-language python -o 'script --language default -- print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s
+# RUN: %lldb -o 'script -l python -- print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s
+# RUN: %lldb -o 'script -lpython -- print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s
+# RUN: %lldb -o 'script --language python -- print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s
+# RUN: %lldb -o 'script --language=python -- print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s
+# CHECK: 
+
+# RUN: %lldb -o 'script --language invalid -- print("{}".format(1000+100+10+1))' 2>&1 | FileCheck %s --check-prefix INVALID
+# INVALID: error: unrecognized value for language 'invalid'
+# INVALID-NOT: 
Index: lldb/test/Shell/ScriptInterpreter/Lua/lua.test
===
--- lldb/test/Shell/ScriptInterpreter/Lua/lua.test
+++ lldb/test/Shell/ScriptInterpreter/Lua/lua.test
@@ -1,3 +1,7 @@
 # REQUIRES: lua
-# RUN: %lldb --script-language lua -o 'script print(1000+100+10+1)' 2>&1 | FileCheck %s
+# RUN: %lldb --script-language lua -o 'script io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s
+# RUN: %lldb --script-language lua -o 'script -- io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s
+# RUN: %lldb --script-language lua -o 'script --language default -- io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s
+# RUN: %lldb -o 'script -l lua -- io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s
+# RUN: %lldb -o 'script --language lua -- io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s
 # CHECK: 
Index: lldb/test/Shell/ScriptInterpreter/Lua/lua-python.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/lua-python.test
@@ -0,0 +1,17 @@
+# REQUIRES: lua
+# REQUIRES: python
+# UNSUPPORTED: lldb-repro
+
+# RUN: mkdir -p %t
+# RUN: cd %t
+# RUN: echo "int main() { return 0; }" | %clang_host -x c - -o a.out
+# RUN: cat %s | %lldb 2>&1 | FileCheck %s
+script -l lua --
+target = lldb.debugger:CreateTarget("a.out")
+print("target is valid:", tostring(target:IsValid()))
+lldb.debugger:SetSelectedTarget(target)
+quit
+# CHECK: target is valid: true
+script -l python --
+print("selected target: {}".format(lldb.debugger.GetSelectedTarget()))
+# CHECK: selected target: a.out
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -717,6 +717,12 @@
 "LLDB event system.">;
 }
 
+let Command = "script" in {
+  def script_language : Option<"language", "l">,
+EnumArg<"ScriptLang", "ScriptOptionEnum()">, Desc<"Specify the scripting "
+" language. If none is specific the default scripting language is used.">;
+}
+
 let Command = "source info" in {
   def source_info_count : Option<"count", "c">, Arg<"Count">,
 Desc<"The number of line entries to display.">;
Index: lldb/source/Commands/CommandObjectScript.h
===
--- lldb/source/Commands/CommandObjectScript.h
+++ lldb/source/Commands/CommandObjectScript.h
@@ 

[Lldb-commits] [lldb] 127faae - [lldb] Add -l/--language option to script command

2020-09-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-09-15T09:40:17-07:00
New Revision: 127faae7529aee7e8508abebbc19212ce30bbf27

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

LOG: [lldb] Add -l/--language option to script command

Make it possible to run the script command with a different language
than currently selected.

  $ ./bin/lldb -l python
  (lldb) script -l lua
  >>> io.stdout:write("Hello, World!\n")
  Hello, World!

When passing the language option and a raw command, you need to separate
the flag from the script code with --.

  $ ./bin/lldb -l python
  (lldb) script -l lua -- io.stdout:write("Hello, World!\n")
  Hello, World!

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

Added: 
lldb/test/Shell/ScriptInterpreter/Lua/lua-python.test
lldb/test/Shell/ScriptInterpreter/Python/python.test

Modified: 
lldb/source/Commands/CommandObjectScript.cpp
lldb/source/Commands/CommandObjectScript.h
lldb/source/Commands/Options.td
lldb/test/Shell/ScriptInterpreter/Lua/lua.test
llvm/lib/Support/MemoryBuffer.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectScript.cpp 
b/lldb/source/Commands/CommandObjectScript.cpp
index e5ae244cade1..9dadf11ebfc8 100644
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ b/lldb/source/Commands/CommandObjectScript.cpp
@@ -10,36 +10,107 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Host/Config.h"
+#include "lldb/Host/OptionParser.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Utility/Args.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-// CommandObjectScript
+static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
+{
+eScriptLanguagePython,
+"python",
+"Python",
+},
+{
+eScriptLanguageLua,
+"lua",
+"Lua",
+},
+{
+eScriptLanguageNone,
+"default",
+"The default scripting language.",
+},
+};
+
+static constexpr OptionEnumValues ScriptOptionEnum() {
+  return OptionEnumValues(g_script_option_enumeration);
+}
+
+#define LLDB_OPTIONS_script
+#include "CommandOptions.inc"
+
+Status CommandObjectScript::CommandOptions::SetOptionValue(
+uint32_t option_idx, llvm::StringRef option_arg,
+ExecutionContext *execution_context) {
+  Status error;
+  const int short_option = m_getopt_table[option_idx].val;
+
+  switch (short_option) {
+  case 'l':
+language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
+option_arg, GetDefinitions()[option_idx].enum_values,
+eScriptLanguageNone, error);
+if (!error.Success())
+  error.SetErrorStringWithFormat("unrecognized value for language '%s'",
+ option_arg.str().c_str());
+break;
+  default:
+llvm_unreachable("Unimplemented option");
+  }
+
+  return error;
+}
+
+void CommandObjectScript::CommandOptions::OptionParsingStarting(
+ExecutionContext *execution_context) {
+  language = lldb::eScriptLanguageNone;
+}
+
+llvm::ArrayRef
+CommandObjectScript::CommandOptions::GetDefinitions() {
+  return llvm::makeArrayRef(g_script_options);
+}
 
 CommandObjectScript::CommandObjectScript(CommandInterpreter )
 : CommandObjectRaw(
   interpreter, "script",
   "Invoke the script interpreter with provided code and display any "
   "results.  Start the interactive interpreter if no code is 
supplied.",
-  "script []") {}
+  "script [--language  --] []") {}
 
 CommandObjectScript::~CommandObjectScript() {}
 
 bool CommandObjectScript::DoExecute(llvm::StringRef command,
 CommandReturnObject ) {
-  if (m_interpreter.GetDebugger().GetScriptLanguage() ==
-  lldb::eScriptLanguageNone) {
+  // Try parsing the language option but when the command contains a raw part
+  // separated by the -- delimiter.
+  OptionsWithRaw raw_args(command);
+  if (raw_args.HasArgs()) {
+if (!ParseOptions(raw_args.GetArgs(), result))
+  return false;
+command = raw_args.GetRawPart();
+  }
+
+  lldb::ScriptLanguage language =
+  (m_options.language == lldb::eScriptLanguageNone)
+  ? m_interpreter.GetDebugger().GetScriptLanguage()
+  : m_options.language;
+
+  if (language == lldb::eScriptLanguageNone) {
 result.AppendError(
 "the script-lang setting is set to none - scripting not available");
 result.SetStatus(eReturnStatusFailed);
 return false;
   }
 
-  ScriptInterpreter *script_interpreter = GetDebugger().GetScriptInterpreter();
+  ScriptInterpreter 

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

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

In D87333#2273506 , @labath wrote:

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

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

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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

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

[Lldb-commits] [PATCH] D86996: [lldb] Add -l/--language option to script command

2020-09-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D86996#2273445 , @labath wrote:

> This looks fine (sorry about the delay, I've been OOO).

I hope you had a good time. Glad to have you back! :-)




Comment at: lldb/test/Shell/ScriptInterpreter/Lua/lua.test:2
 # REQUIRES: lua
-# RUN: %lldb --script-language lua -o 'script print(1000+100+10+1)' 2>&1 | 
FileCheck %s
+# RUN: %lldb --script-language lua -o 'script -- 
io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s
+# RUN: %lldb --script-language lua -o 'script --language default -- 
io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s

labath wrote:
> Did you add the `--` here just for consistency? It believe it should not be 
> necessary to use the double dash if the script command has no arguments 
> (similar to how its possible to write `expr 1+2` without any dashes (but 
> `expr -A -- 1+2` does require it)
I think I meant to have both but updated the line without copying it first. 
I'll fix that before landing. 


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

https://reviews.llvm.org/D86996

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


[Lldb-commits] [PATCH] D87694: [lldb] Don't send invalid region addresses to lldb server

2020-09-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
DavidSpickett requested review of this revision.

Previously when  in "memory region " didn't
parse correctly, we'd print an error then also ask lldb-server
for a region containing LLDB_INVALID_ADDRESS.

(lldb) memory region not_an_address
error: invalid address argument "not_an_address"...
error: Server returned invalid range

Only send the command to lldb-server if the address
parsed correctly.

(lldb) memory region not_an_address
error: invalid address argument "not_an_address"...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87694

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/API/functionalities/memory-region/TestMemoryRegion.py


Index: lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
===
--- lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
+++ lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
@@ -41,6 +41,16 @@
 self.assertFalse(result.Succeeded())
 self.assertRegexpMatches(result.GetError(), "Usage: memory region 
ADDR")
 
+# Test that when the address fails to parse, we do not carry on
+# and ask lldb-server for an invalid address
+interp.HandleCommand("memory region not_an_address", result)
+self.assertFalse(result.Succeeded())
+self.assertRegexpMatches(result.GetError(),
+"error: invalid address argument \"not_an_address\"")
+# This would be found if we carried on despite the error
+self.assertNotRegexpMatches(result.GetError(),
+"error: Server returned invalid range")
+
 # Now let's print the memory region starting at 0 which should always 
work.
 interp.HandleCommand("memory region 0x0", result)
 self.assertTrue(result.Succeeded())
Index: lldb/source/Commands/CommandObjectMemory.cpp
===
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -1710,32 +1710,34 @@
   }
 }
 
-lldb_private::MemoryRegionInfo range_info;
-error = process_sp->GetMemoryRegionInfo(load_addr, range_info);
-if (error.Success()) {
-  lldb_private::Address addr;
-  ConstString name = range_info.GetName();
-  ConstString section_name;
-  if (process_sp->GetTarget().ResolveLoadAddress(load_addr, addr)) {
-SectionSP section_sp(addr.GetSection());
-if (section_sp) {
-  // Got the top most section, not the deepest section
-  while (section_sp->GetParent())
-section_sp = section_sp->GetParent();
-  section_name = section_sp->GetName();
+if (load_addr != LLDB_INVALID_ADDRESS) {
+  lldb_private::MemoryRegionInfo range_info;
+  error = process_sp->GetMemoryRegionInfo(load_addr, range_info);
+  if (error.Success()) {
+lldb_private::Address addr;
+ConstString name = range_info.GetName();
+ConstString section_name;
+if (process_sp->GetTarget().ResolveLoadAddress(load_addr, addr)) {
+  SectionSP section_sp(addr.GetSection());
+  if (section_sp) {
+// Got the top most section, not the deepest section
+while (section_sp->GetParent())
+  section_sp = section_sp->GetParent();
+section_name = section_sp->GetName();
+  }
 }
+result.AppendMessageWithFormatv(
+"[{0:x16}-{1:x16}) {2:r}{3:w}{4:x}{5}{6}{7}{8}\n",
+range_info.GetRange().GetRangeBase(),
+range_info.GetRange().GetRangeEnd(), range_info.GetReadable(),
+range_info.GetWritable(), range_info.GetExecutable(),
+name ? " " : "", name, section_name ? " " : "", section_name);
+m_prev_end_addr = range_info.GetRange().GetRangeEnd();
+result.SetStatus(eReturnStatusSuccessFinishResult);
+  } else {
+result.SetStatus(eReturnStatusFailed);
+result.AppendErrorWithFormat("%s\n", error.AsCString());
   }
-  result.AppendMessageWithFormatv(
-  "[{0:x16}-{1:x16}) {2:r}{3:w}{4:x}{5}{6}{7}{8}\n",
-  range_info.GetRange().GetRangeBase(),
-  range_info.GetRange().GetRangeEnd(), range_info.GetReadable(),
-  range_info.GetWritable(), range_info.GetExecutable(),
-  name ? " " : "", name, section_name ? " " : "", section_name);
-  m_prev_end_addr = range_info.GetRange().GetRangeEnd();
-  result.SetStatus(eReturnStatusSuccessFinishResult);
-} else {
-  result.SetStatus(eReturnStatusFailed);
-  

[Lldb-commits] [PATCH] D87675: [lldb/DWARF] Refactor to prefer emplace_back() vs. push_back()

2020-09-15 Thread Dmitry Antipov via Phabricator via lldb-commits
dmantipov updated this revision to Diff 291894.
dmantipov added a comment.

OK let's reduce it to minimum minimorum.

As for the profiling, l can see possible improvement around 
DWARFAttributes::Append() - inlining even at -O2 and eliminating extra 
constructor call makes

  10.61%  intern-state liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::GetAttributes
  7.28%  intern-state liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::Extract
  6.88%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::ManualDWARFIndex::IndexUnitImpl
  5.76%  intern-state libpthread-2.31.so [.] __pthread_rwlock_rdlock
  5.43%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetU32
  4.70%  intern-state liblldb.so.12.0.0git   [.] DWARFUnit::GetDIE
  4.49%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::DWARFContext::LoadOrGetSection
  4.37%  intern-state libLLVM-12git.so   [.] 
llvm::StringMapImpl::FindKey
  3.50%  intern-state liblldb.so.12.0.0git   [.] 
DWARFFormValue::GetFixedSize
  2.73%  intern-state liblldb.so.12.0.0git   [.] 
DWARFUnit::ExtractDIEsRWLocked
  2.61%  intern-state liblldb.so.12.0.0git   [.] 
Pool::GetConstCStringWithStringRef
  2.08%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetULEB128
  1.82%  intern-state ld-2.31.so [.] __tls_get_addr
  1.77%  intern-state liblldb.so.12.0.0git   [.] 
std::__introsort_loop<__gnu_cxx::__normal_iterator::Entry*,
 std::vector::Entry, 
std::allocator::Entry> > >, long, 
__gnu_cxx::__ops::_Iter_comp_iter::Compare> >
  1.60%  intern-state liblldb.so.12.0.0git   [.] 
DWARFFormValue::ExtractValue
  1.55%  intern-state libpthread-2.31.so [.] __pthread_rwlock_unlock
  1.23%  intern-state libc-2.31.so   [.] __strlen_avx2
  1.15%  intern-state libc-2.31.so   [.] _int_free
  1.15%  intern-state libc-2.31.so   [.] malloc
  1.14%  intern-state liblldb.so.12.0.0git   [.] 
DWARFAttributes::ExtractFormValueAtIndex

from:

  7.68%  intern-state liblldb.so.12.0.0git   [.] DWARFAttributes::Append
  7.25%  intern-state liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::Extract
  6.34%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::ManualDWARFIndex::IndexUnitImpl
  6.30%  intern-state liblldb.so.12.0.0git   [.] 
DWARFDebugInfoEntry::GetAttributes
  5.55%  intern-state libpthread-2.31.so [.] __pthread_rwlock_rdlock
  5.51%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetU32
  4.50%  intern-state liblldb.so.12.0.0git   [.] DWARFUnit::GetDIE
  4.34%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::DWARFContext::LoadOrGetSection
  4.27%  intern-state libLLVM-12git.so   [.] 
llvm::StringMapImpl::FindKey
  2.92%  intern-state liblldb.so.12.0.0git   [.] 
DWARFFormValue::GetFixedSize
  2.65%  intern-state liblldb.so.12.0.0git   [.] 
DWARFUnit::ExtractDIEsRWLocked
  2.51%  intern-state liblldb.so.12.0.0git   [.] 
Pool::GetConstCStringWithStringRef
  1.93%  intern-state liblldb.so.12.0.0git   [.] 
lldb_private::DataExtractor::GetULEB128
  1.79%  intern-state liblldb.so.12.0.0git   [.] 
std::__introsort_loop<__gnu_cxx::__normal_iterator::Entry*,
 std::vector::Entry, 
std::allocator::Entry> > >, long, 
__gnu_cxx::__ops::_Iter_comp_iter::Compare>
 >
  1.78%  intern-state ld-2.31.so [.] __tls_get_addr
  1.46%  intern-state libpthread-2.31.so [.] __pthread_rwlock_unlock
  1.45%  intern-state liblldb.so.12.0.0git   [.] 
DWARFFormValue::ExtractValue
  1.22%  intern-state libc-2.31.so   [.] __strlen_avx2
  1.16%  intern-state libc-2.31.so   [.] malloc
  1.11%  intern-state libc-2.31.so   [.] _int_free
  1.08%  intern-state liblldb.so.12.0.0git   [.] 
DWARFAttributes::ExtractFormValueAtIndex

when loading symbols from clang + libLLVM.so (release build with '-O2 -g').


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

https://reviews.llvm.org/D87675

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -382,33 +382,33 @@
 parent.GetDeclContext(context);
   switch (tag) {
   case DW_TAG_module:
-context.push_back({CompilerContextKind::Module, ConstString(GetName())});
+context.emplace_back(CompilerContextKind::Module, ConstString(GetName()));
 break;
   case DW_TAG_namespace:
-context.push_back({CompilerContextKind::Namespace, 

[Lldb-commits] [PATCH] D87172: Check if debug line sequences are starting after the first code segment

2020-09-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This is fixing the same issue that I tried to fix with D84402 
, but then failed to get back to it when the 
discussion about the best approach started getting long.  While I do have some 
reservations about this approach, it is definitive improvement than the status 
quo, so I won't start bikeshedding the design (but do see the inline comments)..




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:437
+  m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {
+  auto first_code_section_sp =
+  m_objfile_sp->GetModule()->GetSectionList()->FindSectionByType(

This is really the _first_ text section (as listed in the section headers), is 
it not? But, I assume you really want the section with the lowest file address?

The linkers (and other producers) will normally output the sections in 
ascending address order (because it's the simplest thing to do). However, I 
don't believe that is actually required by anything, and I /think/ it should be 
possible (with a moderately funky linker script) to produce a fully functional 
executable which does not have the sections listed in this order.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:437-441
+  auto first_code_section_sp =
+  m_objfile_sp->GetModule()->GetSectionList()->FindSectionByType(
+  eSectionTypeCode, true, 0);
+  if (first_code_section_sp)
+m_first_code_address = first_code_section_sp->GetFileAddress();

clayborg wrote:
> This should be fine. Any symbol files that might get added after the fact 
> really need to have matching sections or nothing will make sense.
Doing this in `InitializeObject` would be better.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h:520
   std::vector m_lldb_cu_to_dwarf_unit;
+  lldb::addr_t m_first_code_address = LLDB_INVALID_ADDRESS;
 };

clayborg wrote:
> A lengthy comment would be great here. Maybe something like:
> 
> ```
> /// Many linkers will concatenate all available DWARF, even if parts of that 
> DWARF
> /// should have been dead stripped. Some linkers will place tombstone values 
> in for
> /// addresses that should have been dead stripped, with a value like -1 or 
> -2. But many
> /// linkers will apply a relocation and attempt to set the value to zero. 
> This is problematic
> /// in that we can end up with many addresses that are zero or close to zero 
> due to there
> /// being an addend on the relocation whose base is at zero. Here we attempt 
> to avoid 
> /// addresses that are zero or close to zero by finding the first valid code 
> address by looking
> /// at the sections and finding the first one that has read + execute 
> permissions. This allows
> /// us to do a quick and cheap comparison against this address when parsing 
> line tables and
> /// parsing functions where the DWARF should have been dead stripped.
> ```
To me, "should have been stripped" implies that the linkers are doing something 
wrong, as if they were required to parse and rewrite the dwarf in the input 
files. However, there is nothing in the DWARF or ELF specs that would support 
that, and the linkers are simply doing what the specs say, and what linkers 
have been doing since the dawn of time -- concatenate things.

It would be better to just state the facts here, instead of passing judgement 
(or make an appearance of doing that).



Comment at: 
lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-addresses.yaml:1-8
+# int foo() {
+# return 42;
+# }
+#
+# int main() {
+# int x = foo();
+# return x;

Is this the actual source code, or you've made some changes to it (like, to 
change the line table start address)?



Comment at: 
lldb/unittests/SymbolFile/DWARF/Inputs/test-invalid-addresses.yaml:203-254
+  - sectname:__apple_names
+segname: __DWARF
+addr:0x0001223C
+size:116
+offset:  0x223C
+align:   0
+reloff:  0x

I guess these (and debug_pub(types/names), and possible debug_aranges) are not 
really needed for this test.



Comment at: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp:349-369
+
+TEST_F(SymbolFileDWARFTests, EnsureLineEntriesExistInAfterFirstCodeSection) {
+  auto ExpectedFile = TestFile::fromYamlFile("test-invalid-addresses.yaml");
+  ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
+
+  lldb::ModuleSP module_sp =
+  std::make_shared(ExpectedFile->moduleSpec());

I think this would be better as a shell test (if for nothing else, then because 
other line table tests are written that way). `image lookup` is pretty much a 
direct equivalent to `ResolveSymbolContext`, but its output is more readable, 
and its 

[Lldb-commits] [PATCH] D87675: [lldb/DWARF] Refactor to prefer emplace_back() vs. push_back()

2020-09-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D87675#2273831 , @dmantipov wrote:

> Use std::pair rather than an ad-hoc two-member trivial structures. Since 
> std::pair provides the default constructor to initialize both members, no 
> extra C++ glue is required for emplace_back()'ing the pairs into containers.

I am sorry, but I don't consider that an improvement. The reason these were not 
pairs in the first place is because the first/second accessors are very 
nondescript. If you can demonstrate that these actually improve performance, 
then we can talk about the best way to do this. However, I'd be very surprised 
if any of these show up in a profile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87675

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


[Lldb-commits] [PATCH] D87675: [lldb/DWARF] Refactor to prefer emplace_back() vs. push_back()

2020-09-15 Thread Dmitry Antipov via Phabricator via lldb-commits
dmantipov updated this revision to Diff 291870.
dmantipov added a comment.

Use std::pair rather than an ad-hoc two-member trivial structures. Since 
std::pair provides the default constructor to initialize both members, no extra 
C++ glue is required for emplace_back()'ing the pairs into containers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87675

Files:
  lldb/include/lldb/Symbol/Function.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3638,10 +3638,8 @@
 LocationInCaller = parse_simple_location(i);
 }
 
-if (LocationInCallee && LocationInCaller) {
-  CallSiteParameter param = {*LocationInCallee, *LocationInCaller};
-  parameters.push_back(param);
-}
+if (LocationInCallee && LocationInCaller)
+  parameters.emplace_back(*LocationInCallee, *LocationInCaller);
   }
   return parameters;
 }
@@ -3793,12 +3791,12 @@
 if (log && parameters.size()) {
   for (const CallSiteParameter  : parameters) {
 StreamString callee_loc_desc, caller_loc_desc;
-param.LocationInCallee.GetDescription(_loc_desc,
-  eDescriptionLevelBrief,
-  LLDB_INVALID_ADDRESS, nullptr);
-param.LocationInCaller.GetDescription(_loc_desc,
-  eDescriptionLevelBrief,
-  LLDB_INVALID_ADDRESS, nullptr);
+param.first.GetDescription(_loc_desc,
+   eDescriptionLevelBrief,
+   LLDB_INVALID_ADDRESS, nullptr);
+param.second.GetDescription(_loc_desc,
+eDescriptionLevelBrief,
+LLDB_INVALID_ADDRESS, nullptr);
 LLDB_LOG(log, "CollectCallEdges: \tparam: {0} => {1}",
  callee_loc_desc.GetString(), caller_loc_desc.GetString());
   }
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -69,11 +69,7 @@
 }
   };
 
-  struct Atom {
-AtomType type;
-dw_form_t form;
-  };
-
+  typedef std::pair Atom;
   typedef std::vector DIEInfoArray;
   typedef std::vector AtomArray;
 
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -154,7 +154,7 @@
 }
 
 void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) {
-  atoms.push_back({type, form});
+  atoms.emplace_back(type, form);
   atom_mask |= 1u << type;
   switch (form) {
   case DW_FORM_indirect:
@@ -269,12 +269,12 @@
 return false;
 
   for (size_t i = 0; i < num_atoms; ++i) {
-DWARFFormValue form_value(nullptr, header_data.atoms[i].form);
+DWARFFormValue form_value(nullptr, header_data.atoms[i].second);
 
 if (!form_value.ExtractValue(data, offset_ptr))
   return false;
 
-switch (header_data.atoms[i].type) {
+switch (header_data.atoms[i].first) {
 case eAtomTypeDIEOffset: // DIE offset, check form for encoding
   hash_data.die_offset =
   DWARFFormValue::IsDataForm(form_value.Form())
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
@@ -49,8 +49,8 @@
   for (uint32_t i = 0; i < num_descriptors; ++i) {
 const DWARFDebugArangeSet::Descriptor  =
 set.GetDescriptorRef(i);
-m_aranges.Append(RangeToDIE::Entry(descriptor.address,
-   descriptor.length, cu_offset));
+

[Lldb-commits] [lldb] af3789a - [lldb] Improve qemu interop for aarch64

2020-09-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-09-15T13:32:08+02:00
New Revision: af3789a188116e400dd021bae54d91dc543aca7d

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

LOG: [lldb] Improve qemu interop for aarch64

qemu calls the "fp" and "lr" registers via their generic names
(x29/x30). This mismatch manifested itself as not being able to unwind
or display values of some local variables.

Added: 
lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml

Modified: 
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/source/Plugins/ABI/AArch64/ABIAArch64.h

Removed: 




diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 5cf9fb4ad37f..7cae4cc42750 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -33,6 +33,12 @@ ABIAArch64::GetEHAndDWARFNums(llvm::StringRef name) {
   return MCBasedABI::GetEHAndDWARFNums(name);
 }
 
+std::string ABIAArch64::GetMCName(std::string reg) {
+  MapRegisterName(reg, "v", "q");
+  MapRegisterName(reg, "x29", "fp");
+  MapRegisterName(reg, "x30", "lr");
+  return reg;
+}
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)

diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
index 981145e2017e..bdff648f1b52 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -20,10 +20,7 @@ class ABIAArch64: public lldb_private::MCBasedABI {
   std::pair
   GetEHAndDWARFNums(llvm::StringRef name) override;
 
-  std::string GetMCName(std::string reg) override {
-MapRegisterName(reg, "v", "q");
-return reg;
-  }
+  std::string GetMCName(std::string reg) override;
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
new file mode 100644
index ..9368de7b055a
--- /dev/null
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
@@ -0,0 +1,73 @@
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+from textwrap import dedent
+
+class MyResponder(MockGDBServerResponder):
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return dedent("""\
+
+  
+aarch64
+
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+  
+"""), False
+else:
+return None, False
+
+class TestQemuAarch64TargetXml(GDBRemoteTestBase):
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("AArch64")
+def test_register_augmentation(self):
+"""
+Test that we correctly associate the register info with the eh_frame
+register numbers.
+"""
+
+target = self.createTarget("basic_eh_frame-aarch64.yaml")
+self.server.responder = MyResponder()
+
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+[lldb.eStateStopped])
+self.filecheck("image show-unwind -n foo", __file__,
+"--check-prefix=UNWIND")
+# UNWIND: eh_frame UnwindPlan:
+# UNWIND: row[0]:0: CFA=x29+16 => x30=[CFA-8]

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml 
b/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml
new file mode 100644
index ..acc66082495e
--- /dev/null
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml
@@ -0,0 +1,25 @@
+--- !ELF

[Lldb-commits] [lldb] 0a2213c - [lldb/cmake] Fix testing support library dependencies

2020-09-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-09-15T13:32:08+02:00
New Revision: 0a2213c6eb24c9deec738e30509815e5bddd860c

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

LOG: [lldb/cmake] Fix testing support library dependencies

lldbUtilityHelpers does not depend on lldbSymbolHelpers. Remove that
dependency, and add direct lldbSymbolHelpers dependencies where needed.

Added: 


Modified: 
lldb/unittests/Expression/CMakeLists.txt
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
lldb/unittests/TestingSupport/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/Expression/CMakeLists.txt 
b/lldb/unittests/Expression/CMakeLists.txt
index 2f5304ab212d..0e8230d19bad 100644
--- a/lldb/unittests/Expression/CMakeLists.txt
+++ b/lldb/unittests/Expression/CMakeLists.txt
@@ -11,5 +11,6 @@ add_lldb_unittest(ExpressionTests
 lldbPluginTypeSystemClang
 lldbUtility
 lldbUtilityHelpers
+lldbSymbolHelpers
 LLVMTestingSupport
   )

diff  --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index 64a7b78c478a..30620a61dc5f 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -11,8 +11,9 @@ add_lldb_unittest(SymbolFileDWARFTests
 lldbPluginSymbolFileDWARF
 lldbPluginSymbolFilePDB
 lldbPluginTypeSystemClang
-lldbUtilityHelpers
 lldbPluginPlatformMacOSX
+lldbUtilityHelpers
+lldbSymbolHelpers
   LINK_COMPONENTS
 Support
 DebugInfoPDB

diff  --git a/lldb/unittests/TestingSupport/CMakeLists.txt 
b/lldb/unittests/TestingSupport/CMakeLists.txt
index 4599ada1ec50..c62bc3b023b7 100644
--- a/lldb/unittests/TestingSupport/CMakeLists.txt
+++ b/lldb/unittests/TestingSupport/CMakeLists.txt
@@ -5,7 +5,6 @@ add_lldb_library(lldbUtilityHelpers
 
   LINK_LIBS
 lldbUtility
-lldbSymbolHelpers
 gtest
 
   LINK_COMPONENTS



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


[Lldb-commits] [PATCH] D87675: [lldb/DWARF] Refactor to prefer emplace_back() vs. push_back()

2020-09-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Using emplacement instead of construction is a good idea, where it makes sense. 
However, I am not convinced that adding constructors to otherwise-trivial 
structures is worth it. These structures are usually trivially copyable and/or 
movable and so an emplacement does not really save much.

And I am definitely sure that the constructors we do add should be taking 
(lvalue) references -- that precludes construction with anything other than an 
lvalue, which is just weird. They also force at least one copy, whereas a 
equivalent (properly written) push_back call could use no copies.

So, I'd just limit this patch to the cases where one does not need to add 
additional constructors to make emplace_back work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87675

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


[Lldb-commits] [PATCH] D87675: [lldb/DWARF] Refactor to prefer emplace_back() vs. push_back()

2020-09-15 Thread Dmitry Antipov via Phabricator via lldb-commits
dmantipov updated this revision to Diff 291838.
dmantipov added a comment.

Minor style adjustments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87675

Files:
  lldb/include/lldb/Symbol/Function.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3638,10 +3638,8 @@
 LocationInCaller = parse_simple_location(i);
 }
 
-if (LocationInCallee && LocationInCaller) {
-  CallSiteParameter param = {*LocationInCallee, *LocationInCaller};
-  parameters.push_back(param);
-}
+if (LocationInCallee && LocationInCaller)
+  parameters.emplace_back(*LocationInCallee, *LocationInCaller);
   }
   return parameters;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -72,6 +72,8 @@
   struct Atom {
 AtomType type;
 dw_form_t form;
+
+Atom(AtomType , dw_form_t ) : type(type), form(form) {}
   };
 
   typedef std::vector DIEInfoArray;
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -154,7 +154,7 @@
 }
 
 void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) {
-  atoms.push_back({type, form});
+  atoms.emplace_back(type, form);
   atom_mask |= 1u << type;
   switch (form) {
   case DW_FORM_indirect:
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
@@ -33,6 +33,14 @@
   struct Descriptor {
 dw_addr_t address;
 dw_addr_t length;
+
+static_assert(sizeof(address) == sizeof(length),
+  "DWARFDebugArangeSet::Descriptor.address and "
+  "DWARFDebugArangeSet::Descriptor.length must have same size");
+
+Descriptor(dw_addr_t address, dw_addr_t length)
+  : address(address), length(length) {}
+
 dw_addr_t end_address() const { return address + length; }
   };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
@@ -98,23 +98,16 @@
 
   *offset_ptr = m_offset + first_tuple_offset;
 
-  Descriptor arangeDescriptor;
-
-  static_assert(sizeof(arangeDescriptor.address) ==
-sizeof(arangeDescriptor.length),
-"DWARFDebugArangeSet::Descriptor.address and "
-"DWARFDebugArangeSet::Descriptor.length must have same size");
-
   while (data.ValidOffset(*offset_ptr)) {
-arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size);
-arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size);
+dw_addr_t address = data.GetMaxU64(offset_ptr, m_header.addr_size);
+dw_attr_t length = data.GetMaxU64(offset_ptr, m_header.addr_size);
 
 // Each set of tuples is terminated by a 0 for the address and 0 for
 // the length.
-if (!arangeDescriptor.address && !arangeDescriptor.length)
+if (!address && !length)
   return llvm::ErrorSuccess();
 
-m_arange_descriptors.push_back(arangeDescriptor);
+m_arange_descriptors.emplace_back(address, length);
   }
 
   return llvm::make_error(
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -382,33 +382,33 @@
 parent.GetDeclContext(context);
   switch (tag) {
   case DW_TAG_module:
-context.push_back({CompilerContextKind::Module, ConstString(GetName())});
+

[Lldb-commits] [PATCH] D87442: [lldb] Show flags for memory regions

2020-09-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett marked 3 inline comments as done.
DavidSpickett added a comment.

In D87442#2273064 , @omjavaid wrote:

> This seems fine to me with some minor nits. Also do you plan on writing a 
> Linux API test for this which test memory regions on Linux? I couldnt locate 
> one already written.

There are some tests in test/API/tools/lldb-server/TestLldbGdbServer.py that 
parse region packets manually (e.g. 
qMemoryRegionInfo_reports_code_address_as_executable) but they're not using the 
API.

There is no test for "memory region" or the API. I'll add some to 
test/API/linux/, one for Kernels with smaps, one without. (so you'll only run 
one or the other per platform)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87442

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


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

2020-09-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.
Herald added a reviewer: JDevlieghere.

(Sorry about the delay.) Given the current requirements, I think this patch is 
fine (excellent even).

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

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




Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:1243
+  std::error_code ec = e->convertToErrorCode();
+  if (ec == std::make_error_code(
+std::errc::address_family_not_supported) ||

Nit: I believe the std::make_error_code call is redundant (direct comparison to 
the enum should work fine).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87333

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


[Lldb-commits] [PATCH] D87442: [lldb] Show flags for memory regions

2020-09-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 291835.
DavidSpickett added a comment.

- clang-format Minidump file
- Remove HasFlags from API, return True/False from GetFlags instead
- Rename MapKind to MapsKind and make it an enum class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87442

Files:
  lldb/bindings/interface/SBMemoryRegionInfo.i
  lldb/docs/lldb-gdb-remote.txt
  lldb/include/lldb/API/SBMemoryRegionInfo.h
  lldb/include/lldb/Target/MemoryRegionInfo.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/API/SBMemoryRegionInfo.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
  lldb/source/Plugins/Process/Utility/LinuxProcMaps.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Target/MemoryRegionInfo.cpp
  lldb/unittests/Process/CMakeLists.txt
  lldb/unittests/Process/Utility/CMakeLists.txt
  lldb/unittests/Process/Utility/LinuxProcMapsTest.cpp
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
  lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -374,20 +374,20 @@
 )"),
 llvm::Succeeded());
 
-  EXPECT_THAT(
-  parser->BuildMemoryRegions(),
-  testing::Pair(testing::ElementsAre(
-MemoryRegionInfo({0x0, 0x1}, no, no, no, no,
- ConstString(), unknown, 0),
-MemoryRegionInfo({0x1, 0x21000}, yes, yes, no, yes,
- ConstString(), unknown, 0),
-MemoryRegionInfo({0x4, 0x1000}, yes, no, no, yes,
- ConstString(), unknown, 0),
-MemoryRegionInfo({0x7ffe, 0x1000}, yes, no, no, yes,
- ConstString(), unknown, 0),
-MemoryRegionInfo({0x7ffe1000, 0xf000}, no, no, no, yes,
- ConstString(), unknown, 0)),
-true));
+  EXPECT_THAT(parser->BuildMemoryRegions(),
+  testing::Pair(
+  testing::ElementsAre(
+  MemoryRegionInfo({0x0, 0x1}, no, no, no, no,
+   ConstString(), unknown, 0, llvm::None),
+  MemoryRegionInfo({0x1, 0x21000}, yes, yes, no, yes,
+   ConstString(), unknown, 0, llvm::None),
+  MemoryRegionInfo({0x4, 0x1000}, yes, no, no, yes,
+   ConstString(), unknown, 0, llvm::None),
+  MemoryRegionInfo({0x7ffe, 0x1000}, yes, no, no, yes,
+   ConstString(), unknown, 0, llvm::None),
+  MemoryRegionInfo({0x7ffe1000, 0xf000}, no, no, no, yes,
+   ConstString(), unknown, 0, llvm::None)),
+  true));
 }
 
 TEST_F(MinidumpParserTest, GetMemoryRegionInfoFromMemoryList) {
@@ -409,12 +409,13 @@
 
   EXPECT_THAT(
   parser->BuildMemoryRegions(),
-  testing::Pair(testing::ElementsAre(
-MemoryRegionInfo({0x1000, 0x10}, yes, unknown, unknown,
- yes, ConstString(), unknown, 0),
-MemoryRegionInfo({0x2000, 0x20}, yes, unknown, unknown,
- yes, ConstString(), unknown, 0)),
-false));
+  testing::Pair(
+  testing::ElementsAre(
+  MemoryRegionInfo({0x1000, 0x10}, yes, unknown, unknown, yes,
+   ConstString(), unknown, 0, llvm::None),
+  MemoryRegionInfo({0x2000, 0x20}, yes, unknown, unknown, yes,
+   ConstString(), unknown, 0, llvm::None)),
+  false));
 }
 
 TEST_F(MinidumpParserTest, GetMemoryRegionInfoFromMemory64List) {
@@ -424,12 +425,13 @@
   // we don't have a MemoryInfoListStream.
   EXPECT_THAT(
   parser->BuildMemoryRegions(),
-  testing::Pair(testing::ElementsAre(
-MemoryRegionInfo({0x1000, 0x10}, yes, unknown, unknown,
- yes, ConstString(), unknown, 0),
-MemoryRegionInfo({0x2000, 0x20}, yes, unknown, unknown,
- yes, ConstString(), unknown, 0)),
-false));
+  testing::Pair(
+  

[Lldb-commits] [PATCH] D87441: Speedup collecting DWARF attribute values

2020-09-15 Thread Dmitry Antipov via Phabricator via lldb-commits
dmantipov abandoned this revision.
dmantipov added a comment.

Superseded with https://reviews.llvm.org/D87675.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87441

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


[Lldb-commits] [PATCH] D87675: [lldb/DWARF] Refactor to prefer emplace_back() vs. push_back()

2020-09-15 Thread Dmitry Antipov via Phabricator via lldb-commits
dmantipov created this revision.
dmantipov added reviewers: labath, jankratochvil, teemperor.
dmantipov added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a reviewer: shafik.
dmantipov requested review of this revision.

Prefer emplace_back() over push_back() where appropriate to avoid extra calls 
to copy and/or move constructors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87675

Files:
  lldb/include/lldb/Symbol/Function.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3638,10 +3638,8 @@
 LocationInCaller = parse_simple_location(i);
 }
 
-if (LocationInCallee && LocationInCaller) {
-  CallSiteParameter param = {*LocationInCallee, *LocationInCaller};
-  parameters.push_back(param);
-}
+if (LocationInCallee && LocationInCaller)
+  parameters.emplace_back(*LocationInCallee, *LocationInCaller);
   }
   return parameters;
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -72,6 +72,8 @@
   struct Atom {
 AtomType type;
 dw_form_t form;
+
+Atom(AtomType , dw_form_t ) : type(type), form(form) {}
   };
 
   typedef std::vector DIEInfoArray;
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -154,7 +154,7 @@
 }
 
 void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) {
-  atoms.push_back({type, form});
+  atoms.emplace_back(type, form);
   atom_mask |= 1u << type;
   switch (form) {
   case DW_FORM_indirect:
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
@@ -33,6 +33,14 @@
   struct Descriptor {
 dw_addr_t address;
 dw_addr_t length;
+
+static_assert(sizeof(address) == sizeof(length),
+		  "DWARFDebugArangeSet::Descriptor.address and "
+		  "DWARFDebugArangeSet::Descriptor.length must have same size");
+
+Descriptor(dw_addr_t address, dw_addr_t length)
+  : address(address), length(length) {}
+
 dw_addr_t end_address() const { return address + length; }
   };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
@@ -98,23 +98,16 @@
 
   *offset_ptr = m_offset + first_tuple_offset;
 
-  Descriptor arangeDescriptor;
-
-  static_assert(sizeof(arangeDescriptor.address) ==
-sizeof(arangeDescriptor.length),
-"DWARFDebugArangeSet::Descriptor.address and "
-"DWARFDebugArangeSet::Descriptor.length must have same size");
-
   while (data.ValidOffset(*offset_ptr)) {
-arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size);
-arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size);
+dw_addr_t address = data.GetMaxU64(offset_ptr, m_header.addr_size);
+dw_attr_t length = data.GetMaxU64(offset_ptr, m_header.addr_size);
 
 // Each set of tuples is terminated by a 0 for the address and 0 for
 // the length.
-if (!arangeDescriptor.address && !arangeDescriptor.length)
+if (!address && !length)
   return llvm::ErrorSuccess();
 
-m_arange_descriptors.push_back(arangeDescriptor);
+m_arange_descriptors.emplace_back(address, length);
   }
 
   return llvm::make_error(
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -382,33 +382,33 @@
 

[Lldb-commits] [PATCH] D86996: [lldb] Add -l/--language option to script command

2020-09-15 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

This looks fine (sorry about the delay, I've been OOO).




Comment at: lldb/test/Shell/ScriptInterpreter/Lua/lua.test:2
 # REQUIRES: lua
-# RUN: %lldb --script-language lua -o 'script print(1000+100+10+1)' 2>&1 | 
FileCheck %s
+# RUN: %lldb --script-language lua -o 'script -- 
io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s
+# RUN: %lldb --script-language lua -o 'script --language default -- 
io.stdout:write(1000+100+10+1, "\n")' 2>&1 | FileCheck %s

Did you add the `--` here just for consistency? It believe it should not be 
necessary to use the double dash if the script command has no arguments 
(similar to how its possible to write `expr 1+2` without any dashes (but `expr 
-A -- 1+2` does require it)


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

https://reviews.llvm.org/D86996

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


[Lldb-commits] [PATCH] D87590: Backport D79219, D85820, D86134 to 10.0 branch

2020-09-15 Thread Brian J. Cardiff via Phabricator via lldb-commits
bcardiff created this revision.
bcardiff added reviewers: JDevlieghere, phosek, smeenai.
Herald added subscribers: llvm-commits, lldb-commits, Sanitizers, cfe-commits, 
hiraditya, mgorny.
Herald added projects: clang, Sanitizers, LLDB, LLVM.
bcardiff requested review of this revision.

Changes CMake configuration files are backported from master to 10.0 branch.

The 10.0.1 release is a bit broken and affects homebrew 
https://discourse.brew.sh/t/llvm-config-10-0-1-advertise-libxml2-tbd-as-system-libs/8593

To backport https://reviews.llvm.org/D79219 I needed to go through many commits 
of changes and revert changes regarding "Simplify CMake handling for zlib".

The other changes included are:

- https://reviews.llvm.org/D85820 "Use find_library for ncurses" and,
- https://reviews.llvm.org/D86134 "Fix OCaml build failure because of absolute 
path in system libs".

I'm not sure if there are plans for another 10.x release, but since I went 
through the history to make the patch for homebrew I figure I would send it 
here also just in case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87590

Files:
  clang/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/xray/tests/CMakeLists.txt
  compiler-rt/test/lit.common.configured.in
  lld/CMakeLists.txt
  lld/test/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/source/Core/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/config.h.cmake
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CRC.cpp
  llvm/lib/Support/Compression.cpp
  llvm/lib/Support/Unix/Process.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.site.cfg.py.in
  llvm/unittests/Support/CompressionTest.cpp
  llvm/utils/gn/secondary/clang/test/BUILD.gn
  llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
  llvm/utils/gn/secondary/lld/test/BUILD.gn
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  llvm/utils/gn/secondary/llvm/test/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/test/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -166,9 +166,9 @@
   }
 
   if (llvm_enable_zlib) {
-extra_values += [ "HAVE_LIBZ=1" ]
+extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
+extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
   }
 }
 
Index: llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -294,9 +294,9 @@
   }
 
   if (llvm_enable_terminfo) {
-values += [ "HAVE_TERMINFO=1" ]
+values += [ "LLVM_ENABLE_TERMINFO=1" ]
   } else {
-values += [ "HAVE_TERMINFO=" ]
+values += [ "LLVM_ENABLE_TERMINFO=" ]
   }
 
   if (llvm_enable_dia_sdk) {
Index: llvm/utils/gn/secondary/lld/test/BUILD.gn
===
--- llvm/utils/gn/secondary/lld/test/BUILD.gn
+++ llvm/utils/gn/secondary/lld/test/BUILD.gn
@@ -49,9 +49,9 @@
   }
 
   if (llvm_enable_zlib) {
-extra_values += [ "HAVE_LIBZ=1" ]
+extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
+extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
   }
 
   if (current_cpu == "x64" || current_cpu == "arm64" ||
Index: llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
===
--- llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
@@ -85,8 +85,8 @@
   }
 
   if (llvm_enable_zlib) {
-values += [ "HAVE_LIBZ=1" ]
+values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-values += [ "HAVE_LIBZ=0" ]
+values += [ "LLVM_ENABLE_ZLIB=0" ]
   }
 }
Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -74,9 +74,9 @@
   }
 
   if (llvm_enable_zlib) {
-extra_values += [ "HAVE_LIBZ=1" ]
+extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
+extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
   }
 
   if (host_cpu == "x64") {
Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 
-#if