[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()

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

Thanks. I have a couple of small comments, but I think this is basically done.




Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:43
 
+namespace {
+using namespace llvm;

llvm style is to only use the anonymous namespaces for class declarations (and 
use the `static` keyword for functions). What you've done here is particularly 
confusing, as you've combined this with `using namespace llvm`, which gives off 
the impression that the `using` declaration is somehow local to the anonymous 
namespace (which it isn't).

In this case, I'd probably just get rid of the anonymous namespace and move 
everything (the struct definition and using declarations, if you really want 
it) into the now-static GetCoffUUID function.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:45
+using namespace llvm;
+typedef struct CVInfoPdb70 {
+  // 16-byte GUID

`typedef struct` is very C-like. Just use plain `struct`.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:117
 
-  if (ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
-DataExtractor data;

You should keep the MagicBytesMatch call (if you want to llvm-ize it, you could 
replace that with a call to `llvm::identify_magic`).

All of the GetModuleSpecifications will be called each time lldb does anything 
with an object file (any object file), and the idea is to avoid reading the 
whole file until we are reasonably certain that it is the file we are looking 
for. That's the reason this function gets the initial bytes of the file in the 
data_sp member. This way, all of the object file plugins can quickly inspect 
that data to see if they care about the file, and only one of them will attempt 
an actual parse.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:891-892
+
+  if (!CreateBinary())
+return UUID();
+  auto COFFObj =

I don't think this is necessary as `CreateInstance` will refuse to return the 
ObjectFile instance if the creation of the coff binary object failed. (You 
could theoretically assert that the binary is really there if you want extra 
security).


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

https://reviews.llvm.org/D56229



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


[Lldb-commits] [PATCH] D60153: Re-enable most lldb-vscode tests on Linux.

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

In D60153#1469397 , @jgorbe wrote:

> Thanks! Please let me know if it happens again and I'll try my best to debug 
> it.


It is still happening (e.g. 
http://lab.llvm.org:8014/builders/lldb-x86_64-debian/builds/141), but I already 
have a fix for that: https://reviews.llvm.org/D60608>>.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60153



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


[Lldb-commits] [PATCH] D60737: [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

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

Thanks for adding the test.

I guess I've touched this bit when I was working on the dwarf5 index thingy, 
but all my memory of this function has already been swapped out (and I'm not 
sure I ever fully understood all the nuances of how it was supposed to work).

So yeah, I think this is fine but I don't feel very qualified to make that 
claim.




Comment at: 
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py:20
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@expectedFailureAll(oslist=["linux"], archs=["aarch64"], 
bugnumber="llvm.org/pr37301")
+def test(self):

I don't think this bug applies here, as we're inspecting a running process, 
though we don't have any arm64 bots running ATM to verify that. I'd just remove 
this XFAIL.


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

https://reviews.llvm.org/D60737



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


[Lldb-commits] [PATCH] D60817: [NativePDB] Add anonymous namespaces support

2019-04-17 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: zturner, asmith, labath, stella.stamenova.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor, aprantl.

This patch adds anonymous namespaces support to the native PDB plugin.

I had to reference from the main function variables of the types that are 
inside of the anonymous namespace to include them in debug info. Without the 
references they are not included. I think it's because they are static, then 
are visible only in the current translation unit, so they are not needed 
without any references to them.

There is also the problem case with variables of types that are nested in 
template structs. For now I've left FIXME in the test because this case is not 
related to the change.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D60817

Files:
  lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
  lit/SymbolFile/NativePDB/ast-types.cpp
  lit/SymbolFile/NativePDB/typedefs.cpp
  lit/SymbolFile/PDB/ast-restore.test
  source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp

Index: source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
===
--- source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -205,6 +205,10 @@
   return std::move(child);
 }
 
+static bool IsAnonymousNamespaceName(llvm::StringRef name) {
+  return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
+}
+
 PdbAstBuilder::PdbAstBuilder(ObjectFile &obj, PdbIndex &index)
 : m_index(index), m_clang(GetClangASTContext(obj)) {
   BuildParentMap();
@@ -256,7 +260,7 @@
 for (llvm::ms_demangle::Node *scope : scopes) {
   auto *nii = static_cast(scope);
   std::string str = nii->toString();
-  context = m_clang.GetUniqueNamespaceDeclaration(str.c_str(), context);
+  context = GetOrCreateNamespaceDecl(str.c_str(), *context);
 }
 return {context, uname};
   }
@@ -525,7 +529,7 @@
   // If that fails, treat it as a series of namespaces.
   for (const MSVCUndecoratedNameSpecifier &spec : specs) {
 std::string ns_name = spec.GetBaseName().str();
-context = m_clang.GetUniqueNamespaceDeclaration(ns_name.c_str(), context);
+context = GetOrCreateNamespaceDecl(ns_name.c_str(), *context);
   }
   return {context, uname};
 }
@@ -568,7 +572,7 @@
   clang::DeclContext *context = &GetTranslationUnitDecl();
   while (!name_components.empty()) {
 std::string ns = name_components.front()->toString();
-context = m_clang.GetUniqueNamespaceDeclaration(ns.c_str(), context);
+context = GetOrCreateNamespaceDecl(ns.c_str(), *context);
 name_components = name_components.drop_front();
   }
   return context;
@@ -807,7 +811,8 @@
 clang::NamespaceDecl *
 PdbAstBuilder::GetOrCreateNamespaceDecl(llvm::StringRef name,
 clang::DeclContext &context) {
-  return m_clang.GetUniqueNamespaceDeclaration(name.str().c_str(), &context);
+  return m_clang.GetUniqueNamespaceDeclaration(
+  IsAnonymousNamespaceName(name) ? nullptr : name.str().c_str(), &context);
 }
 
 clang::BlockDecl *
Index: lit/SymbolFile/PDB/ast-restore.test
===
--- lit/SymbolFile/PDB/ast-restore.test
+++ lit/SymbolFile/PDB/ast-restore.test
@@ -1,6 +1,7 @@
 REQUIRES: system-windows, msvc
 RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/AstRestoreTest.cpp
-RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=GLOBAL %s
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=BASE %s
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=CLASS %s
Index: lit/SymbolFile/NativePDB/typedefs.cpp
===
--- lit/SymbolFile/NativePDB/typedefs.cpp
+++ lit/SymbolFile/NativePDB/typedefs.cpp
@@ -54,7 +54,7 @@
 }
 
 
-// CHECK:  namespace `anonymous namespace' {
+// CHECK:  namespace  {
 // CHECK-NEXT: typedef bool AnonNamespaceTypedef;
 // CHECK-NEXT: }
 // CHECK-NEXT: typedef unsigned long ULongArrayTypedef[10];
Index: lit/SymbolFile/NativePDB/ast-types.cpp
===
--- lit/SymbolFile/NativePDB/ast-types.cpp
+++ lit/SymbolFile/NativePDB/ast-types.cpp
@@ -72,15 +72,18 @@
 A::C<0> AC0;
 A::C<-1> ACNeg1;
 
+// FIXME: The type `D` is located now at the level of the translation unit.
+// FIXME: Should be located in the namespace `A`, in the struct `C<1>`.
+A::C<1>::D AC1D;
+
 A::C<0>::D AC0D;
 A::C<-1>::D ACNeg1D;
 A::D AD;
 A::D::E ADE;
 
-// FIXME: A

[Lldb-commits] [PATCH] D60519: [Windows] Dump more information about access violation exception

2019-04-17 Thread Leonid Mashinskiy via Phabricator via lldb-commits
leonid.mashinskiy updated this revision to Diff 195549.
leonid.mashinskiy added a comment.

- increased buffer size in GetStopDescription call to fit new message


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60519

Files:
  lit/Process/Windows/exception_access_violation.cpp
  packages/Python/lldbsuite/test/lldbutil.py
  source/Plugins/Process/Windows/Common/ExceptionRecord.h
  source/Plugins/Process/Windows/Common/ProcessWindows.cpp

Index: source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -474,6 +474,74 @@
 RefreshStateAfterStop();
 }
 
+static void
+DumpAdditionalExceptionInformation(llvm::raw_ostream &stream,
+   const ExceptionRecordSP &exception) {
+  // Decode additional exception information for specific exception types based
+  // on
+  // https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_exception_record
+
+  const int addr_min_width = 2 + 8; // "0x" + 4 address bytes
+
+  const std::vector &args = exception->GetExceptionArguments();
+  switch (exception->GetExceptionCode()) {
+  case EXCEPTION_ACCESS_VIOLATION: {
+if (args.size() < 2)
+  break;
+
+stream << ": ";
+const int access_violation_code = args[0];
+const lldb::addr_t access_violation_address = args[1];
+switch (access_violation_code) {
+case 0:
+  stream << "Access violation reading";
+  break;
+case 1:
+  stream << "Access violation writing";
+  break;
+case 8:
+  stream << "User-mode data execution prevention (DEP) violation at";
+  break;
+default:
+  stream << "Unknown access violation (code " << access_violation_code
+ << ") at";
+  break;
+}
+stream << " location "
+   << llvm::format_hex(access_violation_address, addr_min_width);
+break;
+  }
+  case EXCEPTION_IN_PAGE_ERROR: {
+if (args.size() < 3)
+  break;
+
+stream << ": ";
+const int page_load_error_code = args[0];
+const lldb::addr_t page_load_error_address = args[1];
+const DWORD underlying_code = args[2];
+switch (page_load_error_code) {
+case 0:
+  stream << "In page error reading";
+  break;
+case 1:
+  stream << "In page error writing";
+  break;
+case 8:
+  stream << "User-mode data execution prevention (DEP) violation at";
+  break;
+default:
+  stream << "Unknown page loading error (code " << page_load_error_code
+ << ") at";
+  break;
+}
+stream << " location "
+   << llvm::format_hex(page_load_error_address, addr_min_width)
+   << " (status code " << llvm::format_hex(underlying_code, 8) << ")";
+break;
+  }
+  }
+}
+
 void ProcessWindows::RefreshStateAfterStop() {
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION);
   llvm::sys::ScopedLock lock(m_mutex);
@@ -573,6 +641,8 @@
 << llvm::format_hex(active_exception->GetExceptionCode(), 8)
 << " encountered at address "
 << llvm::format_hex(active_exception->GetExceptionAddress(), 8);
+DumpAdditionalExceptionInformation(desc_stream, active_exception);
+
 stop_info = StopInfo::CreateStopReasonWithException(
 *stop_thread, desc_stream.str().c_str());
 stop_thread->SetStopInfo(stop_info);
Index: source/Plugins/Process/Windows/Common/ExceptionRecord.h
===
--- source/Plugins/Process/Windows/Common/ExceptionRecord.h
+++ source/Plugins/Process/Windows/Common/ExceptionRecord.h
@@ -64,6 +64,8 @@
 
   lldb::tid_t GetThreadID() const { return m_thread_id; }
 
+  const std::vector& GetExceptionArguments() const { return m_arguments; }
+
 private:
   DWORD m_code;
   bool m_continuable;
Index: packages/Python/lldbsuite/test/lldbutil.py
===
--- packages/Python/lldbsuite/test/lldbutil.py
+++ packages/Python/lldbsuite/test/lldbutil.py
@@ -737,7 +737,7 @@
 return thread.GetStopReason() == lldb.eStopReasonSignal and thread.GetStopReasonDataAtIndex(
 0) == thread.GetProcess().GetUnixSignals().GetSignalNumberFromName("SIGSEGV")
 elif test.getPlatform() == "windows":
-return "Exception 0xc005" in thread.GetStopDescription(100)
+return "Exception 0xc005" in thread.GetStopDescription(200)
 else:
 return "invalid address" in thread.GetStopDescription(100)
 
Index: lit/Process/Windows/exception_access_violation.cpp
===
--- /dev/null
+++ lit/Process/Windows/exception_access_violation.cpp
@@ -0,0 +1,37 @@
+// clang-format off
+
+// REQUIRES: system-windows
+// RUN: %build --comp

[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()

2019-04-17 Thread Hui Huang via Phabricator via lldb-commits
Hui added inline comments.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:891-892
+
+  if (!CreateBinary())
+return UUID();
+  auto COFFObj =

labath wrote:
> I don't think this is necessary as `CreateInstance` will refuse to return the 
> ObjectFile instance if the creation of the coff binary object failed. (You 
> could theoretically assert that the binary is really there if you want extra 
> security).
There is no cached binary for memory instance (by CreateMemoryInstance). Is 
there any chance that any JIT-ed codes will call module or UUID related API? 


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

https://reviews.llvm.org/D56229



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


[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()

2019-04-17 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:891-892
+
+  if (!CreateBinary())
+return UUID();
+  auto COFFObj =

Hui wrote:
> labath wrote:
> > I don't think this is necessary as `CreateInstance` will refuse to return 
> > the ObjectFile instance if the creation of the coff binary object failed. 
> > (You could theoretically assert that the binary is really there if you want 
> > extra security).
> There is no cached binary for memory instance (by CreateMemoryInstance). Is 
> there any chance that any JIT-ed codes will call module or UUID related API? 
Ah, interesting. Yes, if you manage to create a memory instance of 
ObjectFilePECOFF, then there's a very high chance that someone will call 
GetUUID on it. I strongly doubt that anyone is creating memory instances, or 
that they even work in the first place, but I suppose we can leave this check 
just in case.


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

https://reviews.llvm.org/D56229



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


[Lldb-commits] [PATCH] D60667: Allow direct comparison of ConstString against StringRef

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

In D60667#1467970 , @teemperor wrote:

> In D60667#1467387 , @amccarth wrote:
>
> > I, too, have some concern that this could have unintended side effects.  To 
> > make the temporary `StringRef`s from the zero-terminated strings requires a 
> > `strlen` call each time.  So we're making two passes over a string each 
> > time (once to measure and once to compare).  Granted, these are mostly very 
> > short.
>
>
> I think I'm not understanding something here. There is one `strlen` call to 
> make the StringRef from the literal, but I don't see why we need a second one 
> to compare (as StringRef and ConstString both store the string length and 
> don't recompute it when comparing). Simple godbolt test case here: 
> https://godbolt.org/z/9X1RRt So both the old and new version both require one 
> `strlen` call from what I can see (which is anyway optimized out for 
> comparing against literals).


I didn't mean to imply that `strlen` is called twice.  My point was that there 
are two linear passes over the string literal:  The first is the call to 
`strlen` to make the StringRef, and the second is the actual string comparison.

> 
> 
>> I'd love to see the static const variables for the short constant strings, 
>> just to weigh readability hit.
> 
> I can maybe make a new revision to show this, but I hope it's obvious from 
> looking at the code that I changed in this revision. Also there are the 
> problems/style difficulties that hopefully don't need a full revision to see:
> 
> 1. We preferable want to have variables with the same name as the string 
> content, but often the strings contain reserved words or words that don't 
> translate into our lower_case_code_style so that's not possible. E.g. `var == 
> this_` is not really as readable as `var == "this"` (and it looks like a 
> typo). Same with stuff like `if (arg_type.GetTypeName() == "bool")` vs `if 
> (arg_type.GetTypeName() == bool_)` or `image_infos[i].segments[k].name == 
> ConstString("__TEXT"))` vs `image_infos[i].segments[k].name == text)`.
> 2. We get a bunch of local variables that just bloat the code: ``` if 
> (descriptor->IsCFType()) { ConstString type_name(valobj.GetTypeName()); if 
> (type_name == "__CFMutableBitVector" || type_name == "__CFBitVector" || 
> type_name == "CFMutableBitVectorRef" || type_name == "CFBitVectorRef") {
> 
> 
> 
>   if (valobj.IsPointerType())
> is_type_ok = true;
> }
>   }
> 
>   becomes this
> 
> 
>   if (descriptor->IsCFType()) {
> ConstString type_name(valobj.GetTypeName());
> static const ConstString cf_mutable_bit_vector("__CFMutableBitVector"),
>  cf_bit_vector("__CFBitVector"),
>  
> cf_mutable_bit_vector_ref("CFMutableBitVectorRef"),
>  cf_bit_vector_ref("CFBitVectorRef")
> if (type_name == cf_mutable_bit_vector || type_name == cf_bit_vector ||
> type_name == cf_mutable_bit_vector_ref || type_name == 
> cf_bit_vector_ref) {
>   if (valobj.IsPointerType())
> is_type_ok = true;
> }
>   }
> 
>   3. Code becomes much harder to grep. E.g. if I want to check for the 
> location where we filter the `this` variable from the local variables, I can 
> currently do `git grep "\"this\"" | grep ==` and directly see where we do the 
> comparison. But with local variables I have to do some funky grep with 
> context filtering. In general grepping for these string literals without a 
> few lines of context will be pointless with ConstString variables for 
> literals.

Fair enough.  Thanks for the details.


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

https://reviews.llvm.org/D60667



___
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-17 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jasonmolenda, clayborg.

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.


https://reviews.llvm.org/D60829

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

Index: source/Symbol/FuncUnwinders.cpp
===
--- source/Symbol/FuncUnwinders.cpp
+++ source/Symbol/FuncUnwinders.cpp
@@ -51,24 +51,22 @@
 
 FuncUnwinders::~FuncUnwinders() {}
 
-UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite(Target &target,
-int current_offset) {
+UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite(Target &target) {
   std::lock_guard guard(m_mutex);
 
-  if (UnwindPlanSP plan_sp = GetEHFrameUnwindPlan(target, current_offset))
+  if (UnwindPlanSP plan_sp = GetEHFrameUnwindPlan(target))
 return plan_sp;
-  if (UnwindPlanSP plan_sp = GetDebugFrameUnwindPlan(target, current_offset))
+  if (UnwindPlanSP plan_sp = GetDebugFrameUnwindPlan(target))
 return plan_sp;
-  if (UnwindPlanSP plan_sp = GetCompactUnwindUnwindPlan(target, current_offset))
+  if (UnwindPlanSP plan_sp = GetCompactUnwindUnwindPlan(target))
 return plan_sp;
-  if (UnwindPlanSP plan_sp = GetArmUnwindUnwindPlan(target, current_offset))
+  if (UnwindPlanSP plan_sp = GetArmUnwindUnwindPlan(target))
 return plan_sp;
 
   return nullptr;
 }
 
-UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target,
-   int current_offset) {
+UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target) {
   std::lock_guard guard(m_mutex);
   if (m_unwind_plan_compact_unwind.size() > 0)
 return m_unwind_plan_compact_unwind[0]; // FIXME support multiple compact
@@ -79,8 +77,6 @@
   m_tried_unwind_plan_compact_unwind = true;
   if (m_range.GetBaseAddress().IsValid()) {
 Address current_pc(m_range.GetBaseAddress());
-if (current_offset != -1)
-  current_pc.SetOffset(current_pc.GetOffset() + current_offset);
 CompactUnwindInfo *compact_unwind = m_unwind_table.GetCompactUnwindInfo();
 if (compact_unwind) {
   UnwindPlanSP unwind_plan_sp(new UnwindPlan(lldb::eRegisterKindGeneric));
@@ -95,53 +91,43 @@
   return UnwindPlanSP();
 }
 
-UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target,
- int current_offset) {
+UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target) {
   std::lock_guard guard(m_mutex);
   if (m_unwind_plan_eh_frame_sp.get() || m_tried_unwind_plan_eh_frame)
 return m_unwind_plan_eh_frame_sp;
 
   m_tried_unwind_plan_eh_frame = true;
   if (m_range.GetBaseAddress().IsValid()) {
-Address current_pc(m_range.GetBaseAddress());
-if (current_offset != -1)
-  current_pc.SetOffset(current_pc.GetOffset() + current_offset);
 DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo();
 if (eh_frame) {
   m_unwind_plan_eh_frame_sp =
   std::make_shared(lldb::eRegisterKindGeneric

[Lldb-commits] [PATCH] D60737: [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

2019-04-17 Thread Kuba (Brecka) Mracek via Phabricator via lldb-commits
kubamracek updated this revision to Diff 195596.

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

https://reviews.llvm.org/D60737

Files:
  packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
  
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
  packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2036,6 +2036,7 @@
 
   llvm::StringRef basename;
   llvm::StringRef context;
+  bool name_is_mangled = (bool)Mangled(name);
 
   if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name.GetCString(),
   context, basename))
@@ -2085,7 +2086,8 @@
  &variables);
   while (pruned_idx < variables.GetSize()) {
 VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
-if (var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
+if (name_is_mangled ||
+var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
   ++pruned_idx;
 else
   variables.RemoveVariableAtIndex(pruned_idx);
Index: packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
===
--- packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
+++ packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
@@ -0,0 +1,17 @@
+//===-- main.c --*- 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 
+
+namespace abc {
+   int g_file_global_int = 42;
+}
+
+int main (int argc, char const *argv[])
+{
+return abc::g_file_global_int; // Set break point at this line.
+}
Index: 
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
===
--- 
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
+++ 
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
@@ -0,0 +1,41 @@
+"""Test that C++ global variables can be inspected by name and also their 
mangled name."""
+
+from __future__ import print_function
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GlobalVariablesCppTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.source = lldb.SBFileSpec('main.cpp')
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+def test(self):
+self.build()
+
+(target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set 
break point at this line.", self.source)
+
+# Check that we can access g_file_global_int by its name
+self.expect("target variable g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable abc::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable xyz::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+error=True, substrs=['can\'t find global variable'])
+
+# Check that we can access g_file_global_int by its mangled name
+addr = 
target.EvaluateExpression("&abc::g_file_global_int").GetValueAsUnsigned()
+self.assertTrue(addr != 0)
+mangled = lldb.SBAddress(addr, target).GetSymbol().GetMangledName()
+self.assertTrue(mangled != None)
+gv = target.FindFirstGlobalVariable(mangled)
+self.assertTrue(gv.IsValid())
+self.assertEqual(gv.GetName(), "abc::g_file_global_int")
+self.assertEqual(gv.GetValueAsUnsigned(), 42)
Index: packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
===
--- packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
+++ packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFi

[Lldb-commits] [PATCH] D60737: [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

2019-04-17 Thread Kuba (Brecka) Mracek via Phabricator via lldb-commits
kubamracek added a comment.

Okay. @jingham, any more comments, or is this okay to land?


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

https://reviews.llvm.org/D60737



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


[Lldb-commits] [PATCH] D60737: [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

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

LGTM


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

https://reviews.llvm.org/D60737



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


[Lldb-commits] [lldb] r358604 - [CMake] Remove Apple-specific version logic.

2019-04-17 Thread Frederic Riss via lldb-commits
Author: friss
Date: Wed Apr 17 11:23:22 2019
New Revision: 358604

URL: http://llvm.org/viewvc/llvm-project?rev=358604&view=rev
Log:
[CMake] Remove Apple-specific version logic.

We were using the LLDB-Info.plist as the canonical holder of the
version number, but there is really no good reason to do this. If
anything the plist should be generated using the information provided
to CMake.

For now just remove the logic extracting the version from the plist
and rely on LLDB_VERSION_STRING.

Removed:
lldb/trunk/cmake/modules/EmbedAppleVersion.cmake
Modified:
lldb/trunk/source/CMakeLists.txt
lldb/trunk/source/lldb.cpp

Removed: lldb/trunk/cmake/modules/EmbedAppleVersion.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/EmbedAppleVersion.cmake?rev=358603&view=auto
==
--- lldb/trunk/cmake/modules/EmbedAppleVersion.cmake (original)
+++ lldb/trunk/cmake/modules/EmbedAppleVersion.cmake (removed)
@@ -1,11 +0,0 @@
-execute_process(COMMAND /usr/libexec/PlistBuddy -c "Print:CFBundleVersion" 
${LLDB_INFO_PLIST}
-OUTPUT_VARIABLE BundleVersion
-OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-file(APPEND "${HEADER_FILE}.tmp"
-"#define LLDB_VERSION_STRING lldb-${BundleVersion}\n")
-
-execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
-  "${HEADER_FILE}.tmp" "${HEADER_FILE}")
-
-file(REMOVE "${HEADER_FILE}.tmp")

Modified: lldb/trunk/source/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=358604&r1=358603&r2=358604&view=diff
==
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/trunk/source/CMakeLists.txt Wed Apr 17 11:23:22 2019
@@ -39,29 +39,7 @@ set_property(SOURCE lldb.cpp APPEND PROP
 
 list(APPEND lldbBase_SOURCES ${version_inc})
 
-if(APPLE)
-  set(apple_version_inc "${CMAKE_CURRENT_BINARY_DIR}/AppleVersion.inc")
-  set(apple_version_script 
"${LLDB_SOURCE_DIR}/cmake/modules/EmbedAppleVersion.cmake")
-  set(info_plist ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist)
-
-  # Create custom target to generate the VC revision include.
-  add_custom_command(OUTPUT "${apple_version_inc}"
-DEPENDS "${apple_version_script}" "${info_plist}"
-COMMAND
-${CMAKE_COMMAND} "-DLLDB_INFO_PLIST=${info_plist}"
- "-DHEADER_FILE=${apple_version_inc}"
- -P "${apple_version_script}")
-
-  # Mark the generated header as being generated.
-  set_source_files_properties("${apple_version_inc}"
-PROPERTIES GENERATED TRUE
-   HEADER_FILE_ONLY TRUE)
-
-  # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC.
-  set_property(SOURCE lldb.cpp APPEND PROPERTY 
-   COMPILE_DEFINITIONS "HAVE_APPLE_VERSION_INC")
-  list(APPEND lldbBase_SOURCES ${apple_version_inc})
-elseif(LLDB_VERSION_STRING)
+if(LLDB_VERSION_STRING)
   set_property(SOURCE lldb.cpp APPEND PROPERTY
COMPILE_DEFINITIONS 
"LLDB_VERSION_STRING=${LLDB_VERSION_STRING}")
 endif()

Modified: lldb/trunk/source/lldb.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=358604&r1=358603&r2=358604&view=diff
==
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Wed Apr 17 11:23:22 2019
@@ -17,10 +17,6 @@ using namespace lldb_private;
 #include "VCSVersion.inc"
 #endif
 
-#ifdef HAVE_APPLE_VERSION_INC
-#include "AppleVersion.inc"
-#endif
-
 static const char *GetLLDBRevision() {
 #ifdef LLDB_REVISION
   return LLDB_REVISION;


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


[Lldb-commits] [lldb] r358615 - [crashlog] Use the right path for dsymforUUID and remove an unnecessary import.

2019-04-17 Thread Davide Italiano via lldb-commits
Author: davide
Date: Wed Apr 17 14:51:55 2019
New Revision: 358615

URL: http://llvm.org/viewvc/llvm-project?rev=358615&view=rev
Log:
[crashlog] Use the right path for dsymforUUID and remove an unnecessary import.



Modified:
lldb/trunk/examples/python/crashlog.py

Modified: lldb/trunk/examples/python/crashlog.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/crashlog.py?rev=358615&r1=358614&r2=358615&view=diff
==
--- lldb/trunk/examples/python/crashlog.py (original)
+++ lldb/trunk/examples/python/crashlog.py Wed Apr 17 14:51:55 2019
@@ -221,7 +221,7 @@ class CrashLog(symbolication.Symbolicato
 
 class DarwinImage(symbolication.Image):
 """Class that represents a binary images in a darwin crash log"""
-dsymForUUIDBinary = os.path.expanduser('~rc/bin/dsymForUUID')
+dsymForUUIDBinary = '/usr/local/bin/dsymForUUID'
 if not os.path.exists(dsymForUUIDBinary):
 try:
 dsymForUUIDBinary = subprocess.check_output('which 
dsymForUUID',
@@ -303,7 +303,6 @@ class CrashLog(symbolication.Symbolicato
 return False
 if not self.resolved_path and not os.path.exists(self.path):
 try:
-import subprocess
 dsym = subprocess.check_output(
 ["/usr/bin/mdfind",
  "com_apple_xcode_dsym_uuids == %s"%uuid_str])[:-1]
@@ -321,10 +320,6 @@ class CrashLog(symbolication.Symbolicato
 if (self.resolved_path and os.path.exists(self.resolved_path)) or (
 self.path and os.path.exists(self.path)):
 print('ok')
-# if self.resolved_path:
-# print '  exe = "%s"' % self.resolved_path
-# if self.symfile:
-# print ' dsym = "%s"' % self.symfile
 return True
 else:
 self.unavailable = True


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


[Lldb-commits] [PATCH] D60405: MinidumpYAML: Add support for ModuleList stream

2019-04-17 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

Nice!




Comment at: include/llvm/ObjectYAML/MinidumpYAML.h:57
+/// record. In memory, we represent these as the ParsedModule struct, which
+/// groups minidump::Module with all of it's dependant structures in a single
+/// entity.

nit: s/it's/its/


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60405



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


[Lldb-commits] [PATCH] D60519: [Windows] Dump more information about access violation exception

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

Thanks for the new test and the test fix.  It's unfortunate that the tests are 
so sensitive to an arbitrary buffer size.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60519



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


[Lldb-commits] [lldb] r358625 - [Cmake] Add missing dependency for running tests.

2019-04-17 Thread Davide Italiano via lldb-commits
Author: davide
Date: Wed Apr 17 16:43:01 2019
New Revision: 358625

URL: http://llvm.org/viewvc/llvm-project?rev=358625&view=rev
Log:
[Cmake] Add missing dependency for running tests.

This is needed now that we marked lldb-test as EXCLUDE_ALL, to
make sure `ninja lldb-test-deps` doesn't fail.

Modified:
lldb/trunk/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=358625&r1=358624&r2=358625&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed Apr 17 16:43:01 2019
@@ -79,6 +79,9 @@ if(LLDB_INCLUDE_TESTS)
 list(APPEND LLDB_TEST_DEPS darwin-debug)
   endif()
 
+  # lldb-test is an hard dependency for the testsuite.
+  list(APPEND LLDB_TEST_DEPS lldb-test)
+
   if(TARGET lldb-server)
 list(APPEND LLDB_TEST_DEPS lldb-server)
   endif()


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


[Lldb-commits] [lldb] r358629 - [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

2019-04-17 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Wed Apr 17 17:15:44 2019
New Revision: 358629

URL: http://llvm.org/viewvc/llvm-project?rev=358629&view=rev
Log:
[lldb] Don't filter variable list when doing a lookup by mangled name in 
SymbolFileDWARF::FindGlobalVariables

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


Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile?rev=358629&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile 
Wed Apr 17 17:15:44 2019
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py?rev=358629&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
 Wed Apr 17 17:15:44 2019
@@ -0,0 +1,41 @@
+"""Test that C++ global variables can be inspected by name and also their 
mangled name."""
+
+from __future__ import print_function
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GlobalVariablesCppTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.source = lldb.SBFileSpec('main.cpp')
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+def test(self):
+self.build()
+
+(target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set 
break point at this line.", self.source)
+
+# Check that we can access g_file_global_int by its name
+self.expect("target variable g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable abc::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable xyz::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+error=True, substrs=['can\'t find global variable'])
+
+# Check that we can access g_file_global_int by its mangled name
+addr = 
target.EvaluateExpression("&abc::g_file_global_int").GetValueAsUnsigned()
+self.assertTrue(addr != 0)
+mangled = lldb.SBAddress(addr, target).GetSymbol().GetMangledName()
+self.assertTrue(mangled != None)
+gv = target.FindFirstGlobalVariable(mangled)
+self.assertTrue(gv.IsValid())
+self.assertEqual(gv.GetName(), "abc::g_file_global_int")
+self.assertEqual(gv.GetValueAsUnsigned(), 42)

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp?rev=358629&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp 
Wed Apr 17 17:15:44 2019
@@ -0,0 +1,17 @@
+//===-- main.c --*- 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 
+
+namespace abc {
+   int g_file_global_int = 42;
+}
+
+int main (int argc, char const *argv[])
+{
+return abc::g_file_global_int; // Set break point at this line.
+}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=358629&r1=358628&r2=358629&view=diff
==

[Lldb-commits] [PATCH] D60737: [lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

2019-04-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB358629: [lldb] Don't filter variable list when doing 
a lookup by mangled name in… (authored by kuba.brecka, committed by ).

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60737

Files:
  packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
  
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
  packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
===
--- packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
+++ packages/Python/lldbsuite/test/lang/cpp/global_variables/main.cpp
@@ -0,0 +1,17 @@
+//===-- main.c --*- 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 
+
+namespace abc {
+   int g_file_global_int = 42;
+}
+
+int main (int argc, char const *argv[])
+{
+return abc::g_file_global_int; // Set break point at this line.
+}
Index: 
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
===
--- 
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
+++ 
packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
@@ -0,0 +1,41 @@
+"""Test that C++ global variables can be inspected by name and also their 
mangled name."""
+
+from __future__ import print_function
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GlobalVariablesCppTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.source = lldb.SBFileSpec('main.cpp')
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+def test(self):
+self.build()
+
+(target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set 
break point at this line.", self.source)
+
+# Check that we can access g_file_global_int by its name
+self.expect("target variable g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable abc::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable xyz::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+error=True, substrs=['can\'t find global variable'])
+
+# Check that we can access g_file_global_int by its mangled name
+addr = 
target.EvaluateExpression("&abc::g_file_global_int").GetValueAsUnsigned()
+self.assertTrue(addr != 0)
+mangled = lldb.SBAddress(addr, target).GetSymbol().GetMangledName()
+self.assertTrue(mangled != None)
+gv = target.FindFirstGlobalVariable(mangled)
+self.assertTrue(gv.IsValid())
+self.assertEqual(gv.GetName(), "abc::g_file_global_int")
+self.assertEqual(gv.GetValueAsUnsigned(), 42)
Index: packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
===
--- packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
+++ packages/Python/lldbsuite/test/lang/cpp/global_variables/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2036,6 +2036,7 @@
 
   llvm::StringRef basename;
   llvm::StringRef context;
+  bool name_is_mangled = (bool)Mangled(name);
 
   if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name.GetCString(),
   context, basename))
@@ -2085,7 +2086,8 @@
  &variables);
   while (pruned_idx < variables.GetSize()) {
 VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
-if (var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
+if (name_is_mangled ||
+var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
   ++pruned_idx;
 else
   variables.RemoveVariableAtIndex(pruned_idx);


Index: packages/Python/lldbsu

[Lldb-commits] [lldb] r358635 - [Shell] Simplify Extracting Python Version

2019-04-17 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Apr 17 18:37:19 2019
New Revision: 358635

URL: http://llvm.org/viewvc/llvm-project?rev=358635&view=rev
Log:
[Shell] Simplify Extracting Python Version

Instead of parsing the Python version with a fairly convoluted regex,
just print the major and minor version and call it a day.

Modified:
lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh

Modified: lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh?rev=358635&r1=358634&r2=358635&view=diff
==
--- lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh (original)
+++ lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh Wed Apr 17 18:37:19 
2019
@@ -56,8 +56,7 @@ fi
 
 OS_NAME=`uname -s`
 PYTHON=${PYTHON_EXECUTABLE:-/usr/bin/env python}
-PYTHON_VERSION=`${PYTHON} --version 2>&1 | sed -e 's,Python ,,' -e 
's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'`
-
+PYTHON_VERSION=`${PYTHON} -c 'import sys; 
print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
 
 if [ $Debug -eq 1 ]
 then


___
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-17 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

Thanks for digging in to this Pavel.  I haven't had time to look over the patch 
today, but I'd like to; I'll make time for it in the next couple days if that's 
OK.


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