[Lldb-commits] [PATCH] D60968: WIP, RFC: Add an example of how LLDB python plug-in could look like

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath resigned from this revision.
labath added a comment.

I don't have any opinions on os plugins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60968



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


[Lldb-commits] [lldb] r358957 - yamlify TestMiniDumpUUID binaries

2019-04-23 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Apr 23 01:49:39 2019
New Revision: 358957

URL: http://llvm.org/viewvc/llvm-project?rev=358957&view=rev
Log:
yamlify TestMiniDumpUUID binaries

Summary:
Instead of checking in raw minidump binaries, check in their yaml form,
and call yaml2obj in the test.

Reviewers: clayborg

Subscribers: javed.absar, lldb-commits

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.yaml
Removed:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.dmp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.dmp
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py?rev=358957&r1=358956&r2=358957&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
 Tue Apr 23 01:49:39 2019
@@ -33,6 +33,13 @@ class MiniDumpUUIDTestCase(TestBase):
 self.assertEqual(verify_path, module.GetFileSpec().fullpath)
 self.assertEqual(verify_uuid, uuid)
 
+def get_minidump_modules(self, yaml_file):
+minidump_path = self.getBuildArtifact(yaml_file + ".dmp")
+self.yaml2obj(yaml_file, minidump_path)
+self.target = self.dbg.CreateTarget(None)
+self.process = self.target.LoadCore(minidump_path)
+return self.target.modules
+
 def test_zero_uuid_modules(self):
 """
 Test multiple modules having a MINIDUMP_MODULE.CvRecord that is 
valid,
@@ -42,10 +49,7 @@ class MiniDumpUUIDTestCase(TestBase):
 ensure that the UUID is not valid for each module and that we have
 each of the modules in the target after loading the core
 """
-self.dbg.CreateTarget(None)
-self.target = self.dbg.GetSelectedTarget()
-self.process = self.target.LoadCore("linux-arm-zero-uuids.dmp")
-modules = self.target.modules
+modules = self.get_minidump_modules("linux-arm-zero-uuids.yaml")
 self.assertEqual(2, len(modules))
 self.verify_module(modules[0], "/file/does/not/exist/a", None)
 self.verify_module(modules[1], "/file/does/not/exist/b", None)
@@ -56,9 +60,7 @@ class MiniDumpUUIDTestCase(TestBase):
 and contains a PDB70 value whose age is zero and whose UUID values 
are 
 valid. Ensure we decode the UUID and don't include the age field 
in the UUID.
 """
-self.dbg.CreateTarget(None)
-self.target = self.dbg.GetSelectedTarget()
-self.process = self.target.LoadCo

[Lldb-commits] [PATCH] D60948: yamlify TestMiniDumpUUID binaries

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB358957: yamlify TestMiniDumpUUID binaries (authored by 
labath, committed by ).
Herald added a subscriber: abidh.
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D60948?vs=196000&id=196194#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60948

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-match.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-partial-uuids-mismatch.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-zero.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-no-age.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-with-age.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/macos-arm-uuids-no-age.yaml

Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-16.yaml
@@ -0,0 +1,19 @@
+--- !minidump
+Streams: 
+  - Type:SystemInfo
+Processor Arch:  ARM
+Platform ID: Linux
+CSD Version: '15E216'
+CPU: 
+  CPUID:   0x
+  - Type:ModuleList
+Modules: 
+  - Base of Image:   0x1000
+Size of Image:   0x1000
+Module Name: '/tmp/a'
+CodeView Record: 4C4570420102030405060708090A0B0C0D0E0F10
+  - Base of Image:   0x1000
+Size of Image:   0x1000
+Module Name: '/tmp/b'
+CodeView Record: 4C4570420A141E28323C46505A646E78828C96A0
+...
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml
@@ -0,0 +1,21 @@
+--- !minidump
+Streams: 
+  - Type:SystemInfo
+Processor Arch:  AMD64
+Platform ID: Linux
+CSD Version: '15E216'
+CPU: 
+  Vendor ID:   GenuineIntel
+  Version Info:0x
+  Feature Info:0x
+  - Type:ModuleList
+Modules: 
+  - Base of Image:   0x1000
+Size of Image:   0x1000
+Module Name: '/file/does/not/exist/a'
+CodeView Record: '5253445300'
+  - Base of Image:   0x1000
+Size of Image:   0x1000
+Module Name: '/file/does/not/exist/b'
+CodeView Record: '5253445300'
+...
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-20.yaml
+++ packag

[Lldb-commits] [PATCH] D60984: [Reproducers] Limit logging to calls that cross the API boundary.

2019-04-23 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.

Logging only external calls makes sense to me. The one thing I was not sure 
about is the name of the `Recorder` class, since it's responsibility was now 
extended to include logging (and that has affected its design). However, I 
couldn't come up with a better name, and I suppose logging could be considered 
a form of recording, so maybe that's fine as it is. It might be good to mention 
the new role in the class description too...




Comment at: lldb/source/Utility/ReproducerInstrumentation.cpp:106
+: m_serializer(nullptr), m_pretty_func(pretty_func),
+  m_pretty_args(pretty_args), m_local_boundary(false),
   m_result_recorded(true) {

`std::move(pretty_args)`


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60984



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


[Lldb-commits] [PATCH] D60829: FuncUnwinders: remove "current_offset" from function arguments

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for the review. Don't worry about the delay -- it has actually coincided 
with the public holidays on this side of the globe, so I was not working 
anyway. (but the delay wasn't long even if I had worked) :)


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

https://reviews.llvm.org/D60829



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


Re: [Lldb-commits] [lldb] r358918 - [EditLineTest] Not always TERM is available, e.g. on some bots.

2019-04-23 Thread Pavel Labath via lldb-commits

On 22/04/2019 22:27, Davide Italiano via lldb-commits wrote:

Author: davide
Date: Mon Apr 22 13:27:10 2019
New Revision: 358918

URL: http://llvm.org/viewvc/llvm-project?rev=358918&view=rev
Log:
[EditLineTest] Not always TERM is available, e.g. on some bots.

Modified:
 lldb/trunk/unittests/Editline/EditlineTest.cpp

Modified: lldb/trunk/unittests/Editline/EditlineTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Editline/EditlineTest.cpp?rev=358918&r1=358917&r2=358918&view=diff
==
--- lldb/trunk/unittests/Editline/EditlineTest.cpp (original)
+++ lldb/trunk/unittests/Editline/EditlineTest.cpp Mon Apr 22 13:27:10 2019
@@ -244,17 +244,19 @@ private:
EditlineAdapter _el_adapter;
std::shared_ptr _sp_output_thread;
  
+protected:

+  bool _has_term = true;
+
  public:
void SetUp() {
  FileSystem::Initialize();
  
  // We need a TERM set properly for editline to work as expected.

-setenv("TERM", "vt100", 1);
+if (setenv("TERM", "vt100", 1) != 0)
+  _has_term = false;


I'm confused as to what is this trying to solve. Judging by the manpage 
(which also agrees with my intuition) the setenv call can only fail 
under two conditions:
- "name (first arg) is NULL, points to a string of length 0, or contains 
an '=' character". This is clearly not the case here.
- "Insufficient memory to add a new variable to the environment". While 
technically possible, I find that highly unlikely, as you'd run into a 
lot more problems if the system was so severely memory-constrained.


I suspect this is only covering up some other problem. Can you elaborate 
on how you've arrived at this patch?


pl

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


[Lldb-commits] [PATCH] D60949: UnwindPlan: pretty-print dwarf expressions

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB358959: UnwindPlan: pretty-print dwarf expressions 
(authored by labath, committed by ).
Herald added a subscriber: teemperor.
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D60949?vs=196006&id=196198#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60949

Files:
  lit/Unwind/Inputs/unwind-plan-dwarf-dump.s
  lit/Unwind/unwind-plan-dwarf-dump.test
  source/Symbol/UnwindPlan.cpp

Index: source/Symbol/UnwindPlan.cpp
===
--- source/Symbol/UnwindPlan.cpp
+++ source/Symbol/UnwindPlan.cpp
@@ -8,8 +8,10 @@
 
 #include "lldb/Symbol/UnwindPlan.h"
 
+#include "lldb/Expression/DWARFExpression.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -64,6 +66,30 @@
   m_location.expr.length = len;
 }
 
+static llvm::Optional>
+GetByteOrderAndAddrSize(Thread *thread) {
+  if (!thread)
+return llvm::None;
+  ProcessSP process_sp = thread->GetProcess();
+  if (!process_sp)
+return llvm::None;
+  ArchSpec arch = process_sp->GetTarget().GetArchitecture();
+  return std::make_pair(arch.GetByteOrder(), arch.GetAddressByteSize());
+}
+
+static void DumpDWARFExpr(Stream &s, llvm::ArrayRef expr, Thread *thread) {
+  if (auto order_and_width = GetByteOrderAndAddrSize(thread)) {
+DataExtractor extractor(expr.data(), expr.size(), order_and_width->first,
+order_and_width->second);
+if (!DWARFExpression::PrintDWARFExpression(s, extractor,
+   order_and_width->second,
+   /*dwarf_ref_size*/ 4,
+   /*location_expression*/ false))
+  s.PutCString("invalid-dwarf-expr");
+  } else
+s.PutCString("dwarf-expr");
+}
+
 void UnwindPlan::Row::RegisterLocation::Dump(Stream &s,
  const UnwindPlan *unwind_plan,
  const UnwindPlan::Row *row,
@@ -120,9 +146,12 @@
   case isDWARFExpression: {
 s.PutChar('=');
 if (m_type == atDWARFExpression)
-  s.PutCString("[dwarf-expr]");
-else
-  s.PutCString("dwarf-expr");
+  s.PutChar('[');
+DumpDWARFExpr(
+s, llvm::makeArrayRef(m_location.expr.opcodes, m_location.expr.length),
+thread);
+if (m_type == atDWARFExpression)
+  s.PutChar(']');
   } break;
   }
 }
@@ -172,7 +201,9 @@
 s.PutChar(']');
 break;
   case isDWARFExpression:
-s.PutCString("dwarf-expr");
+DumpDWARFExpr(s,
+  llvm::makeArrayRef(m_value.expr.opcodes, m_value.expr.length),
+  thread);
 break;
   default:
 s.PutCString("unspecified");
Index: lit/Unwind/unwind-plan-dwarf-dump.test
===
--- lit/Unwind/unwind-plan-dwarf-dump.test
+++ lit/Unwind/unwind-plan-dwarf-dump.test
@@ -0,0 +1,14 @@
+# REQUIRES: target-x86_64, system-linux, native
+
+# RUN: %clang %p/Inputs/unwind-plan-dwarf-dump.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set -n main
+# CHECK: Breakpoint 1:
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+target modules show-unwind -n main
+# CHECK: eh_frame UnwindPlan:
+# CHECK: row[0]:0: CFA=DW_OP_breg7 +0, DW_OP_const1u 0x00, DW_OP_plus  => rip=DW_OP_const1s -8, DW_OP_plus , DW_OP_deref
Index: lit/Unwind/Inputs/unwind-plan-dwarf-dump.s
===
--- lit/Unwind/Inputs/unwind-plan-dwarf-dump.s
+++ lit/Unwind/Inputs/unwind-plan-dwarf-dump.s
@@ -0,0 +1,13 @@
+.text
+.globl  main
+.type   main, @function
+main:
+.LFB0:
+.cfi_startproc
+.cfi_escape 0x0f, 0x05, 0x77, 0x00, 0x08, 0x00, 0x22
+.cfi_escape 0x16, 0x10, 0x04, 0x09, 0xf8, 0x22, 0x06
+movl$47, %eax
+ret
+.cfi_endproc
+.LFE0:
+.size   main, .-main
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r358959 - UnwindPlan: pretty-print dwarf expressions

2019-04-23 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Apr 23 02:16:51 2019
New Revision: 358959

URL: http://llvm.org/viewvc/llvm-project?rev=358959&view=rev
Log:
UnwindPlan: pretty-print dwarf expressions

Summary:
Previously we were printing the dwarf expressions in unwind rules simply
as "dwarf-expr". This patch uses the existing dwarf-printing
capabilities in lldb to enhance this dump output, and print the full
decoded dwarf expression.

Reviewers: jasonmolenda, clayborg

Subscribers: aprantl, lldb-commits

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

Added:
lldb/trunk/lit/Unwind/
lldb/trunk/lit/Unwind/Inputs/
lldb/trunk/lit/Unwind/Inputs/unwind-plan-dwarf-dump.s
lldb/trunk/lit/Unwind/unwind-plan-dwarf-dump.test
Modified:
lldb/trunk/source/Symbol/UnwindPlan.cpp

Added: lldb/trunk/lit/Unwind/Inputs/unwind-plan-dwarf-dump.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Unwind/Inputs/unwind-plan-dwarf-dump.s?rev=358959&view=auto
==
--- lldb/trunk/lit/Unwind/Inputs/unwind-plan-dwarf-dump.s (added)
+++ lldb/trunk/lit/Unwind/Inputs/unwind-plan-dwarf-dump.s Tue Apr 23 02:16:51 
2019
@@ -0,0 +1,13 @@
+.text
+.globl  main
+.type   main, @function
+main:
+.LFB0:
+.cfi_startproc
+.cfi_escape 0x0f, 0x05, 0x77, 0x00, 0x08, 0x00, 0x22
+.cfi_escape 0x16, 0x10, 0x04, 0x09, 0xf8, 0x22, 0x06
+movl$47, %eax
+ret
+.cfi_endproc
+.LFE0:
+.size   main, .-main

Added: lldb/trunk/lit/Unwind/unwind-plan-dwarf-dump.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Unwind/unwind-plan-dwarf-dump.test?rev=358959&view=auto
==
--- lldb/trunk/lit/Unwind/unwind-plan-dwarf-dump.test (added)
+++ lldb/trunk/lit/Unwind/unwind-plan-dwarf-dump.test Tue Apr 23 02:16:51 2019
@@ -0,0 +1,14 @@
+# REQUIRES: target-x86_64, system-linux, native
+
+# RUN: %clang %p/Inputs/unwind-plan-dwarf-dump.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set -n main
+# CHECK: Breakpoint 1:
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+target modules show-unwind -n main
+# CHECK: eh_frame UnwindPlan:
+# CHECK: row[0]:0: CFA=DW_OP_breg7 +0, DW_OP_const1u 0x00, DW_OP_plus  => 
rip=DW_OP_const1s -8, DW_OP_plus , DW_OP_deref

Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=358959&r1=358958&r2=358959&view=diff
==
--- lldb/trunk/source/Symbol/UnwindPlan.cpp (original)
+++ lldb/trunk/source/Symbol/UnwindPlan.cpp Tue Apr 23 02:16:51 2019
@@ -8,8 +8,10 @@
 
 #include "lldb/Symbol/UnwindPlan.h"
 
+#include "lldb/Expression/DWARFExpression.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -64,6 +66,30 @@ void UnwindPlan::Row::RegisterLocation::
   m_location.expr.length = len;
 }
 
+static llvm::Optional>
+GetByteOrderAndAddrSize(Thread *thread) {
+  if (!thread)
+return llvm::None;
+  ProcessSP process_sp = thread->GetProcess();
+  if (!process_sp)
+return llvm::None;
+  ArchSpec arch = process_sp->GetTarget().GetArchitecture();
+  return std::make_pair(arch.GetByteOrder(), arch.GetAddressByteSize());
+}
+
+static void DumpDWARFExpr(Stream &s, llvm::ArrayRef expr, Thread 
*thread) {
+  if (auto order_and_width = GetByteOrderAndAddrSize(thread)) {
+DataExtractor extractor(expr.data(), expr.size(), order_and_width->first,
+order_and_width->second);
+if (!DWARFExpression::PrintDWARFExpression(s, extractor,
+   order_and_width->second,
+   /*dwarf_ref_size*/ 4,
+   /*location_expression*/ false))
+  s.PutCString("invalid-dwarf-expr");
+  } else
+s.PutCString("dwarf-expr");
+}
+
 void UnwindPlan::Row::RegisterLocation::Dump(Stream &s,
  const UnwindPlan *unwind_plan,
  const UnwindPlan::Row *row,
@@ -120,9 +146,12 @@ void UnwindPlan::Row::RegisterLocation::
   case isDWARFExpression: {
 s.PutChar('=');
 if (m_type == atDWARFExpression)
-  s.PutCString("[dwarf-expr]");
-else
-  s.PutCString("dwarf-expr");
+  s.PutChar('[');
+DumpDWARFExpr(
+s, llvm::makeArrayRef(m_location.expr.opcodes, m_location.expr.length),
+thread);
+if (m_type == atDWARFExpression)
+  s.PutChar(']');
   } break;
   }
 }
@@ -172,7 +201,9 @@ void UnwindPlan::Row::FAValue::Dump(Stre
 s.PutChar(']');
 break;
   case isDWARFExpression:
-s.PutCString("dwarf-expr")

[Lldb-commits] [lldb] r358964 - FuncUnwinders: remove "current_offset" from function arguments

2019-04-23 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Apr 23 02:57:14 2019
New Revision: 358964

URL: http://llvm.org/viewvc/llvm-project?rev=358964&view=rev
Log:
FuncUnwinders: remove "current_offset" from function arguments

Summary:
This argument was added back in 2010 (r118882) to support the ability to unwind
from functions whose eh_frame entry does not cover the entire range of
the function.

However, due to the caching happening in FuncUnwinders, this solution is
very fragile. FuncUnwinders will cache the plan it got from eh_frame
regardless of the value of the current_offset, so our ability to unwind
from a given function depended what was the value of "current_offset" the
first time that this function was called.

Furthermore, since the "image show-unwind" command did not know what's
the right offset to pass, this created an unfortunate situation where
"image show-unwind" would show no valid plans for a function, even
though they were available and being used.

In this patch I implement the feature slightly differently. Instead of
giving just a base address to the eh_frame unwinder, I give it the
entire range we are interested in. Then, I change the unwinder to return
the first plan that covers (even partially) that range. This way even a
partial plan will be returned, regardless of the address in the function
where we are stopped at.

This solution is still not 100% correct, as it will not handle a
function which is covered by two independent fde entries. However, I
don't expect anybody will write this kind of functions, and this wasn't
handled by the previous implementation either. If this is ever needed in
the future. The eh_frame unwinder can be extended to return "composite"
unwind plans created by merging sevelar fde entries.

I also create a test which triggers this scenario. As doing this is
virtually impossible without hand-written assembly, the test only works
on x86 linux.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits

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

Added:
lldb/trunk/lit/Unwind/Inputs/eh-frame-small-fde.s
lldb/trunk/lit/Unwind/eh-frame-small-fde.test
Modified:
lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h
lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
lldb/trunk/include/lldb/Utility/RangeMap.h
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp
lldb/trunk/source/Symbol/FuncUnwinders.cpp

Modified: lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h?rev=358964&r1=358963&r2=358964&view=diff
==
--- lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h (original)
+++ lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h Tue Apr 23 02:57:14 2019
@@ -43,9 +43,15 @@ public:
   // address.
   bool GetAddressRange(Address addr, AddressRange &range);
 
-  // Return an UnwindPlan based on the call frame information encoded in the
-  // FDE of this DWARFCallFrameInfo section.
-  bool GetUnwindPlan(Address addr, UnwindPlan &unwind_plan);
+  /// Return an UnwindPlan based on the call frame information encoded in the
+  /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
+  /// (at least) for the given address.
+  bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan);
+
+  /// Return an UnwindPlan based on the call frame information encoded in the
+  /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
+  /// (at least) for some address in the given range.
+  bool GetUnwindPlan(const AddressRange &range, UnwindPlan &unwind_plan);
 
   typedef RangeVector FunctionAddressAndSizeVector;
 
@@ -115,8 +121,8 @@ private:
 
   bool IsEHFrame() const;
 
-  bool GetFDEEntryByFileAddress(lldb::addr_t file_offset,
-FDEEntryMap::Entry &fde_entry);
+  llvm::Optional
+  GetFirstFDEEntryInRange(const AddressRange &range);
 
   void GetFDEIndex();
 

Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=358964&r1=358963&r2=358964&view=diff
==
--- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (original)
+++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Tue Apr 23 02:57:14 2019
@@ -35,17 +35,10 @@ public:
 
   ~FuncUnwinders();
 
-  // current_offset is the byte offset into the function.
-  // 0 means no instructions have executed yet.  -1 means the offset is 
unknown.
-  // On architectures where the pc points to the next instruction that will
-  // execute, this offset value will have already been decremented by 1 to stay
-  // within the bounds of the correct function body.
-  lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &targ

[Lldb-commits] [PATCH] D60829: FuncUnwinders: remove "current_offset" from function arguments

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358964: FuncUnwinders: remove "current_offset" 
from function arguments (authored by labath, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60829

Files:
  lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h
  lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
  lldb/trunk/include/lldb/Utility/RangeMap.h
  lldb/trunk/lit/Unwind/Inputs/eh-frame-small-fde.s
  lldb/trunk/lit/Unwind/eh-frame-small-fde.test
  lldb/trunk/source/Commands/CommandObjectTarget.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp
  lldb/trunk/source/Symbol/FuncUnwinders.cpp

Index: lldb/trunk/lit/Unwind/eh-frame-small-fde.test
===
--- lldb/trunk/lit/Unwind/eh-frame-small-fde.test
+++ lldb/trunk/lit/Unwind/eh-frame-small-fde.test
@@ -0,0 +1,22 @@
+# This test that we are able to unwind using eh_frame in case an FDE entry does
+# not cover the entire range of a function we are unwinding through.
+
+# REQUIRES: target-x86_64, system-linux, native
+
+# RUN: %clang %p/Inputs/eh-frame-small-fde.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set -n bar
+# CHECK: Breakpoint 1: where = {{.*}}`bar
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+thread backtrace
+# CHECK: frame #0: {{.*}}`bar
+# CHECK: frame #1: {{.*}}`foo + 6
+# CHECK: frame #2: {{.*}}`main + 20
+
+target modules show-unwind -n foo
+# CHECK: eh_frame UnwindPlan:
+# CHECK: row[0]: 0: CFA=rsp +8 => rip=r13
Index: lldb/trunk/lit/Unwind/Inputs/eh-frame-small-fde.s
===
--- lldb/trunk/lit/Unwind/Inputs/eh-frame-small-fde.s
+++ lldb/trunk/lit/Unwind/Inputs/eh-frame-small-fde.s
@@ -0,0 +1,48 @@
+.text
+.globl  bar
+.type   bar, @function
+bar:
+.LFB0:
+.cfi_startproc
+leal(%edi, %edi), %eax
+ret
+.cfi_endproc
+.LFE0:
+.size   bar, .-bar
+.globl  foo
+.type   foo, @function
+foo:
+.LFB1:
+nop # Make the FDE entry start one byte later than the actual function.
+.cfi_startproc
+.cfi_register %rip, %r13
+callbar
+addl$1, %eax
+jmp *%r13 # Return
+.cfi_endproc
+.LFE1:
+.size   foo, .-foo
+.globl  main
+.type   main, @function
+main:
+.LFB2:
+.cfi_startproc
+pushq   %rbp
+.cfi_def_cfa_offset 16
+.cfi_offset 6, -16
+movq%rsp, %rbp
+.cfi_def_cfa_register 6
+movl$47, %edi
+
+# Non-standard calling convention. Put return address in r13.
+pushq   %r13
+leaq1f(%rip), %r13
+jmp foo # call
+1:
+popq%r13
+popq%rbp
+.cfi_def_cfa 7, 8
+ret
+.cfi_endproc
+.LFE2:
+.size   main, .-main
Index: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
===
--- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
+++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h
@@ -35,17 +35,10 @@
 
   ~FuncUnwinders();
 
-  // current_offset is the byte offset into the function.
-  // 0 means no instructions have executed yet.  -1 means the offset is unknown.
-  // On architectures where the pc points to the next instruction that will
-  // execute, this offset value will have already been decremented by 1 to stay
-  // within the bounds of the correct function body.
-  lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target,
- int current_offset);
+  lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target);
 
   lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target,
-lldb_private::Thread &thread,
-int current_offset);
+lldb_private::Thread &thread);
 
   lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target,
  lldb_private::Thread &thread);
@@ -81,26 +74,21 @@
   // used. Instead, clients should ask for the *behavior* they are looking for,
   // using one of the above UnwindPlan retrieval methods.
 
-  lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread,
-   int current_offset);
+  lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread);
 
-  lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target, int current_offset);
+  lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target);
 
   lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target,
-   

[Lldb-commits] [lldb] r358967 - modify-python-lldb: Remove \a-removing code

2019-04-23 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Apr 23 03:04:22 2019
New Revision: 358967

URL: http://llvm.org/viewvc/llvm-project?rev=358967&view=rev
Log:
modify-python-lldb: Remove \a-removing code

instead, remove \a directly from the interface files.

Modified:
lldb/trunk/scripts/Python/modify-python-lldb.py
lldb/trunk/scripts/interface/SBCompileUnit.i
lldb/trunk/scripts/interface/SBModule.i
lldb/trunk/scripts/interface/SBTarget.i
lldb/trunk/scripts/interface/SBValue.i

Modified: lldb/trunk/scripts/Python/modify-python-lldb.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=358967&r1=358966&r2=358967&view=diff
==
--- lldb/trunk/scripts/Python/modify-python-lldb.py (original)
+++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue Apr 23 03:04:22 2019
@@ -121,10 +121,6 @@ for line in content.splitlines():
 state |= CLEANUP_DOCSTRING
 
 if (state & CLEANUP_DOCSTRING):
-# Remove the '\a ' and '\b 'substrings.
-line = line.replace('\a ', '')
-line = line.replace('\b ', '')
-
 line = char_to_str_xform(line)
 
 # Note that the transition out of CLEANUP_DOCSTRING is handled at the

Modified: lldb/trunk/scripts/interface/SBCompileUnit.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBCompileUnit.i?rev=358967&r1=358966&r2=358967&view=diff
==
--- lldb/trunk/scripts/interface/SBCompileUnit.i (original)
+++ lldb/trunk/scripts/interface/SBCompileUnit.i Tue Apr 23 03:04:22 2019
@@ -88,7 +88,7 @@ public:
 FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool 
full);
 
 %feature("docstring", "
- Get all types matching \a type_mask from debug info in this
+ Get all types matching type_mask from debug info in this
  compile unit.
 
  @param[in] type_mask
@@ -100,7 +100,7 @@ public:
 unit.
 
  @return
-A list of types in this compile unit that match \a type_mask") 
GetTypes;
+A list of types in this compile unit that match type_mask") GetTypes;
 lldb::SBTypeList
 GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
 

Modified: lldb/trunk/scripts/interface/SBModule.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBModule.i?rev=358967&r1=358966&r2=358967&view=diff
==
--- lldb/trunk/scripts/interface/SBModule.i (original)
+++ lldb/trunk/scripts/interface/SBModule.i Tue Apr 23 03:04:22 2019
@@ -270,7 +270,7 @@ public:
 GetBasicType(lldb::BasicType type);
 
 %feature("docstring", "
-Get all types matching \a type_mask from debug info in this
+Get all types matching type_mask from debug info in this
 module.
 
 @param[in] type_mask
@@ -281,7 +281,7 @@ public:
 all types found in the debug information for this module.
 
 @return
-A list of types in this module that match \a type_mask") GetTypes;
+A list of types in this module that match type_mask") GetTypes;
 lldb::SBTypeList
 GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
 
@@ -296,7 +296,7 @@ public:
 for.
 
 @param[in] max_matches
-Allow the number of matches to be limited to \a max_matches.
+Allow the number of matches to be limited to max_matches.
 
 @return
 A list of matched variables in an SBValueList.") FindGlobalVariables;

Modified: lldb/trunk/scripts/interface/SBTarget.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBTarget.i?rev=358967&r1=358966&r2=358967&view=diff
==
--- lldb/trunk/scripts/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/interface/SBTarget.i Tue Apr 23 03:04:22 2019
@@ -130,14 +130,14 @@ public:
 
 Launch a new process by spawning a new process using the
 target object's executable module's file as the file to launch.
-Arguments are given in \a argv, and the environment variables
-are in \a envp. Standard input and output files can be
-optionally re-directed to \a stdin_path, \a stdout_path, and
-\a stderr_path.
+Arguments are given in argv, and the environment variables
+are in envp. Standard input and output files can be
+optionally re-directed to stdin_path, stdout_path, and
+stderr_path.
 
 @param[in] listener
 An optional listener that will receive all process events.
-If \a listener is valid then \a listener will listen to all
+If listener is valid then listener will listen to all
 process events. If not valid, then this target's debugger
 (SBTarget::GetDebugger()) will listen to all process events.
 
@@ -278,7 +278,7 @@ public:
 
 @param[in] listener
 An optional listener that will rec

[Lldb-commits] [PATCH] D61000: Kill modify-python-lldb.py

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: amccarth, jingham, clayborg.
Herald added a subscriber: mgorny.

After the last round of cleanups, this script was almost a no-op. The
only piece of functionality that remained was the one which tried to
make the swig-generated function signatures more pythonic.

The "tried" part is important here, as it wasn't doing a really good job
and the end result was not valid python nor c (e.g.,
SetExecutable(SBAttachInfo self, str const * path)).

Doing these transformations another way is not possible, as these
signatures are generated by swig, and not present in source. However,
given that this is the only reason why we need a swig post-process step,
and that the current implementation is pretty sub-optimal, I propose we
simply abandon the the signature fixup idea, and choose to simplify our
build process instead.


https://reviews.llvm.org/D61000

Files:
  lldb.xcodeproj/project.pbxproj
  scripts/CMakeLists.txt
  scripts/Python/modify-python-lldb.py
  scripts/Python/prepare_binding_Python.py

Index: scripts/Python/prepare_binding_Python.py
===
--- scripts/Python/prepare_binding_Python.py
+++ scripts/Python/prepare_binding_Python.py
@@ -279,26 +279,6 @@
 logging.info("output: %s", script_stdout)
 
 
-def do_modify_python_lldb(options, config_build_dir):
-"""Executes the modify-python-lldb.py script.
-
-@param options the parsed command line arguments
-@param config_build_dir the directory where the Python output was created.
-"""
-script_path = os.path.normcase(
-os.path.join(
-options.src_root,
-"scripts",
-"Python",
-"modify-python-lldb.py"))
-
-if not os.path.exists(script_path):
-logging.error("failed to find python script: '%s'", script_path)
-sys.exit(-11)
-
-run_python_script([script_path, config_build_dir])
-
-
 def get_python_module_path(options):
 """Returns the location where the lldb Python module should be placed.
 
@@ -426,11 +406,6 @@
 # Generate the Python binding with swig.
 logging.info("Python binding is out of date, regenerating")
 do_swig_rebuild(options, dependency_file, config_build_dir, settings)
-if options.generate_dependency_file:
-return
-
-# Post process the swig-generated file.
-do_modify_python_lldb(options, config_build_dir)
 
 
 # This script can be called by another Python script by calling the main()
Index: scripts/Python/modify-python-lldb.py
===
--- scripts/Python/modify-python-lldb.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# modify-python-lldb.py
-#
-# This script modifies the lldb module (which was automatically generated via
-# running swig) to support iteration and/or equality operations for certain lldb
-# objects, implements truth value testing for certain lldb objects, and adds a
-# global variable 'debugger_unique_id' which is initialized to 0.
-#
-# As a cleanup step, it also removes the 'residues' from the autodoc features of
-# swig.  For an example, take a look at SBTarget.h header file, where we take
-# advantage of the already existing doxygen C++-docblock and make it the Python
-# docstring for the same method.  The 'residues' in this context include the c
-# comment marker, the trailing blank (SPC's) line, and the doxygen comment start
-# marker.
-#
-# In addition to the 'residues' removal during the cleanup step, it also
-# transforms the 'char' data type (which was actually 'char *' but the 'autodoc'
-# feature of swig removes ' *' from it) into 'str' (as a Python str type).
-
-# System modules
-import sys
-import re
-if sys.version_info.major >= 3:
-import io as StringIO
-else:
-import StringIO
-
-# import use_lldb_suite so we can find third-party and helper modules
-import use_lldb_suite
-
-# Third party modules
-import six
-
-# LLDB modules
-
-if len(sys.argv) != 2:
-output_name = "./lldb.py"
-else:
-output_name = sys.argv[1] + "/lldb.py"
-
-# print "output_name is '" + output_name + "'"
-
-#
-# Residues to be removed.
-#
-# The demarcation point for turning on/off residue removal state.
-# When bracketed by the lines, the CLEANUP_DOCSTRING state (see below) is ON.
-toggle_docstring_cleanup_line = '"""'
-
-
-def char_to_str_xform(line):
-"""This transforms the 'char', i.e, 'char *' to 'str', Python string."""
-line = line.replace(' char', ' str')
-line = line.replace('char ', 'str ')
-# Special case handling of 'char **argv' and 'char **envp'.
-line = line.replace('str argv', 'list argv')
-line = line.replace('str envp', 'list envp')
-return line
-
-#
-# The one-liner docstring also needs char_to_str transformation, btw.
-#
-TWO_SPACES = ' ' * 2
-EIGHT_SPACES = ' ' * 8
-one_liner_docstring_pattern = re.compile(
-'^(%s|%s)""".*"""$' %
-(TWO_SPACES, EIGHT_SPACES))
-
-class NewC

[Lldb-commits] [lldb] r358976 - Move postfix expression code out of the NativePDB plugin

2019-04-23 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Apr 23 04:50:07 2019
New Revision: 358976

URL: http://llvm.org/viewvc/llvm-project?rev=358976&view=rev
Log:
Move postfix expression code out of the NativePDB plugin

Summary:
The NativePDB plugin contains code to convert "programs" describing the
layout of function frames into dwarf (for easier interaction with the
rest of lldb). This functionality is useful for the Breakpad plugin too,
as it contains the same kind of expressions (because breakpad info is
generated from pdb files).

In this patch, I move the core classes of this code into a common place,
where it can be used from both files. Previously, these were the details
of the implementation, but here I am exposing them (instead of just a
single "string->string" conversion function), as breakpad will need to
use these in a slightly different way. The reason for that is that
breakpad files generated from dwarf expressions use a slightly different
syntax, although most of the core code can be reused with a bit of
thought.

This is also the reason why I am not moving the parsing or dwarf
generation bits, as they will need to be generalized a bit before
they're usable for both scenarios.

This patch should be NFC, modulo renaming the moved entities to more
neutral names.

The reason I am moving this to the "Symbol" library, is because both
customers will be "Symbol"Files, and also the unwinding code lives in
the Symbol library. From a purely dependency standpoint this code will
probably be standalone, and so it could be moved all the way to Utility,
but that seems too low for this kind of functionality.

Reviewers: jasonmolenda, amccarth, clayborg, JDevlieghere, aleksandr.urakov

Subscribers: aprantl, markmentovai, lldb-commits

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

Added:
lldb/trunk/include/lldb/Symbol/PostfixExpression.h
Modified:

lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp

Added: lldb/trunk/include/lldb/Symbol/PostfixExpression.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/PostfixExpression.h?rev=358976&view=auto
==
--- lldb/trunk/include/lldb/Symbol/PostfixExpression.h (added)
+++ lldb/trunk/include/lldb/Symbol/PostfixExpression.h Tue Apr 23 04:50:07 2019
@@ -0,0 +1,179 @@
+//===-- PostfixExpression.h -*- 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
+//
+//===--===//
+//
+//  This file implements support for postfix expressions found in several 
symbol
+//  file formats, and their conversion to DWARF.
+//
+//===--===//
+
+#ifndef LLDB_SYMBOL_POSTFIXEXPRESSION_H
+#define LLDB_SYMBOL_POSTFIXEXPRESSION_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+
+namespace lldb_private {
+namespace postfix {
+
+/// The base class for all nodes in the parsed postfix tree.
+class Node {
+public:
+  enum Kind {
+BinaryOp,
+Integer,
+Register,
+Symbol,
+UnaryOp,
+  };
+
+protected:
+  Node(Kind kind) : m_kind(kind) {}
+
+public:
+  Kind GetKind() const { return m_kind; }
+
+private:
+  Kind m_kind;
+};
+
+/// A node representing a binary expression.
+class BinaryOpNode : public Node {
+public:
+  enum OpType {
+Align, // alignDown(a, b)
+Minus, // a - b
+Plus,  // a + b
+  };
+
+  BinaryOpNode(OpType op_type, Node &left, Node &right)
+  : Node(BinaryOp), m_op_type(op_type), m_left(&left), m_right(&right) {}
+
+  OpType GetOpType() const { return m_op_type; }
+
+  const Node *Left() const { return m_left; }
+  Node *&Left() { return m_left; }
+
+  const Node *Right() const { return m_right; }
+  Node *&Right() { return m_right; }
+
+  static bool classof(const Node *node) { return node->GetKind() == BinaryOp; }
+
+private:
+  OpType m_op_type;
+  Node *m_left;
+  Node *m_right;
+};
+
+/// A node representing an integer literal.
+class IntegerNode : public Node {
+public:
+  IntegerNode(uint32_t value) : Node(Integer), m_value(value) {}
+
+  uint32_t GetValue() const { return m_value; }
+
+  static bool classof(const Node *node) { return node->GetKind() == Integer; }
+
+private:
+  uint32_t m_value;
+};
+
+/// A node representing the value of a register with the given register number.
+/// The register kind (RegisterKind enum) used for the specifying the register
+/// number is implicit and assumed to be the same for all Register nodes in a
+/// given tree.
+class RegisterNode : public Node {
+public:
+  RegisterNode(uint32_t reg_num) : Node(Register), m_reg_num(reg_num) {}
+
+  uint32_t GetRegNum() const { return m_reg_num; }
+
+  static bool classof(const Node *node) { ret

[Lldb-commits] [PATCH] D60599: Move postfix expression code out of the NativePDB plugin

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB358976: Move postfix expression code out of the NativePDB 
plugin (authored by labath, committed by ).
Herald added a subscriber: abidh.
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D60599?vs=194816&id=196214#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60599

Files:
  include/lldb/Symbol/PostfixExpression.h
  source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp

Index: include/lldb/Symbol/PostfixExpression.h
===
--- include/lldb/Symbol/PostfixExpression.h
+++ include/lldb/Symbol/PostfixExpression.h
@@ -0,0 +1,179 @@
+//===-- PostfixExpression.h -*- 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
+//
+//===--===//
+//
+//  This file implements support for postfix expressions found in several symbol
+//  file formats, and their conversion to DWARF.
+//
+//===--===//
+
+#ifndef LLDB_SYMBOL_POSTFIXEXPRESSION_H
+#define LLDB_SYMBOL_POSTFIXEXPRESSION_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+
+namespace lldb_private {
+namespace postfix {
+
+/// The base class for all nodes in the parsed postfix tree.
+class Node {
+public:
+  enum Kind {
+BinaryOp,
+Integer,
+Register,
+Symbol,
+UnaryOp,
+  };
+
+protected:
+  Node(Kind kind) : m_kind(kind) {}
+
+public:
+  Kind GetKind() const { return m_kind; }
+
+private:
+  Kind m_kind;
+};
+
+/// A node representing a binary expression.
+class BinaryOpNode : public Node {
+public:
+  enum OpType {
+Align, // alignDown(a, b)
+Minus, // a - b
+Plus,  // a + b
+  };
+
+  BinaryOpNode(OpType op_type, Node &left, Node &right)
+  : Node(BinaryOp), m_op_type(op_type), m_left(&left), m_right(&right) {}
+
+  OpType GetOpType() const { return m_op_type; }
+
+  const Node *Left() const { return m_left; }
+  Node *&Left() { return m_left; }
+
+  const Node *Right() const { return m_right; }
+  Node *&Right() { return m_right; }
+
+  static bool classof(const Node *node) { return node->GetKind() == BinaryOp; }
+
+private:
+  OpType m_op_type;
+  Node *m_left;
+  Node *m_right;
+};
+
+/// A node representing an integer literal.
+class IntegerNode : public Node {
+public:
+  IntegerNode(uint32_t value) : Node(Integer), m_value(value) {}
+
+  uint32_t GetValue() const { return m_value; }
+
+  static bool classof(const Node *node) { return node->GetKind() == Integer; }
+
+private:
+  uint32_t m_value;
+};
+
+/// A node representing the value of a register with the given register number.
+/// The register kind (RegisterKind enum) used for the specifying the register
+/// number is implicit and assumed to be the same for all Register nodes in a
+/// given tree.
+class RegisterNode : public Node {
+public:
+  RegisterNode(uint32_t reg_num) : Node(Register), m_reg_num(reg_num) {}
+
+  uint32_t GetRegNum() const { return m_reg_num; }
+
+  static bool classof(const Node *node) { return node->GetKind() == Register; }
+
+private:
+  uint32_t m_reg_num;
+};
+
+/// A node representing a symbolic reference to a named entity. This may be a
+/// register, which hasn't yet been resolved to a RegisterNode.
+class SymbolNode : public Node {
+public:
+  SymbolNode(llvm::StringRef name) : Node(Symbol), m_name(name) {}
+
+  llvm::StringRef GetName() const { return m_name; }
+
+  static bool classof(const Node *node) { return node->GetKind() == Symbol; }
+
+private:
+  llvm::StringRef m_name;
+};
+
+/// A node representing a unary operation.
+class UnaryOpNode : public Node {
+public:
+  enum OpType {
+Deref, // *a
+  };
+
+  UnaryOpNode(OpType op_type, Node &operand)
+  : Node(UnaryOp), m_op_type(op_type), m_operand(&operand) {}
+
+  OpType GetOpType() const { return m_op_type; }
+
+  const Node *Operand() const { return m_operand; }
+  Node *&Operand() { return m_operand; }
+
+  static bool classof(const Node *node) { return node->GetKind() == UnaryOp; }
+
+private:
+  OpType m_op_type;
+  Node *m_operand;
+};
+
+/// A template class implementing a visitor pattern, but with a couple of
+/// twists:
+/// - It uses type switch instead of virtual double dispatch. This allows the
+//node classes to be vtable-free and trivially destructible.
+/// - The Visit functions get an extra Node *& parameter, which refers to the
+///   child pointer of the parent of the node we are currently visiting. This
+///   allows mutating algorithms, which replace the currently visited node with
+///   a different one.
+/// - 

[Lldb-commits] [PATCH] D59831: [CMake] macOS: Find DebugSymbols.framework inside the SDK

2019-04-23 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz accepted this revision.
sgraenitz added a comment.

LGTM too. Did this land?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59831



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


[Lldb-commits] [PATCH] D61003: PostfixExpression: move parser out of NativePDB internals

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: amccarth, clayborg, JDevlieghere, aleksandr.urakov.
Herald added a subscriber: mgorny.

The postfix expressions in PDB and breakpad symbol files are similar
enough that they can be parsed by the same parser. This patch
generalizes the parser in the NativePDB plugin and moves it into the
PostfixExpression file created in the previous commit (r358976).

The generalization consists of treating any unrecognised token as a
"symbol" node (previously these would only be created for tokens
starting with "$", and other token would abort the parse). This is
needed because breakpad symbols can also contain ".cfa" tokens, which
refer to the frame's CFA.

The cosmetic changes include:

- using a factory function instead of a class for creating nodes (this is more 
generic as it allows the same BumpPtrAllocator to be used for other things too)
- using dedicated function for parsing operator tokens instead of a DenseMap 
(more efficient as we don't need to create the DenseMap every time).


https://reviews.llvm.org/D61003

Files:
  include/lldb/Symbol/PostfixExpression.h
  source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
  source/Symbol/CMakeLists.txt
  source/Symbol/PostfixExpression.cpp
  unittests/Symbol/CMakeLists.txt
  unittests/Symbol/PostfixExpressionTest.cpp

Index: unittests/Symbol/PostfixExpressionTest.cpp
===
--- /dev/null
+++ unittests/Symbol/PostfixExpressionTest.cpp
@@ -0,0 +1,97 @@
+//===-- PostfixExpressionTest.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/Symbol/PostfixExpression.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace lldb_private::postfix;
+
+static std::string ToString(BinaryOpNode::OpType type) {
+  switch (type) {
+  case BinaryOpNode::Align:
+return "@";
+  case BinaryOpNode::Minus:
+return "-";
+  case BinaryOpNode::Plus:
+return "+";
+  }
+  llvm_unreachable("Fully covered switch!");
+}
+
+static std::string ToString(UnaryOpNode::OpType type) {
+  switch (type) {
+  case UnaryOpNode::Deref:
+return "^";
+  }
+  llvm_unreachable("Fully covered switch!");
+}
+
+struct ASTPrinter : public Visitor {
+protected:
+  std::string Visit(BinaryOpNode &binary, Node *&) override {
+return llvm::formatv("{0}({1}, {2})", ToString(binary.GetOpType()),
+ Dispatch(binary.Left()), Dispatch(binary.Right()));
+  }
+
+  std::string Visit(IntegerNode &integer, Node *&) override {
+return llvm::formatv("int({0})", integer.GetValue());
+  }
+
+  std::string Visit(RegisterNode ®, Node *&) override {
+return llvm::formatv("reg({0})", reg.GetRegNum());
+  }
+
+  std::string Visit(SymbolNode &symbol, Node *&) override {
+return symbol.GetName();
+  }
+
+  std::string Visit(UnaryOpNode &unary, Node *&) override {
+return llvm::formatv("{0}({1})", ToString(unary.GetOpType()),
+ Dispatch(unary.Operand()));
+  }
+
+public:
+  static std::string Print(Node *node) {
+if (node)
+  return ASTPrinter().Dispatch(node);
+return "nullptr";
+  }
+};
+
+static std::string ParseAndStringify(llvm::StringRef expr) {
+  llvm::BumpPtrAllocator alloc;
+  return ASTPrinter::Print(Parse(expr, alloc));
+}
+
+TEST(PostfixExpression, Parse) {
+  EXPECT_EQ("int(47)", ParseAndStringify("47"));
+  EXPECT_EQ("$foo", ParseAndStringify("$foo"));
+  EXPECT_EQ("+(int(1), int(2))", ParseAndStringify("1 2 +"));
+  EXPECT_EQ("-(int(1), int(2))", ParseAndStringify("1 2 -"));
+  EXPECT_EQ("@(int(1), int(2))", ParseAndStringify("1 2 @"));
+  EXPECT_EQ("+(int(1), +(int(2), int(3)))", ParseAndStringify("1 2 3 + +"));
+  EXPECT_EQ("+(+(int(1), int(2)), int(3))", ParseAndStringify("1 2 + 3 +"));
+  EXPECT_EQ("^(int(1))", ParseAndStringify("1 ^"));
+  EXPECT_EQ("^(^(int(1)))", ParseAndStringify("1 ^ ^"));
+  EXPECT_EQ("^(+(int(1), ^(int(2", ParseAndStringify("1 2 ^ + ^"));
+  EXPECT_EQ("-($foo, int(47))", ParseAndStringify("$foo 47 -"));
+
+  EXPECT_EQ("nullptr", ParseAndStringify("+"));
+  EXPECT_EQ("nullptr", ParseAndStringify("^"));
+  EXPECT_EQ("nullptr", ParseAndStringify("1 +"));
+  EXPECT_EQ("nullptr", ParseAndStringify("1 2 ^"));
+  EXPECT_EQ("nullptr", ParseAndStringify("1 2 3 +"));
+  EXPECT_EQ("nullptr", ParseAndStringify("^ 1"));
+  EXPECT_EQ("nullptr", ParseAndStringify("+ 1 2"));
+  EXPECT_EQ("nullptr", ParseAndStringify("1 + 2"));
+  EXPECT_EQ("nullptr", ParseAndStringify("1 2"));
+  EXPECT_EQ("nullptr", ParseAndStringify(""));
+}
Index: unittests/Symbol/CMakeLists.txt
===

[Lldb-commits] [PATCH] D61004: FuncUnwinders: Factor out address validity check

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jasonmolenda, aprantl.

Some (but not all) of the unwind plan creation functions were checking
the validity of their address range before they attempted to create the
unwind plan.

Since a FuncUnwinders object cannot do anything reasonable with an
invalid address range, in this patch I remove the checks in from the
creation functions, and instead make it's validity a class invariant.
This makes it the responsibility of whoever's creating the FuncUnwinders
to ensure it does that with a valid address range, which is easy to
achieve as there is only one place we are doing that.


https://reviews.llvm.org/D61004

Files:
  include/lldb/Symbol/FuncUnwinders.h
  source/Symbol/FuncUnwinders.cpp
  source/Symbol/UnwindTable.cpp

Index: source/Symbol/UnwindTable.cpp
===
--- source/Symbol/UnwindTable.cpp
+++ source/Symbol/UnwindTable.cpp
@@ -89,11 +89,13 @@
 return range;
 
   // Does the eh_frame unwind info has a function bounds for this addr?
-  if (m_eh_frame_up && m_eh_frame_up->GetAddressRange(addr, range))
+  if (m_eh_frame_up && m_eh_frame_up->GetAddressRange(addr, range) &&
+  range.GetBaseAddress().IsValid())
 return range;
 
   // Try debug_frame as well
-  if (m_debug_frame_up && m_debug_frame_up->GetAddressRange(addr, range))
+  if (m_debug_frame_up && m_debug_frame_up->GetAddressRange(addr, range) &&
+  range.GetBaseAddress().IsValid())
 return range;
 
   return llvm::None;
Index: source/Symbol/FuncUnwinders.cpp
===
--- source/Symbol/FuncUnwinders.cpp
+++ source/Symbol/FuncUnwinders.cpp
@@ -45,7 +45,9 @@
   m_tried_unwind_plan_arm_unwind(false), m_tried_unwind_fast(false),
   m_tried_unwind_arch_default(false),
   m_tried_unwind_arch_default_at_func_entry(false),
-  m_first_non_prologue_insn() {}
+  m_first_non_prologue_insn() {
+  assert(range.GetBaseAddress().IsValid());
+}
 
 /// destructor
 
@@ -75,17 +77,15 @@
 return UnwindPlanSP();
 
   m_tried_unwind_plan_compact_unwind = true;
-  if (m_range.GetBaseAddress().IsValid()) {
-Address current_pc(m_range.GetBaseAddress());
-CompactUnwindInfo *compact_unwind = m_unwind_table.GetCompactUnwindInfo();
-if (compact_unwind) {
-  UnwindPlanSP unwind_plan_sp(new UnwindPlan(lldb::eRegisterKindGeneric));
-  if (compact_unwind->GetUnwindPlan(target, current_pc, *unwind_plan_sp)) {
-m_unwind_plan_compact_unwind.push_back(unwind_plan_sp);
-return m_unwind_plan_compact_unwind[0]; // FIXME support multiple
-// compact unwind plans for one
-// func
-  }
+  Address current_pc(m_range.GetBaseAddress());
+  CompactUnwindInfo *compact_unwind = m_unwind_table.GetCompactUnwindInfo();
+  if (compact_unwind) {
+UnwindPlanSP unwind_plan_sp(new UnwindPlan(lldb::eRegisterKindGeneric));
+if (compact_unwind->GetUnwindPlan(target, current_pc, *unwind_plan_sp)) {
+  m_unwind_plan_compact_unwind.push_back(unwind_plan_sp);
+  return m_unwind_plan_compact_unwind[0]; // FIXME support multiple
+  // compact unwind plans for one
+  // func
 }
   }
   return UnwindPlanSP();
@@ -97,14 +97,12 @@
 return m_unwind_plan_eh_frame_sp;
 
   m_tried_unwind_plan_eh_frame = true;
-  if (m_range.GetBaseAddress().IsValid()) {
-DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo();
-if (eh_frame) {
-  m_unwind_plan_eh_frame_sp =
-  std::make_shared(lldb::eRegisterKindGeneric);
-  if (!eh_frame->GetUnwindPlan(m_range, *m_unwind_plan_eh_frame_sp))
-m_unwind_plan_eh_frame_sp.reset();
-}
+  DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo();
+  if (eh_frame) {
+m_unwind_plan_eh_frame_sp =
+std::make_shared(lldb::eRegisterKindGeneric);
+if (!eh_frame->GetUnwindPlan(m_range, *m_unwind_plan_eh_frame_sp))
+  m_unwind_plan_eh_frame_sp.reset();
   }
   return m_unwind_plan_eh_frame_sp;
 }
@@ -115,14 +113,13 @@
 return m_unwind_plan_debug_frame_sp;
 
   m_tried_unwind_plan_debug_frame = true;
-  if (m_range.GetBaseAddress().IsValid()) {
-DWARFCallFrameInfo *debug_frame = m_unwind_table.GetDebugFrameInfo();
-if (debug_frame) {
-  m_unwind_plan_debug_frame_sp =
-  std::make_shared(lldb::eRegisterKindGeneric);
-  if (!debug_frame->GetUnwindPlan(m_range, *m_unwind_plan_debug_frame_sp))
-m_unwind_plan_debug_frame_sp.reset();
-}
+  DWARFCallFrameInfo *debug_frame = m_unwind_table.GetDebugFrameInfo();
+  if (debug_frame) {
+m_unwind_plan_debug_frame_sp =
+std::make_shared(lldb::eRegisterKindGeneric);
+if (!debug_frame->GetUnwindPlan(m_range,
+*m_unwind_plan_debug_frame_sp))
+  m_unwin

[Lldb-commits] [PATCH] D60962: [NativePDB] Extend .pdb files search folders

2019-04-23 Thread Mikhail Senkov via Phabricator via lldb-commits
zloyrobot updated this revision to Diff 196226.
zloyrobot added a comment.

Add test case for searching .pdb file in the same folder as .exe file


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

https://reviews.llvm.org/D60962

Files:
  lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp


Index: lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
===
--- /dev/null
+++ lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
@@ -0,0 +1,31 @@
+// clang-format off
+// REQUIRES: lld
+
+// Test that we can find .pdb file in _NT_SYMBOL_PATH folder. 
+// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
+// RUN: mkdir -p %t
+// RUN: mv %t.pdb %t/pdb-file-lookup.cpp.tmp.pdb
+// RUN: env _NT_SYMBOL_PATH=%t LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s 
\
+// RUN: %p/Inputs/pdb-file-lookup.lldbinit | FileCheck %s
+//
+// Test that we can find .pdb file in folder containing .exe file.
+// RUN: mv %t.exe %t/pdb-file-lookup.cpp.tmp.exe
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f \
+// RUN: %t/pdb-file-lookup.cpp.tmp.exe -s \
+// RUN: %p/Inputs/pdb-file-lookup.lldbinit | FileCheck %s
+
+
+
+int main(int argc, char **argv) {
+  // Here are some comments.
+  return 0;
+}
+
+// CHECK: (lldb) source list -n main
+// CHECK: File: {{.*}}pdb-file-lookup.cpp
+// CHECK:18
+// CHECK:19   int main(int argc, char **argv) {
+// CHECK:20 // Here are some comments.
+// CHECK:21 return 0;
+// CHECK:22   }
+// CHECK:23


Index: lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
===
--- /dev/null
+++ lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
@@ -0,0 +1,31 @@
+// clang-format off
+// REQUIRES: lld
+
+// Test that we can find .pdb file in _NT_SYMBOL_PATH folder. 
+// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
+// RUN: mkdir -p %t
+// RUN: mv %t.pdb %t/pdb-file-lookup.cpp.tmp.pdb
+// RUN: env _NT_SYMBOL_PATH=%t LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
+// RUN: %p/Inputs/pdb-file-lookup.lldbinit | FileCheck %s
+//
+// Test that we can find .pdb file in folder containing .exe file.
+// RUN: mv %t.exe %t/pdb-file-lookup.cpp.tmp.exe
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f \
+// RUN: %t/pdb-file-lookup.cpp.tmp.exe -s \
+// RUN: %p/Inputs/pdb-file-lookup.lldbinit | FileCheck %s
+
+
+
+int main(int argc, char **argv) {
+  // Here are some comments.
+  return 0;
+}
+
+// CHECK: (lldb) source list -n main
+// CHECK: File: {{.*}}pdb-file-lookup.cpp
+// CHECK:18
+// CHECK:19   int main(int argc, char **argv) {
+// CHECK:20 // Here are some comments.
+// CHECK:21 return 0;
+// CHECK:22   }
+// CHECK:23
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D60962: [NativePDB] Extend .pdb files search folders

2019-04-23 Thread Mikhail Senkov via Phabricator via lldb-commits
zloyrobot updated this revision to Diff 196232.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60962

Files:
  lldb/lit/SymbolFile/NativePDB/Inputs/pdb-file-lookup.lldbinit
  lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -106,6 +106,43 @@
   return File;
 }
 
+
+static std::string findPdbFile(const llvm::StringRef exe_path, const llvm::StringRef pdb_file, llvm::file_magic &magic) {
+  auto ec = llvm::identify_magic(pdb_file, magic);
+  if (!ec)
+return pdb_file;
+
+  auto pdb_file_name = llvm::sys::path::filename(pdb_file);
+
+  llvm::SmallString<128> path = exe_path;
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, pdb_file_name);
+
+  ec = llvm::identify_magic(path, magic);
+  if (!ec)
+return path.str();
+
+  llvm::StringRef nt_symbol_path = ::getenv("_NT_SYMBOL_PATH");
+  llvm::SmallVector parts;
+  nt_symbol_path.split(parts, ';', -1, false);
+
+  for (auto part_ref : parts)  {
+if (part_ref.startswith_lower("srv*")) {
+  //Symbol servers is not supported yet
+  continue;
+}
+
+path = part_ref;
+llvm::sys::path::append(path, pdb_file_name);
+
+ec = llvm::identify_magic(path, magic);
+if (!ec) {
+  return path.str();
+}
+  }
+
+  return {};
+}
 static std::unique_ptr
 loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
   // Try to find a matching PDB for an EXE.
@@ -130,13 +167,14 @@
   if (ec)
 return nullptr;
 
+  llvm::file_magic magic;
+  auto pdb_full_path = findPdbFile(exe_path, pdb_file, magic);
+
   // if the file doesn't exist, is not a pdb, or doesn't have a matching guid,
   // fail.
-  llvm::file_magic magic;
-  ec = llvm::identify_magic(pdb_file, magic);
-  if (ec || magic != llvm::file_magic::pdb)
+  if (pdb_full_path.empty() || magic != llvm::file_magic::pdb)
 return nullptr;
-  std::unique_ptr pdb = loadPDBFile(pdb_file, allocator);
+  std::unique_ptr pdb = loadPDBFile(pdb_full_path, allocator);
   if (!pdb)
 return nullptr;
 
Index: lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
===
--- /dev/null
+++ lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
@@ -0,0 +1,31 @@
+// clang-format off
+// REQUIRES: lld
+
+// Test that we can find .pdb file in _NT_SYMBOL_PATH folder. 
+// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
+// RUN: mkdir -p %t
+// RUN: mv %t.pdb %t/pdb-file-lookup.cpp.tmp.pdb
+// RUN: env _NT_SYMBOL_PATH=%t LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
+// RUN: %p/Inputs/pdb-file-lookup.lldbinit | FileCheck %s
+//
+// Test that we can find .pdb file in folder containing .exe file.
+// RUN: mv %t.exe %t/pdb-file-lookup.cpp.tmp.exe
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f \
+// RUN: %t/pdb-file-lookup.cpp.tmp.exe -s \
+// RUN: %p/Inputs/pdb-file-lookup.lldbinit | FileCheck %s
+
+
+
+int main(int argc, char **argv) {
+  // Here are some comments.
+  return 0;
+}
+
+// CHECK: (lldb) source list -n main
+// CHECK: File: {{.*}}pdb-file-lookup.cpp
+// CHECK:18
+// CHECK:19   int main(int argc, char **argv) {
+// CHECK:20 // Here are some comments.
+// CHECK:21 return 0;
+// CHECK:22   }
+// CHECK:23
Index: lldb/lit/SymbolFile/NativePDB/Inputs/pdb-file-lookup.lldbinit
===
--- /dev/null
+++ lldb/lit/SymbolFile/NativePDB/Inputs/pdb-file-lookup.lldbinit
@@ -0,0 +1,2 @@
+source list -n main
+quit
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61018: RegisterContextLLDB: Push CFA value on DWARF stack when evaluating register expressions

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jasonmolenda, clayborg.
Herald added a subscriber: aprantl.

This behavior is specified in the Section 6.4.2.3 (Register Rule
instructions) of the DWARF4 spec. We were not doing that, which meant
that any register rule which was relying on the cfa value being there
was not evaluated correctly (it was aborted due to "out of bounds"
access).

I'm not sure how come this wasn't noticed before, but I guess this has
something to do with the fact that dwarf unwind expressions are not used
very often, and when they are, the situation is so complicated that the
CFA is of no use. I noticed this when I started emitting dwarf
expressions for the unwind information present in breakpad symbol files.


https://reviews.llvm.org/D61018

Files:
  lit/Unwind/Inputs/eh-frame-dwarf-unwind.s
  lit/Unwind/eh-frame-dwarf-unwind.test
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp


Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -1507,9 +1507,11 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0,
   unwindplan_regloc.GetDWARFExpressionLength());
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
+Value cfa_val = Scalar(m_cfa);
+cfa_val.SetValueType(Value::eValueTypeLoadAddress);
 Value result;
 Status error;
-if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result,
+if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
&error)) {
   addr_t val;
   val = result.GetScalar().ULongLong();
Index: lit/Unwind/eh-frame-dwarf-unwind.test
===
--- /dev/null
+++ lit/Unwind/eh-frame-dwarf-unwind.test
@@ -0,0 +1,22 @@
+# Test handing of dwarf expressions specifying the location of registers, if
+# those expressions refer to the frame's CFA value.
+
+# REQUIRES: target-x86_64, system-linux, native
+
+# RUN: %clang %p/Inputs/eh-frame-dwarf-unwind.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set -n bar
+# CHECK: Breakpoint 1: where = {{.*}}`bar
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+thread backtrace
+# CHECK: frame #0: {{.*}}`bar
+# CHECK: frame #1: {{.*}}`foo + 5
+# CHECK: frame #2: {{.*}}`main + 19
+
+target modules show-unwind -n foo
+# CHECK: eh_frame UnwindPlan:
+# CHECK: row[0]: 0: CFA=rsp +8 => rip=DW_OP_lit8 , DW_OP_minus , DW_OP_deref , 
DW_OP_const1u 0x47, DW_OP_minus
Index: lit/Unwind/Inputs/eh-frame-dwarf-unwind.s
===
--- /dev/null
+++ lit/Unwind/Inputs/eh-frame-dwarf-unwind.s
@@ -0,0 +1,49 @@
+.text
+.globl  bar
+.type   bar, @function
+bar:
+.LFB0:
+.cfi_startproc
+leal(%edi, %edi), %eax
+ret
+.cfi_endproc
+.LFE0:
+.size   bar, .-bar
+.globl  foo
+.type   foo, @function
+foo:
+.LFB1:
+.cfi_startproc
+.cfi_escape 0x16, 0x10, 0x06, 0x38, 0x1c, 0x06, 0x08, 0x47, 0x1c
+callbar
+addl$1, %eax
+popq%rdi
+subq$0x47, %rdi
+jmp *%rdi # Return
+.cfi_endproc
+.LFE1:
+.size   foo, .-foo
+.globl  main
+.type   main, @function
+main:
+.LFB2:
+.cfi_startproc
+pushq   %rbp
+.cfi_def_cfa_offset 16
+.cfi_offset 6, -16
+movq%rsp, %rbp
+.cfi_def_cfa_register 6
+movl$47, %edi
+
+# Non-standard calling convention. The real return address must be
+# decremented by 0x47.
+leaq0x47+1f(%rip), %rax
+pushq   %rax
+jmp foo # call
+1:
+popq%rbp
+.cfi_def_cfa 7, 8
+ret
+.cfi_endproc
+.LFE2:
+.size   main, .-main


Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -1507,9 +1507,11 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0,
   unwindplan_regloc.GetDWARFExpressionLength());
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
+Value cfa_val = Scalar(m_cfa);
+cfa_val.SetValueType(Value::eValueTypeLoadAddress);
 Value result;
 Status error;
-if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result,
+if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
&error)) {
   addr_t val;
   val = result.GetScalar().ULongLong();
Index: lit/Unwind/eh-frame-dwarf-unwind.test
=

[Lldb-commits] [PATCH] D61018: RegisterContextLLDB: Push CFA value on DWARF stack when evaluating register expressions

2019-04-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Got errors trying to compile this .s file on mac:

  $ ~/Documents/src/lldb/svn/lldb/llvm-build/Release+Asserts/x86_64/bin/clang 
foo.s -o foo.o
  foo.s:3:9: error: unknown directive
  .type bar, @function
  ^
  foo.s:11:9: error: unknown directive
  .size bar, .-bar
  ^
  foo.s:13:9: error: unknown directive
  .type foo, @function
  ^
  foo.s:25:9: error: unknown directive
  .size foo, .-foo
  ^
  foo.s:27:9: error: unknown directive
  .type main, @function
  ^
  foo.s:49:9: error: unknown directive
  .size main, .-main


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

https://reviews.llvm.org/D61018



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


[Lldb-commits] [PATCH] D61018: RegisterContextLLDB: Push CFA value on DWARF stack when evaluating register expressions

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D61018#1475553 , @clayborg wrote:

> Got errors trying to compile this .s file on mac:
>
>   $ ~/Documents/src/lldb/svn/lldb/llvm-build/Release+Asserts/x86_64/bin/clang 
> foo.s -o foo.o
>   foo.s:3:9: error: unknown directive
>   .type bar, @function
>   ^
>   foo.s:11:9: error: unknown directive
>   .size bar, .-bar
>   ^
>   foo.s:13:9: error: unknown directive
>   .type foo, @function
>   ^
>   foo.s:25:9: error: unknown directive
>   .size foo, .-foo
>   ^
>   foo.s:27:9: error: unknown directive
>   .type main, @function
>   ^
>   foo.s:49:9: error: unknown directive
>   .size main, .-main
>


Yeah, that test is linux-only (technically, other elf platforms may work too). 
I am not aware of any way to generate eh_frame entries with this kind of 
content except by hand-written assembly, and assembly is not really 
cross-platform.

If you just want to look at the resulting binary, you can add `-target 
x86_64-pc-linux -c` to the clang invocation, but that of course still won't run 
on a mac.


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

https://reviews.llvm.org/D61018



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


[Lldb-commits] [PATCH] D61018: RegisterContextLLDB: Push CFA value on DWARF stack when evaluating register expressions

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Actually, it seems it may be possible to tweak this asm so that it can run on a 
mac too (windows support unlikely). I'll try to post an updated version soon.


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

https://reviews.llvm.org/D61018



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


[Lldb-commits] [PATCH] D61000: Kill modify-python-lldb.py

2019-04-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Can you post a diff of things before and after? Hard to tell what we are opting 
out of just by seeing this patch


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

https://reviews.llvm.org/D61000



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


[Lldb-commits] [PATCH] D61000: Kill modify-python-lldb.py

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Sure. This is the diff: F8747706: modify.diff 
.


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

https://reviews.llvm.org/D61000



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


[Lldb-commits] [PATCH] D61018: RegisterContextLLDB: Push CFA value on DWARF stack when evaluating register expressions

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 196253.
labath added a comment.

This is the version that should at least compile on a mac (it turns out asm is 
more portable than I expected). I am still building lldb to see if the test 
will pass.


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

https://reviews.llvm.org/D61018

Files:
  lit/Unwind/Inputs/call-asm.c
  lit/Unwind/Inputs/eh-frame-dwarf-unwind.s
  lit/Unwind/eh-frame-dwarf-unwind.test
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp


Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -1507,9 +1507,11 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0,
   unwindplan_regloc.GetDWARFExpressionLength());
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
+Value cfa_val = Scalar(m_cfa);
+cfa_val.SetValueType(Value::eValueTypeLoadAddress);
 Value result;
 Status error;
-if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result,
+if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
&error)) {
   addr_t val;
   val = result.GetScalar().ULongLong();
Index: lit/Unwind/eh-frame-dwarf-unwind.test
===
--- /dev/null
+++ lit/Unwind/eh-frame-dwarf-unwind.test
@@ -0,0 +1,22 @@
+# Test handing of dwarf expressions specifying the location of registers, if
+# those expressions refer to the frame's CFA value.
+
+# REQUIRES: target-x86_64, native
+
+# RUN: %clang %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set -n bar
+# CHECK: Breakpoint 1: where = {{.*}}`bar
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+thread backtrace
+# CHECK: frame #0: {{.*}}`bar
+# CHECK: frame #1: {{.*}}`foo + 5
+# CHECK: frame #2: {{.*}}`asm_main + 22
+
+target modules show-unwind -n foo
+# CHECK: eh_frame UnwindPlan:
+# CHECK: row[0]: 0: CFA=rsp +8 => rip=DW_OP_lit8 , DW_OP_minus , DW_OP_deref , 
DW_OP_const1u 0x47, DW_OP_minus
Index: lit/Unwind/Inputs/eh-frame-dwarf-unwind.s
===
--- /dev/null
+++ lit/Unwind/Inputs/eh-frame-dwarf-unwind.s
@@ -0,0 +1,39 @@
+.text
+.globl  bar
+bar:
+.cfi_startproc
+leal(%edi, %edi), %eax
+ret
+.cfi_endproc
+
+.globl  foo
+foo:
+.cfi_startproc
+.cfi_escape 0x16, 0x10, 0x06, 0x38, 0x1c, 0x06, 0x08, 0x47, 0x1c
+callbar
+addl$1, %eax
+popq%rdi
+subq$0x47, %rdi
+jmp *%rdi # Return
+.cfi_endproc
+
+.globl  asm_main
+asm_main:
+.cfi_startproc
+pushq   %rbp
+.cfi_def_cfa_offset 16
+.cfi_offset 6, -16
+movq%rsp, %rbp
+.cfi_def_cfa_register 6
+movl$47, %edi
+
+# Non-standard calling convention. The real return address must be
+# decremented by 0x47.
+leaq0x47+1f(%rip), %rax
+pushq   %rax
+jmp foo # call
+1:
+popq%rbp
+.cfi_def_cfa 7, 8
+ret
+.cfi_endproc
Index: lit/Unwind/Inputs/call-asm.c
===
--- /dev/null
+++ lit/Unwind/Inputs/call-asm.c
@@ -0,0 +1,3 @@
+int asm_main() asm("asm_main");
+
+int main() { return asm_main(); }


Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -1507,9 +1507,11 @@
 DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0,
   unwindplan_regloc.GetDWARFExpressionLength());
 dwarfexpr.SetRegisterKind(unwindplan_registerkind);
+Value cfa_val = Scalar(m_cfa);
+cfa_val.SetValueType(Value::eValueTypeLoadAddress);
 Value result;
 Status error;
-if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result,
+if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
&error)) {
   addr_t val;
   val = result.GetScalar().ULongLong();
Index: lit/Unwind/eh-frame-dwarf-unwind.test
===
--- /dev/null
+++ lit/Unwind/eh-frame-dwarf-unwind.test
@@ -0,0 +1,22 @@
+# Test handing of dwarf expressions specifying the location of registers, if
+# those expressions refer to the frame's CFA value.
+
+# REQUIRES: target-x86_64, native
+
+# RUN: %clang %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind.s -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+breakpoint set

[Lldb-commits] [PATCH] D61018: RegisterContextLLDB: Push CFA value on DWARF stack when evaluating register expressions

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Indeed the test passes on a mac with just a single linker warning saying it 
could not create compact unwind info because the %rip save address is weird, 
but that is not surprising.


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

https://reviews.llvm.org/D61018



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


[Lldb-commits] [PATCH] D60963: Fix dereferencing null pointer

2019-04-23 Thread Mikhail Senkov via Phabricator via lldb-commits
zloyrobot added a comment.

In D60963#1474783 , @thakis wrote:

> test?


Would you please advise me on what kind of test I should add for such fix?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60963



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


[Lldb-commits] [PATCH] D59991: [Linux/x86] Fix writing of non-gpr registers on newer processors

2019-04-23 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet added inline comments.



Comment at: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp:282
+  // Then fetch the maximum size of the area.
+  if (!__get_cpuid_count(0x0d, 0, &eax, &ebx, &ecx, &edx))
+return sizeof(FPR);

This doesn't compile for me (on stock Ubuntu 16.04, so using gcc/libstdc++ 
5.4.0), since my cpuid.h doesn't have __get_cpuid_count.  Do I just need to 
update/fix my toolset, or is that a supported one that we should change this 
code to accommodate?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59991



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


[Lldb-commits] [PATCH] D59991: [Linux/x86] Fix writing of non-gpr registers on newer processors

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

gcc-5.4 technically supported, so we can try to make things work for you. I'd 
be best if you can create a patch that will make things work for you (since 
it's kinda hard for me to test that). Or at least, can you paste the contents 
of your cpuid.h somewhere?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59991



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


[Lldb-commits] [lldb] r359004 - [Docs] Add 301 redirects for old URLs

2019-04-23 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Apr 23 08:57:47 2019
New Revision: 359004

URL: http://llvm.org/viewvc/llvm-project?rev=359004&view=rev
Log:
[Docs] Add 301 redirects for old URLs

Added:
lldb/trunk/docs/.htaccess
Modified:
lldb/trunk/docs/conf.py

Added: lldb/trunk/docs/.htaccess
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/.htaccess?rev=359004&view=auto
==
--- lldb/trunk/docs/.htaccess (added)
+++ lldb/trunk/docs/.htaccess Tue Apr 23 08:57:47 2019
@@ -0,0 +1,7 @@
+Redirect 301 /lldb-gdb.html https://lldb.llvm.org/use/map.html
+Redirect 301 /tutorial.html https://lldb.llvm.org/use/tutorial.html
+Redirect 301 source.html https://lldb.llvm.org/resources/source.html
+Redirect 301 projects.html https://lldb.llvm.org/status/projects.html
+Redirect 301 goals.html https://lldb.llvm.org/status/goals.html
+Redirect 301 varformats.html https://lldb.llvm.org/use/variable.html
+Redirect 301 architecture/index.html 
https://lldb.llvm.org/use/architecture.html

Modified: lldb/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/conf.py?rev=359004&r1=359003&r2=359004&view=diff
==
--- lldb/trunk/docs/conf.py (original)
+++ lldb/trunk/docs/conf.py Tue Apr 23 08:57:47 2019
@@ -129,6 +129,7 @@ html_context = {
 ],
 }
 
+html_extra_path = ['.htaccess']
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.


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


[Lldb-commits] [lldb] r359005 - [Docs] Add missing leading slash

2019-04-23 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Apr 23 09:00:43 2019
New Revision: 359005

URL: http://llvm.org/viewvc/llvm-project?rev=359005&view=rev
Log:
[Docs] Add missing leading slash

Modified:
lldb/trunk/docs/.htaccess

Modified: lldb/trunk/docs/.htaccess
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/.htaccess?rev=359005&r1=359004&r2=359005&view=diff
==
--- lldb/trunk/docs/.htaccess (original)
+++ lldb/trunk/docs/.htaccess Tue Apr 23 09:00:43 2019
@@ -1,7 +1,7 @@
 Redirect 301 /lldb-gdb.html https://lldb.llvm.org/use/map.html
 Redirect 301 /tutorial.html https://lldb.llvm.org/use/tutorial.html
-Redirect 301 source.html https://lldb.llvm.org/resources/source.html
-Redirect 301 projects.html https://lldb.llvm.org/status/projects.html
-Redirect 301 goals.html https://lldb.llvm.org/status/goals.html
-Redirect 301 varformats.html https://lldb.llvm.org/use/variable.html
-Redirect 301 architecture/index.html 
https://lldb.llvm.org/use/architecture.html
+Redirect 301 /source.html https://lldb.llvm.org/resources/source.html
+Redirect 301 /projects.html https://lldb.llvm.org/status/projects.html
+Redirect 301 /goals.html https://lldb.llvm.org/status/goals.html
+Redirect 301 /varformats.html https://lldb.llvm.org/use/variable.html
+Redirect 301 /architecture/index.html 
https://lldb.llvm.org/use/architecture.html


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


[Lldb-commits] [PATCH] D59991: [Linux/x86] Fix writing of non-gpr registers on newer processors

2019-04-23 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet added a comment.

In D59991#1475694 , @labath wrote:

> gcc-5.4 technically supported, so we can try to make things work for you. I'd 
> be best if you can create a patch that will make things work for you (since 
> it's kinda hard for me to test that). Or at least, can you paste the contents 
> of your cpuid.h somewhere?


Ok.  I'd be happy to put a patch together... is there an existing pattern for 
this sort of thing that I should follow?  E.g. define a helper 
llvm::get_cpuid_count function somewhere, similar to STLExtras?  Or just define 
it in this file?  Looking at the implementation of __get_cpuid_count in libc++, 
it's pretty short, my instinct would be to just inline that logic into the 
callsite here... LMK if there's a preferred approach.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59991



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


[Lldb-commits] [PATCH] D59991: [Linux/x86] Fix writing of non-gpr registers on newer processors

2019-04-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D59991#1475709 , @JosephTremoulet 
wrote:

> In D59991#1475694 , @labath wrote:
>
> > gcc-5.4 technically supported, so we can try to make things work for you. 
> > I'd be best if you can create a patch that will make things work for you 
> > (since it's kinda hard for me to test that). Or at least, can you paste the 
> > contents of your cpuid.h somewhere?
>
>
> Ok.  I'd be happy to put a patch together... is there an existing pattern for 
> this sort of thing that I should follow?  E.g. define a helper 
> llvm::get_cpuid_count function somewhere, similar to STLExtras?  Or just 
> define it in this file?  Looking at the implementation of __get_cpuid_count 
> in libc++, it's pretty short, my instinct would be to just inline that logic 
> into the callsite here... LMK if there's a preferred approach.


You can just put create a helper function at the top of this file. (This is 
assuming that we actually need to define a helper function, and that it's not 
possible to tweak this code slightly so that it works on all cpuid.h versions 
-- hard to say without looking at what your cpuid.h looks like.)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59991



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


[Lldb-commits] [PATCH] D61003: PostfixExpression: move parser out of NativePDB internals

2019-04-23 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov accepted this revision.
aleksandr.urakov added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D61003



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


Re: [Lldb-commits] [lldb] r358918 - [EditLineTest] Not always TERM is available, e.g. on some bots.

2019-04-23 Thread Davide Italiano via lldb-commits
You're right, I thought this was fixing a problem, but it's not. I'm
going to revert this immediately.

On Tue, Apr 23, 2019 at 2:12 AM Pavel Labath via lldb-commits
 wrote:
>
> On 22/04/2019 22:27, Davide Italiano via lldb-commits wrote:
> > Author: davide
> > Date: Mon Apr 22 13:27:10 2019
> > New Revision: 358918
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=358918&view=rev
> > Log:
> > [EditLineTest] Not always TERM is available, e.g. on some bots.
> >
> > Modified:
> >  lldb/trunk/unittests/Editline/EditlineTest.cpp
> >
> > Modified: lldb/trunk/unittests/Editline/EditlineTest.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Editline/EditlineTest.cpp?rev=358918&r1=358917&r2=358918&view=diff
> > ==
> > --- lldb/trunk/unittests/Editline/EditlineTest.cpp (original)
> > +++ lldb/trunk/unittests/Editline/EditlineTest.cpp Mon Apr 22 13:27:10 2019
> > @@ -244,17 +244,19 @@ private:
> > EditlineAdapter _el_adapter;
> > std::shared_ptr _sp_output_thread;
> >
> > +protected:
> > +  bool _has_term = true;
> > +
> >   public:
> > void SetUp() {
> >   FileSystem::Initialize();
> >
> >   // We need a TERM set properly for editline to work as expected.
> > -setenv("TERM", "vt100", 1);
> > +if (setenv("TERM", "vt100", 1) != 0)
> > +  _has_term = false;
>
> I'm confused as to what is this trying to solve. Judging by the manpage
> (which also agrees with my intuition) the setenv call can only fail
> under two conditions:
> - "name (first arg) is NULL, points to a string of length 0, or contains
> an '=' character". This is clearly not the case here.
> - "Insufficient memory to add a new variable to the environment". While
> technically possible, I find that highly unlikely, as you'd run into a
> lot more problems if the system was so severely memory-constrained.
>
> I suspect this is only covering up some other problem. Can you elaborate
> on how you've arrived at this patch?
>
> pl
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r359011 - Revert "[EditLineTest] Not always TERM is available, e.g. on some bots."

2019-04-23 Thread Davide Italiano via lldb-commits
Author: davide
Date: Tue Apr 23 09:51:20 2019
New Revision: 359011

URL: http://llvm.org/viewvc/llvm-project?rev=359011&view=rev
Log:
Revert "[EditLineTest] Not always TERM is available, e.g. on some bots."

This was a speculative fix trying to placate some bots, but it's
ultimately just a bot configuration problem and not a code problem.

Modified:
lldb/trunk/unittests/Editline/EditlineTest.cpp

Modified: lldb/trunk/unittests/Editline/EditlineTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Editline/EditlineTest.cpp?rev=359011&r1=359010&r2=359011&view=diff
==
--- lldb/trunk/unittests/Editline/EditlineTest.cpp (original)
+++ lldb/trunk/unittests/Editline/EditlineTest.cpp Tue Apr 23 09:51:20 2019
@@ -244,19 +244,17 @@ private:
   EditlineAdapter _el_adapter;
   std::shared_ptr _sp_output_thread;
 
-protected:
-  bool _has_term = true;
-
 public:
   void SetUp() {
 FileSystem::Initialize();
 
 // We need a TERM set properly for editline to work as expected.
-if (setenv("TERM", "vt100", 1) != 0)
-  _has_term = false;
+setenv("TERM", "vt100", 1);
 
 // Validate the editline adapter.
 EXPECT_TRUE(_el_adapter.IsValid());
+if (!_el_adapter.IsValid())
+  return;
 
 // Dump output.
 _sp_output_thread =
@@ -275,10 +273,6 @@ public:
 };
 
 TEST_F(EditlineTestFixture, EditlineReceivesSingleLineText) {
-  // Skip if we don't have a TERM.
-  if (!_has_term)
-return;
-
   // Send it some text via our virtual keyboard.
   const std::string input_text("Hello, world");
   EXPECT_TRUE(GetEditlineAdapter().SendLine(input_text));
@@ -295,10 +289,6 @@ TEST_F(EditlineTestFixture, EditlineRece
 }
 
 TEST_F(EditlineTestFixture, EditlineReceivesMultiLineText) {
-  // Skip if we don't have a TERM.
-  if (!_has_term)
-return;
-
   // Send it some text via our virtual keyboard.
   std::vector input_lines;
   input_lines.push_back("int foo()");


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


[Lldb-commits] [lldb] r359016 - [Reproducers] Limit logging to calls that cross the API boundary.

2019-04-23 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Apr 23 10:44:40 2019
New Revision: 359016

URL: http://llvm.org/viewvc/llvm-project?rev=359016&view=rev
Log:
[Reproducers] Limit logging to calls that cross the API boundary.

We recently moved API logging into the instrumentation macros. This made
that logging is now consistent and abstracted behind a macro for every
API functions, independent of the reproducers. It also means we have a
lot more output. While this is a good thing, it also meant a lot more
noise in the log, from things that aren't always equally interesting,
such as the copy constructor for example.

To improve usability, we should increase the signal-to-noise ratio. I
propose to achieve this by only logging API functions that cross the API
boundary. This is a divergence of what we had before, where a select
number of functions were logged, irregardless of the API boundary, a
concept that was introduced for the reproducers. However, I believe this
is in line with the purpose of the API log.

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

Modified:
lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
lldb/trunk/source/Utility/ReproducerInstrumentation.cpp

Modified: lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h?rev=359016&r1=359015&r2=359016&view=diff
==
--- lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h (original)
+++ lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h Tue Apr 23 
10:44:40 2019
@@ -22,43 +22,44 @@
 
 template ::value, int>::type = 
0>
-inline void log_append(llvm::raw_string_ostream &ss, const T &t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
   ss << t;
 }
 
 template ::value,
   int>::type = 0>
-inline void log_append(llvm::raw_string_ostream &ss, const T &t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
   ss << &t;
 }
 
 template 
-inline void log_append(llvm::raw_string_ostream &ss, const T *t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) {
   ss << reinterpret_cast(t);
 }
 
 template <>
-inline void log_append(llvm::raw_string_ostream &ss, const char *t) {
+inline void stringify_append(llvm::raw_string_ostream &ss,
+   const char *t) {
   ss << t;
 }
 
 template 
-inline void log_helper(llvm::raw_string_ostream &ss, const Head &head) {
-  log_append(ss, head);
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) {
+  stringify_append(ss, head);
 }
 
 template 
-inline void log_helper(llvm::raw_string_ostream &ss, const Head &head,
-   const Tail &... tail) {
-  log_append(ss, head);
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head,
+ const Tail &... tail) {
+  stringify_append(ss, head);
   ss << ", ";
-  log_helper(ss, tail...);
+  stringify_helper(ss, tail...);
 }
 
-template  inline std::string log_args(const Ts &... ts) {
+template  inline std::string stringify_args(const Ts &... ts) {
   std::string buffer;
   llvm::raw_string_ostream ss(buffer);
-  log_helper(ss, ts...);
+  stringify_helper(ss, ts...);
   return ss.str();
 }
 
@@ -69,131 +70,111 @@ template  inline std::st
 
 #define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
\
   R.Register(&construct::doit, "", #Class, 
\
-  #Class, #Signature)
+#Class, #Signature)
 #define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) 
\
   R.Register(  
\
   &invoke::method<(&Class::Method)>::doit, 
\
   #Result, #Class, #Method, #Signature)
 #define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)   
\
-  R.Register(&invoke::method_const<(&Class::Method)>::doit, 
\
-   #Result, #Class, #Method, #Signature)
+  R.Register(&invoke::method_const<( 
\
+ &Class::Method)>::doit,   
\
+ #Result, #Class, #Method, #Signature)
 #define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)  
\
   R.Register(
\
   static_cast(&Class::Method), #Result, #Class,   
\
   #Method, #Signature)
 
 #define LLDB_RECORD_CONSTRUCTOR(Class, Signature, ...) 
\
-  LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "{0} ({1})", 
\
-   LLVM_PRETTY_FUNCTION, log_args(__VA_ARGS__));   
\
+  lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION,  
\
+stringify_args(__VA_ARGS__));  
\
   i

[Lldb-commits] [PATCH] D60984: [Reproducers] Limit logging to calls that cross the API boundary.

2019-04-23 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB359016: [Reproducers] Limit logging to calls that cross 
the API boundary. (authored by JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60984?vs=196139&id=196281#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60984

Files:
  include/lldb/Utility/ReproducerInstrumentation.h
  source/Utility/ReproducerInstrumentation.cpp

Index: source/Utility/ReproducerInstrumentation.cpp
===
--- source/Utility/ReproducerInstrumentation.cpp
+++ source/Utility/ReproducerInstrumentation.cpp
@@ -101,14 +101,16 @@
   return m_mapping[object];
 }
 
-Recorder::Recorder(Serializer &serializer, Registry ®istry,
-   llvm::StringRef pretty_func)
-: m_serializer(serializer), m_registry(registry),
-  m_pretty_func(pretty_func), m_local_boundary(false),
+Recorder::Recorder(llvm::StringRef pretty_func, std::string &&pretty_args)
+: m_serializer(nullptr), m_pretty_func(pretty_func),
+  m_pretty_args(pretty_args), m_local_boundary(false),
   m_result_recorded(true) {
   if (!g_global_boundary) {
 g_global_boundary = true;
 m_local_boundary = true;
+
+LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "{0} ({1})",
+ m_pretty_func, m_pretty_args);
   }
 }
 
@@ -117,13 +119,4 @@
   UpdateBoundary();
 }
 
-void Recorder::Log(unsigned id) {
-#ifndef LLDB_REPRO_INSTR_TRACE
-  LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "Recording {0}: {1}", id,
-   m_pretty_func);
-#else
-  llvm::errs() << "Recording " << id << ": " << m_pretty_func << "\n";
-#endif
-}
-
 bool lldb_private::repro::Recorder::g_global_boundary;
Index: include/lldb/Utility/ReproducerInstrumentation.h
===
--- include/lldb/Utility/ReproducerInstrumentation.h
+++ include/lldb/Utility/ReproducerInstrumentation.h
@@ -22,43 +22,44 @@
 
 template ::value, int>::type = 0>
-inline void log_append(llvm::raw_string_ostream &ss, const T &t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
   ss << t;
 }
 
 template ::value,
   int>::type = 0>
-inline void log_append(llvm::raw_string_ostream &ss, const T &t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
   ss << &t;
 }
 
 template 
-inline void log_append(llvm::raw_string_ostream &ss, const T *t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) {
   ss << reinterpret_cast(t);
 }
 
 template <>
-inline void log_append(llvm::raw_string_ostream &ss, const char *t) {
+inline void stringify_append(llvm::raw_string_ostream &ss,
+   const char *t) {
   ss << t;
 }
 
 template 
-inline void log_helper(llvm::raw_string_ostream &ss, const Head &head) {
-  log_append(ss, head);
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) {
+  stringify_append(ss, head);
 }
 
 template 
-inline void log_helper(llvm::raw_string_ostream &ss, const Head &head,
-   const Tail &... tail) {
-  log_append(ss, head);
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head,
+ const Tail &... tail) {
+  stringify_append(ss, head);
   ss << ", ";
-  log_helper(ss, tail...);
+  stringify_helper(ss, tail...);
 }
 
-template  inline std::string log_args(const Ts &... ts) {
+template  inline std::string stringify_args(const Ts &... ts) {
   std::string buffer;
   llvm::raw_string_ostream ss(buffer);
-  log_helper(ss, ts...);
+  stringify_helper(ss, ts...);
   return ss.str();
 }
 
@@ -69,131 +70,111 @@
 
 #define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)\
   R.Register(&construct::doit, "", #Class, \
-  #Class, #Signature)
+#Class, #Signature)
 #define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) \
   R.Register(  \
   &invoke::method<(&Class::Method)>::doit, \
   #Result, #Class, #Method, #Signature)
 #define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)   \
-  R.Register(&invoke::method_const<(&Class::Method)>::doit, \
-   #Result, #Class, #Method, #Signature)
+  R.Register(&invoke::method_const<( \
+ &Class::Method)>::doit,   \
+ #Result, #Class, #Method, #Signature)
 #define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)  \
   R.Register(\
   static_cast(&Class::Method), #Result, #Class,   \
   #Method, #Signature)
 
 #define LLDB_RECORD_CONSTRUCTOR(Cl

[Lldb-commits] [PATCH] D61000: Kill modify-python-lldb.py

2019-04-23 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Since this just changes how we fix up comments for the generated functions in 
lldb.py, I can't see any harm in removing it.  It is clearly showing you a 
C-view of the function, so char -> str doesn't seem terribly helpful to me.


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

https://reviews.llvm.org/D61000



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


[Lldb-commits] [PATCH] D61000: Kill modify-python-lldb.py

2019-04-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

Thanks for the diff! LGTM


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

https://reviews.llvm.org/D61000



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


[Lldb-commits] [PATCH] D60468: Lock accesses to OptionValueFileSpecList objects

2019-04-23 Thread Frederic Riss via Phabricator via lldb-commits
friss added a comment.

There were no objections to the patch, and it fixes a real crash seen in the 
field so I'm going to check it in.

There seems to be consensus that properties should be per-debugger, so I'll 
work on this when I get some spare cycles. Note that making that change won't 
prevent won't completely prevent concurrent accesses, so we might still want to 
investigate making all the properties thread-safe.


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

https://reviews.llvm.org/D60468



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


[Lldb-commits] [PATCH] D60468: Lock accesses to OptionValueFileSpecList objects

2019-04-23 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.

Fine to fix the current issue. We should think about building this into the 
base class eventually. We can always have multi-threaded access, so we will 
always need to protect modifying operations.


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

https://reviews.llvm.org/D60468



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


[Lldb-commits] [lldb] r359028 - Lock accesses to OptionValueFileSpecList objects

2019-04-23 Thread Frederic Riss via lldb-commits
Author: friss
Date: Tue Apr 23 13:17:04 2019
New Revision: 359028

URL: http://llvm.org/viewvc/llvm-project?rev=359028&view=rev
Log:
Lock accesses to OptionValueFileSpecList objects

Before a Debugger gets a Target, target settings are routed to a global set
of settings. Even without this, some part of the LLDB which exist independently
of the Debugger object (the Module cache, the Symbol vendors, ...) access
directly the global default store for those settings.

Of course, if you modify one of those global settings while they are being read,
bad things happen. We see this quite a bit with FileSpecList settings. In
particular, we see many cases where one debug session changes
target.exec-search-paths while another session starts up and it crashes when
one of those accesses invalid FileSpecs.

This patch addresses the specific FileSpecList issue by adding locking to
OptionValueFileSpecList and never returning by reference.

Reviewers: clayborg

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Interpreter/OptionValueFileSpecLIst.cpp

lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/TargetList.cpp
lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h?rev=359028&r1=359027&r2=359028&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionValueFileSpecList.h Tue Apr 23 
13:17:04 2019
@@ -9,6 +9,8 @@
 #ifndef liblldb_OptionValueFileSpecList_h_
 #define liblldb_OptionValueFileSpecList_h_
 
+#include 
+
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Interpreter/OptionValue.h"
 
@@ -49,13 +51,23 @@ public:
 
   // Subclass specific functions
 
-  FileSpecList &GetCurrentValue() { return m_current_value; }
+  FileSpecList GetCurrentValue() const {
+std::lock_guard lock(m_mutex);
+return m_current_value;
+  }
 
-  const FileSpecList &GetCurrentValue() const { return m_current_value; }
+  void SetCurrentValue(const FileSpecList &value) {
+std::lock_guard lock(m_mutex);
+m_current_value = value;
+  }
 
-  void SetCurrentValue(const FileSpecList &value) { m_current_value = value; }
+  void AppendCurrentValue(const FileSpec &value) {
+std::lock_guard lock(m_mutex);
+m_current_value.Append(value);
+  }
 
 protected:
+  mutable std::mutex m_mutex;
   FileSpecList m_current_value;
 };
 

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=359028&r1=359027&r2=359028&view=diff
==
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Apr 23 13:17:04 2019
@@ -119,11 +119,13 @@ public:
 
   PathMappingList &GetSourcePathMap() const;
 
-  FileSpecList &GetExecutableSearchPaths();
+  FileSpecList GetExecutableSearchPaths();
 
-  FileSpecList &GetDebugFileSearchPaths();
+  void AppendExecutableSearchPaths(const FileSpec&);
 
-  FileSpecList &GetClangModuleSearchPaths();
+  FileSpecList GetDebugFileSearchPaths();
+
+  FileSpecList GetClangModuleSearchPaths();
 
   bool GetEnableAutoImportClangModules() const;
 

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=359028&r1=359027&r2=359028&view=diff
==
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Tue Apr 23 13:17:04 2019
@@ -43,7 +43,7 @@ public:
   ///
   const RegularExpression *GetSymbolsToAvoidRegexp();
 
-  FileSpecList &GetLibrariesToAvoid() const;
+  FileSpecList GetLibrariesToAvoid() const;
 
   bool GetTraceEnabledState() const;
 

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=359028&r1=359027&r2=359028&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)

[Lldb-commits] [PATCH] D60468: Lock accesses to OptionValueFileSpecList objects

2019-04-23 Thread Frederic Riss via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB359028: Lock accesses to OptionValueFileSpecList objects 
(authored by friss, committed by ).
Herald added a subscriber: teemperor.
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D60468?vs=194352&id=196312#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60468

Files:
  include/lldb/Interpreter/OptionValueFileSpecList.h
  include/lldb/Target/Target.h
  include/lldb/Target/Thread.h
  source/Commands/CommandObjectTarget.cpp
  source/Interpreter/OptionValueFileSpecLIst.cpp
  source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Target/Target.cpp
  source/Target/TargetList.cpp
  source/Target/Thread.cpp

Index: include/lldb/Target/Thread.h
===
--- include/lldb/Target/Thread.h
+++ include/lldb/Target/Thread.h
@@ -43,7 +43,7 @@
   ///
   const RegularExpression *GetSymbolsToAvoidRegexp();
 
-  FileSpecList &GetLibrariesToAvoid() const;
+  FileSpecList GetLibrariesToAvoid() const;
 
   bool GetTraceEnabledState() const;
 
Index: include/lldb/Target/Target.h
===
--- include/lldb/Target/Target.h
+++ include/lldb/Target/Target.h
@@ -119,11 +119,13 @@
 
   PathMappingList &GetSourcePathMap() const;
 
-  FileSpecList &GetExecutableSearchPaths();
+  FileSpecList GetExecutableSearchPaths();
 
-  FileSpecList &GetDebugFileSearchPaths();
+  void AppendExecutableSearchPaths(const FileSpec&);
 
-  FileSpecList &GetClangModuleSearchPaths();
+  FileSpecList GetDebugFileSearchPaths();
+
+  FileSpecList GetClangModuleSearchPaths();
 
   bool GetEnableAutoImportClangModules() const;
 
Index: include/lldb/Interpreter/OptionValueFileSpecList.h
===
--- include/lldb/Interpreter/OptionValueFileSpecList.h
+++ include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -9,6 +9,8 @@
 #ifndef liblldb_OptionValueFileSpecList_h_
 #define liblldb_OptionValueFileSpecList_h_
 
+#include 
+
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Interpreter/OptionValue.h"
 
@@ -49,13 +51,23 @@
 
   // Subclass specific functions
 
-  FileSpecList &GetCurrentValue() { return m_current_value; }
+  FileSpecList GetCurrentValue() const {
+std::lock_guard lock(m_mutex);
+return m_current_value;
+  }
 
-  const FileSpecList &GetCurrentValue() const { return m_current_value; }
+  void SetCurrentValue(const FileSpecList &value) {
+std::lock_guard lock(m_mutex);
+m_current_value = value;
+  }
 
-  void SetCurrentValue(const FileSpecList &value) { m_current_value = value; }
+  void AppendCurrentValue(const FileSpec &value) {
+std::lock_guard lock(m_mutex);
+m_current_value.Append(value);
+  }
 
 protected:
+  mutable std::mutex m_mutex;
   FileSpecList m_current_value;
 };
 
Index: source/Target/TargetList.cpp
===
--- source/Target/TargetList.cpp
+++ source/Target/TargetList.cpp
@@ -422,7 +422,7 @@
 if (file.GetDirectory()) {
   FileSpec file_dir;
   file_dir.GetDirectory() = file.GetDirectory();
-  target_sp->GetExecutableSearchPaths().Append(file_dir);
+  target_sp->AppendExecutableSearchPaths(file_dir);
 }
 
 // Don't put the dummy target in the target list, it's held separately.
Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -138,9 +138,9 @@
   return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx);
 }
 
-FileSpecList &ThreadProperties::GetLibrariesToAvoid() const {
+FileSpecList ThreadProperties::GetLibrariesToAvoid() const {
   const uint32_t idx = ePropertyStepAvoidLibraries;
-  OptionValueFileSpecList *option_value =
+  const OptionValueFileSpecList *option_value =
   m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
   assert(option_value);
Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -1574,8 +1574,9 @@
   arch_spec.GetArchitectureName(),
   arch_spec.GetTriple().getTriple().c_str());
 ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
+FileSpecList search_paths = GetExecutableSearchPaths();
 Status error = ModuleList::GetSharedModule(module_spec, executable_sp,
-   

[Lldb-commits] [PATCH] D61036: [lldb] Use local definition of get_cpuid_count

2019-04-23 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This is needed for gcc/cstdlib++ 5.4.0, where __get_cpuid_count is not
defined in cpuid.h.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61036

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp


Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -27,6 +27,23 @@
 // Private namespace.
 
 namespace {
+// Newer toolchains define __get_cpuid_count in cpuid.h, but some
+// older-but-still-supported ones (e.g. gcc 5.4.0) don't, so we
+// define it locally here, following the definition in clang/lib/Headers.
+inline int get_cpuid_count (unsigned int __leaf,
+unsigned int __subleaf,
+unsigned int *__eax, unsigned int *__ebx,
+unsigned int *__ecx, unsigned int *__edx)
+{
+unsigned int __max_leaf = __get_cpuid_max(__leaf & 0x8000, 0);
+
+if (__max_leaf == 0 || __max_leaf < __leaf)
+return 0;
+
+__cpuid_count(__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
+return 1;
+}
+
 // x86 32-bit general purpose registers.
 const uint32_t g_gpr_regnums_i386[] = {
 lldb_eax_i386,  lldb_ebx_i386,lldb_ecx_i386, lldb_edx_i386,
@@ -269,7 +286,7 @@
 return sizeof(FPR);
 
   // Then fetch the maximum size of the area.
-  if (!__get_cpuid_count(0x0d, 0, &eax, &ebx, &ecx, &edx))
+  if (!get_cpuid_count(0x0d, 0, &eax, &ebx, &ecx, &edx))
 return sizeof(FPR);
   return std::max(ecx, sizeof(FPR));
 }


Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -27,6 +27,23 @@
 // Private namespace.
 
 namespace {
+// Newer toolchains define __get_cpuid_count in cpuid.h, but some
+// older-but-still-supported ones (e.g. gcc 5.4.0) don't, so we
+// define it locally here, following the definition in clang/lib/Headers.
+inline int get_cpuid_count (unsigned int __leaf,
+unsigned int __subleaf,
+unsigned int *__eax, unsigned int *__ebx,
+unsigned int *__ecx, unsigned int *__edx)
+{
+unsigned int __max_leaf = __get_cpuid_max(__leaf & 0x8000, 0);
+
+if (__max_leaf == 0 || __max_leaf < __leaf)
+return 0;
+
+__cpuid_count(__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
+return 1;
+}
+
 // x86 32-bit general purpose registers.
 const uint32_t g_gpr_regnums_i386[] = {
 lldb_eax_i386,  lldb_ebx_i386,lldb_ecx_i386, lldb_edx_i386,
@@ -269,7 +286,7 @@
 return sizeof(FPR);
 
   // Then fetch the maximum size of the area.
-  if (!__get_cpuid_count(0x0d, 0, &eax, &ebx, &ecx, &edx))
+  if (!get_cpuid_count(0x0d, 0, &eax, &ebx, &ecx, &edx))
 return sizeof(FPR);
   return std::max(ecx, sizeof(FPR));
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61036: [lldb] Use local definition of get_cpuid_count

2019-04-23 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet added a comment.

@labath, as discussed in D59991 , I went with 
a local copy of the function since I didn't see an obvious opportunity to tweak 
the calling code, but maybe I overlooked something.  My copy of cpuid.h matches 
https://github.com/gcc-mirror/gcc/blob/gcc-5-branch/gcc/config/i386/cpuid.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61036



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


[Lldb-commits] [PATCH] D60962: [NativePDB] Extend .pdb files search folders

2019-04-23 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

cc: Pavel Labath because I know he's been involved in conversations about how 
to find symbol files in general (PDB, split DWARF, Breakpad, etc.), especially 
when doing post-mortem debugging.

I believe there are complications when the debugger host is different than the 
target host, (e.g., post-mortem debugging a Windows minidump using LLDB on 
Linux).

I'm not concerned about the details of this patch but whether this approach is 
going to be compatible with the more general solution being discussed.  This is 
small enough that it's probably not a big deal if it's helpful for now, but I'm 
going to hold my LGTM until Pavel has a chance to weigh in.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60962



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


[Lldb-commits] [PATCH] D61044: Fix infinite recursion when calling C++ template functions

2019-04-23 Thread Frederic Riss via Phabricator via lldb-commits
friss created this revision.
friss added reviewers: shafik, clayborg, jingham.
Herald added subscribers: kristof.beyls, javed.absar, aprantl.

When we encounter a templated function in the debug information, we
were creating an AST that looked like this:

FunctionTemplateDecl 0x12980ab90 <>  foo

| -TemplateTypeParmDecl 0x12980aad0 <>  class depth 
0 index 0 T |
| -FunctionDecl 0x12980aa30 <>  foo 'int 
(int)' extern |
|   
| -TemplateArgument type 'int' |
| `-ParmVarDecl 0x12980a998 <>  t1 'int'
|
|

`-FunctionDecl 0x12980aa30 <>  foo 'int (int)' 
extern

  |-TemplateArgument type 'int'
  `-ParmVarDecl 0x12980a998 <>  t1 'int'

Note that the FunctionTemplateDecl has 2 children which are identical (as
in have the same address). This is not what Clang is doing:

FunctionTemplateDecl 0x7f89d206c6f8  line:2:5 
foo

| -TemplateTypeParmDecl 0x7f89d206c4a8  col:19 referenced 
typename depth 0 index 0 T |
| -FunctionDecl 0x7f89d206c660  line:2:5 foo 'int (T)'  
|
| `-ParmVarDecl 0x7f89d206c570  col:11 t1 'T'
|
|

`-FunctionDecl 0x7f89d206cb60  line:2:5 used foo 'int (int)'

  |-TemplateArgument type 'int'
  `-ParmVarDecl 0x7f89d206ca68  col:11 t1 'int':'int'

The 2 chidlren are different and actually repesent different things: the first
one is the unspecialized version and the second one is specialized. (Just 
looking
at the names shows another major difference which is that we create the parent
with a name of "foo" when it should be just "foo".)

The fact that we have those 2 identical children confuses the ClangImporter
and generates an infinite recursion (reported in https://llvm.org/pr41473).
We cannot create the unspecialized version as the debug information doesn't
contain a mapping from the template parameters to their use in the prototype.

This patch just creates 2 different FunctionDecls for those 2 children of the
FunctionTemplateDecl. This avoids the infinite recursion and allows us to
call functions. As the XFAILs in the added test show, we've still got issues
in our handling of templates. I believe they are mostly centered on the fact
that we create do not register "foo" as a template, but "foo". This is
a bigger change that will need changes to the debug information generation.
I believe this change makes sense on its own.


https://reviews.llvm.org/D61044

Files:
  packages/Python/lldbsuite/test/lang/cpp/template-function/Makefile
  
packages/Python/lldbsuite/test/lang/cpp/template-function/TestTemplateFunctions.py
  packages/Python/lldbsuite/test/lang/cpp/template-function/main.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1590,6 +1590,7 @@
 
   if (!type_handled) {
 clang::FunctionDecl *function_decl = nullptr;
+clang::FunctionDecl *template_function_decl = nullptr;
 
 if (abstract_origin_die_form.IsValid()) {
   DWARFDIE abs_die =
@@ -1617,10 +1618,14 @@
   if (has_template_params) {
 ClangASTContext::TemplateParameterInfos template_param_infos;
 ParseTemplateParameterInfos(die, template_param_infos);
+template_function_decl = m_ast.CreateFunctionDeclaration(
+ignore_containing_context ? m_ast.GetTranslationUnitDecl()
+  : containing_decl_ctx,
+type_name_cstr, clang_type, storage, is_inline);
 clang::FunctionTemplateDecl *func_template_decl =
 m_ast.CreateFunctionTemplateDecl(
-containing_decl_ctx, function_decl, type_name_cstr,
-template_param_infos);
+containing_decl_ctx, template_function_decl,
+type_name_cstr, template_param_infos);
 m_ast.CreateFunctionTemplateSpecializationInfo(
 function_decl, func_template_decl, template_param_infos);
   }
@@ -1630,10 +1635,15 @@
   if (function_decl) {
 LinkDeclContextToDIE(function_decl, die);
 
-if (!function_param_decls.empty())
+if (!function_param_decls.empty()) {
   m_ast.SetFunctionParameters(function_decl,
   &function_param_decls.front(),
   function_param_decls.size());
+  if (template_function_decl)
+m_ast.SetFunctionParameters(template_function_decl,
+&function_param_decls.

[Lldb-commits] [PATCH] D61003: PostfixExpression: move parser out of NativePDB internals

2019-04-23 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.

Nice.  Thanks for adding the test, too!


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

https://reviews.llvm.org/D61003



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


Re: [Lldb-commits] [PATCH] D61044: Fix infinite recursion when calling C++ template functions

2019-04-23 Thread Frédéric Riss via lldb-commits


> On Apr 23, 2019, at 3:48 PM, Frederic Riss via Phabricator 
>  wrote:
> 
> friss created this revision.
> friss added reviewers: shafik, clayborg, jingham.
> Herald added subscribers: kristof.beyls, javed.absar, aprantl.
> 
> When we encounter a templated function in the debug information, we
> were creating an AST that looked like this:
> 
> FunctionTemplateDecl 0x12980ab90 <>  foo
> 
> | -TemplateTypeParmDecl 0x12980aad0 <>  class 
> depth 0 index 0 T |
> | -FunctionDecl 0x12980aa30 <>  foo 'int 
> (int)' extern |
> | 
>   | -TemplateArgument type 'int' |
> | `-ParmVarDecl 0x12980a998 <>  t1 'int'  
>   |
> |
> 
> `-FunctionDecl 0x12980aa30 <>  foo 'int 
> (int)' extern
> 
>  |-TemplateArgument type 'int'
>  `-ParmVarDecl 0x12980a998 <>  t1 'int'
> 
> Note that the FunctionTemplateDecl has 2 children which are identical (as
> in have the same address). This is not what Clang is doing:
> 
> FunctionTemplateDecl 0x7f89d206c6f8  
> line:2:5 foo
> 
> | -TemplateTypeParmDecl 0x7f89d206c4a8  col:19 referenced 
> typename depth 0 index 0 T |
> | -FunctionDecl 0x7f89d206c660  line:2:5 foo 'int (T)'
>   |
> | `-ParmVarDecl 0x7f89d206c570  col:11 t1 'T'  
>   |
> |
> 
> `-FunctionDecl 0x7f89d206cb60  line:2:5 used foo 'int 
> (int)'
> 
>  |-TemplateArgument type 'int'
>  `-ParmVarDecl 0x7f89d206ca68  col:11 t1 'int':’int'

I don’t know what Phabricator did to my commit message. Here it is (hopefully) 
un-mangled:

Fix infinite recursion when calling C++ template functions

Summary:
When we encounter a templated function in the debug information, we
were creating an AST that looked like this:

FunctionTemplateDecl 0x12980ab90 <>  foo
|-TemplateTypeParmDecl 0x12980aad0 <>  class 
depth 0 index 0 T
|-FunctionDecl 0x12980aa30 <>  foo 'int 
(int)' extern
| |-TemplateArgument type 'int'
| `-ParmVarDecl 0x12980a998 <>  t1 'int'
`-FunctionDecl 0x12980aa30 <>  foo 'int 
(int)' extern
  |-TemplateArgument type 'int'
  `-ParmVarDecl 0x12980a998 <>  t1 'int'

Note that the FunctionTemplateDecl has 2 children which are identical (as
in have the same address). This is not what Clang is doing:

FunctionTemplateDecl 0x7f89d206c6f8  
line:2:5 foo
|-TemplateTypeParmDecl 0x7f89d206c4a8  col:19 referenced 
typename depth 0 index 0 T
|-FunctionDecl 0x7f89d206c660  line:2:5 foo 'int (T)'
| `-ParmVarDecl 0x7f89d206c570  col:11 t1 'T'
`-FunctionDecl 0x7f89d206cb60  line:2:5 used foo 'int 
(int)'
  |-TemplateArgument type 'int'
  `-ParmVarDecl 0x7f89d206ca68  col:11 t1 'int':'int'

The 2 chidlren are different and actually repesent different things: the 
first
one is the unspecialized version and the second one is specialized. (Just 
looking
at the names shows another major difference which is that we create the 
parent
with a name of "foo" when it should be just "foo".)

The fact that we have those 2 identical children confuses the ClangImporter
and generates an infinite recursion (reported in https://llvm.org/pr41473).
We cannot create the unspecialized version as the debug information doesn't
contain a mapping from the template parameters to their use in the 
prototype.

This patch just creates 2 different FunctionDecls for those 2 children of 
the
FunctionTemplateDecl. This avoids the infinite recursion and allows us to
call functions. As the XFAILs in the added test show, we've still got issues
in our handling of templates. I believe they are mostly centered on the fact
that we create do not register "foo" as a template, but "foo". This is
a bigger change that will need changes to the debug information generation.
I believe this change makes sense on its own.

Reviewers: shafik, clayborg, jingham

Subscribers: aprantl, javed.absar, kristof.beyls, lldb-commits

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

Fred

> The 2 chidlren are different and actually repesent different things: the first
> one is the unspecialized version and the second one is specialized. (Just 
> looking
> at the names shows another major difference which is that we create the parent
> with a name of "foo" when it should be just "foo".)
> 
> The fact that we have those 2 identical children confuses the ClangImporter
> and generates an infinite recursion (reported in https://llvm.org/pr41473).
> We cannot create the unspecialized version as the debug information doesn't
> contain a mapping from the template parameters to their use in the prototype.
> 
> This patch just creates 2 different FunctionDecls for those 2 children of the
> FunctionTemplateDecl. This avoids the infinite recursion and allows us to
> call functions. As the XFAILs in the added test show, we've still got issue

Re: [Lldb-commits] [PATCH] D61044: Fix infinite recursion when calling C++ template functions

2019-04-23 Thread Adrian Prantl via lldb-commits


> On Apr 23, 2019, at 3:51 PM, Frédéric Riss  wrote:
> 
> 
> 
> I don’t know what Phabricator did to my commit message. Here it is 
> (hopefully) un-mangled:

I fixed it by ```-quoting the verbatim blocks.

-- adrian

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


[Lldb-commits] [lldb] r359052 - [Docs] Fix link to C++ docs

2019-04-23 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Apr 23 17:10:23 2019
New Revision: 359052

URL: http://llvm.org/viewvc/llvm-project?rev=359052&view=rev
Log:
[Docs] Fix link to C++ docs

... and add a redirect for the old URL.

Modified:
lldb/trunk/docs/.htaccess
lldb/trunk/docs/index.rst

Modified: lldb/trunk/docs/.htaccess
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/.htaccess?rev=359052&r1=359051&r2=359052&view=diff
==
--- lldb/trunk/docs/.htaccess (original)
+++ lldb/trunk/docs/.htaccess Tue Apr 23 17:10:23 2019
@@ -5,3 +5,5 @@ Redirect 301 /projects.html https://lldb
 Redirect 301 /goals.html https://lldb.llvm.org/status/goals.html
 Redirect 301 /varformats.html https://lldb.llvm.org/use/variable.html
 Redirect 301 /architecture/index.html 
https://lldb.llvm.org/use/architecture.html
+Redirect 301 /architecture/index.html 
https://lldb.llvm.org/use/architecture.html
+Redirect 301 /cpp_reference/html/index.html 
https://lldb.llvm.org/cpp_reference/index.html

Modified: lldb/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/index.rst?rev=359052&r1=359051&r2=359052&view=diff
==
--- lldb/trunk/docs/index.rst (original)
+++ lldb/trunk/docs/index.rst Tue Apr 23 17:10:23 2019
@@ -61,9 +61,8 @@ Resources
 API Documentation
 =
 
+* `C++ API Documentation `_
 * `Python API Documentation 
`_
-* `C++ API Documentation 
`_
-
 
 Indices and tables
 ==


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


[Lldb-commits] [lldb] r359062 - [Docs] Update the CI page

2019-04-23 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Apr 23 18:48:43 2019
New Revision: 359062

URL: http://llvm.org/viewvc/llvm-project?rev=359062&view=rev
Log:
[Docs] Update the CI page

 - Add the Sphinx bot
 - Add a little more info

Modified:
lldb/trunk/docs/resources/bots.rst

Modified: lldb/trunk/docs/resources/bots.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/resources/bots.rst?rev=359062&r1=359061&r2=359062&view=diff
==
--- lldb/trunk/docs/resources/bots.rst (original)
+++ lldb/trunk/docs/resources/bots.rst Tue Apr 23 18:48:43 2019
@@ -4,17 +4,34 @@ Continuous Integration
 Buildbot
 
 
+LLVM Buildbot is the place where Volunteers provide build machines to work as
+build slaves. Everyone can `add a buildbot for LLDB
+`_.
+
+
 * `lldb-amd64-ninja-freebsd11 
`_
 * `lldb-x64-windows-ninja 
`_
 * `lldb-x86_64-debian `_
 * `lldb-x86_64-fedora `_
 
+Documentation
+-
+
+The documentation bot validates that the website builds correctly with Sphinx.
+It does not generate the website itself, which happens on a separate server.
+
+* `lldb-sphinx-docs `_
+
 GreenDragon
 ---
 
+GreenDragon builds and tests LLDB on macOS. It has a `dedicated tab
+`_ for LLDB.
+
 * `lldb-cmake `_
 * `lldb-cmake-matrix 
`_
 * `lldb-cmake-python3 
`_
 * `lldb-cmake-standalone 
`_
 * `lldb-sanitized 
`_
 * `lldb-xcode `_
+


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


[Lldb-commits] [lldb] r359061 - [Docs] Move external links up

2019-04-23 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Apr 23 18:48:40 2019
New Revision: 359061

URL: http://llvm.org/viewvc/llvm-project?rev=359061&view=rev
Log:
[Docs] Move external links up

With a duplicate link removed and the API reference moved up, the page
didn't make much sense anymore.

Removed:
lldb/trunk/docs/resources/external.rst
Modified:
lldb/trunk/docs/index.rst

Modified: lldb/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/index.rst?rev=359061&r1=359060&r2=359061&view=diff
==
--- lldb/trunk/docs/index.rst (original)
+++ lldb/trunk/docs/index.rst Tue Apr 23 18:48:40 2019
@@ -56,7 +56,6 @@ Resources
resources/test
resources/bots
resources/sbapi
-   resources/external
 
 API Documentation
 =
@@ -64,8 +63,9 @@ API Documentation
 * `C++ API Documentation `_
 * `Python API Documentation 
`_
 
-Indices and tables
-==
+External Links
+==
 
-* :ref:`genindex`
-* :ref:`search`
+* `Source Code `_
+* `Code Reviews `_
+* `Bug Reports `_

Removed: lldb/trunk/docs/resources/external.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/resources/external.rst?rev=359060&view=auto
==
--- lldb/trunk/docs/resources/external.rst (original)
+++ lldb/trunk/docs/resources/external.rst (removed)
@@ -1,13 +0,0 @@
-External Resources
-==
-
-Bugs
-
-
-* `Bug Reports `_
-
-Source
---
-
-* `Browse SVN `_
-* `Browse ViewVNC `_


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


[Lldb-commits] [lldb] r359063 - [Docs] Add more redirects

2019-04-23 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Tue Apr 23 18:58:17 2019
New Revision: 359063

URL: http://llvm.org/viewvc/llvm-project?rev=359063&view=rev
Log:
[Docs] Add more redirects

Found two more broken links.

Modified:
lldb/trunk/docs/.htaccess

Modified: lldb/trunk/docs/.htaccess
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/.htaccess?rev=359063&r1=359062&r2=359063&view=diff
==
--- lldb/trunk/docs/.htaccess (original)
+++ lldb/trunk/docs/.htaccess Tue Apr 23 18:58:17 2019
@@ -5,5 +5,6 @@ Redirect 301 /projects.html https://lldb
 Redirect 301 /goals.html https://lldb.llvm.org/status/goals.html
 Redirect 301 /varformats.html https://lldb.llvm.org/use/variable.html
 Redirect 301 /architecture/index.html 
https://lldb.llvm.org/use/architecture.html
-Redirect 301 /architecture/index.html 
https://lldb.llvm.org/use/architecture.html
+Redirect 301 /features.html https://lldb.llvm.org/status/features.html
+Redirect 301 /formats.html https://lldb.llvm.org/use/formatting.html
 Redirect 301 /cpp_reference/html/index.html 
https://lldb.llvm.org/cpp_reference/index.html


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