[Lldb-commits] [PATCH] D71801: [lldb/Lua] Make lldb.debugger et al available to Lua

2020-01-09 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.

Thanks for your patience. Looks fine to me, just remove the dead code..




Comment at: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp:29-38
+
+llvm::Error Lua::EnterSession(user_id_t debugger_id) {
+  const char *fmt_str =
+  "lldb.debugger = lldb.SBDebugger.FindDebuggerWithID({0}); "
+  "lldb.target = lldb.debugger:GetSelectedTarget(); "
+  "lldb.process = lldb.target:GetProcess(); "
+  "lldb.thread = lldb.process:GetSelectedThread(); "

This should be dead code now, right?


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

https://reviews.llvm.org/D71801



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


[Lldb-commits] [PATCH] D72437: [lldb/Bindings] Move bindings into their own subdirectory

2020-01-09 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.
Herald added a subscriber: dexonsmith.

I think this is a great idea. I'm not convinced of the need to pluralize 
"interfaces" (header files are in "include", even though that folder usually 
contains more than one file), but I don't care much either way...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72437



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


[Lldb-commits] [PATCH] D72086: [lldb] Fix that SBThread.GetStopDescription is returning strings with uninitialized memory at the end.

2020-01-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 236986.
teemperor added a comment.

- Just removed the result parameter.


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

https://reviews.llvm.org/D72086

Files:
  lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
  lldb/scripts/Python/python-typemaps.swig


Index: lldb/scripts/Python/python-typemaps.swig
===
--- lldb/scripts/Python/python-typemaps.swig
+++ lldb/scripts/Python/python-typemaps.swig
@@ -121,7 +121,7 @@
   $result = string.release();
   Py_INCREF($result);
} else {
-  llvm::StringRef ref(static_cast($1), result);
+  llvm::StringRef ref(static_cast($1));
   PythonString string(ref);
   $result = string.release();
}
Index: lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
@@ -122,14 +122,20 @@
 self.assertTrue(
 thread.IsValid(),
 "There should be a thread stopped due to breakpoint")
-#self.runCmd("process status")
-
-# Due to the typemap magic (see lldb.swig), we pass in an (int)length 
to GetStopDescription
-# and expect to get a Python string as the return object!
-# The 100 is just an arbitrary number specifying the buffer size.
-stop_description = thread.GetStopDescription(100)
-self.expect(stop_description, exe=False,
-startstr='breakpoint')
+
+# Get the stop reason. GetStopDescription expects that we pass in the 
size of the description
+# we expect plus an additional byte for the null terminator.
+
+# Test with a buffer that is exactly as large as the expected stop 
reason.
+self.assertEqual("breakpoint 1.1", 
thread.GetStopDescription(len('breakpoint 1.1') + 1))
+
+# Test some smaller buffer sizes.
+self.assertEqual("breakpoint", 
thread.GetStopDescription(len('breakpoint') + 1))
+self.assertEqual("break", thread.GetStopDescription(len('break') + 1))
+self.assertEqual("b", thread.GetStopDescription(len('b') + 1))
+
+# Test that we can pass in a much larger size and still get the right 
output.
+self.assertEqual("breakpoint 1.1", 
thread.GetStopDescription(len('breakpoint 1.1') + 100))
 
 def step_out_of_malloc_into_function_b(self, exe_name):
 """Test Python SBThread.StepOut() API to step out of a malloc call 
where the call site is at function b()."""


Index: lldb/scripts/Python/python-typemaps.swig
===
--- lldb/scripts/Python/python-typemaps.swig
+++ lldb/scripts/Python/python-typemaps.swig
@@ -121,7 +121,7 @@
   $result = string.release();
   Py_INCREF($result);
} else {
-  llvm::StringRef ref(static_cast($1), result);
+  llvm::StringRef ref(static_cast($1));
   PythonString string(ref);
   $result = string.release();
}
Index: lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py
@@ -122,14 +122,20 @@
 self.assertTrue(
 thread.IsValid(),
 "There should be a thread stopped due to breakpoint")
-#self.runCmd("process status")
-
-# Due to the typemap magic (see lldb.swig), we pass in an (int)length to GetStopDescription
-# and expect to get a Python string as the return object!
-# The 100 is just an arbitrary number specifying the buffer size.
-stop_description = thread.GetStopDescription(100)
-self.expect(stop_description, exe=False,
-startstr='breakpoint')
+
+# Get the stop reason. GetStopDescription expects that we pass in the size of the description
+# we expect plus an additional byte for the null terminator.
+
+# Test with a buffer that is exactly as large as the expected stop reason.
+self.assertEqual("breakpoint 1.1", thread.GetStopDescription(len('breakpoint 1.1') + 1))
+
+# Test some smaller buffer sizes.
+self.assertEqual("breakpoint", thread.GetStopDescription(len('breakpoint') + 1))
+self.assertEqual("break", thread.GetStopDescription(len('break') + 1))
+self.assertEqual("b", thread.GetStopDescription(len('b') + 1))
+
+# Test that we can pass in a much larger size and still get the right output.
+self.assertEqual("breakpoint 1.1", thread.GetStopDescription(len('breakpoint 1.1') + 100))
 
 def step_out_of_malloc_into_function_b(self, exe_name):
 """Test Python SBThr

[Lldb-commits] [PATCH] D72391: [lldb] Add a display name to ClangASTContext instances

2020-01-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

@clayborg We can easily append the ptr value to the display name. All names 
should always be unique as long as there is one target, but in the off-chance 
that one isn't unique it might be useful.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72391



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


[Lldb-commits] [PATCH] D71825: [lldb/Lua] Support loading Lua modules.

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

Thanks. For posterity, I'm going to summarize my thoughts from that discussion.

I was arguing that "require" is not a good thing to be using here, because it's 
hard for it to guarantee that it will load a specific file. Now, that does not 
matter for "normal" uses of "require", but it is pretty unfortunate for the 
"command script import" command. This command takes an explicit filename 
argument, and it'd be pretty surprising to have "command script import 
/bar/foo.lua" load "/baz/foo.lua" just because "/baz" happened to come first in 
the search path.

Since figuring out what to load is the largest part of the "require" function, 
and that's exactly the part we don't need here, I think we can just drop 
"require" and implement the loading ourselves. (The other responsibility of the 
"require" function is to ensure a module is not loaded twice, but this is 
something we need to override anyway, as the "command script import" contract 
states that the module is always reloaded.)

Now back to the current patch: I see that you've dropped the part which assigns 
the result of evaluating the module to a global variable (and consequently, 
dropped the "local" keyword from the "mymodule" declaration). That seems 
unfortunate, as the recommended way for writing modules is to make the variable 
local, and return the module as a result.

What's the reasoning behind that? I was expecting we would keep that part... 
All it would take is adding an extra `lua_setglobal(m_lua_state, name)` call 
after the `pcall` stuff.




Comment at: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h:43-46
+  llvm::Expected FormatQuoted(llvm::StringRef str);
   std::mutex m_mutex;
   lua_State *m_lua_state;
+  llvm::StringSet<> m_loaded_modules;

I guess these are not needed anymore...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71825



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


[Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

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

In D71372#1810687 , @ted wrote:

> I've got another failure case for this. If the remote gdbserver doesn't 
> implement qMemoryRegionInfo or qXfer:memory-map:read, thread step-out will 
> fail.
>  


That's a good point Ted. I think we should give targets which don't support 
fetching permissions the benefit of the doubt, and treat all memory as 
potentially executable. Would removing the `return` statement from the 
`if(!GetLoadAddressPermissions)` branch solve your problem? If so, can you whip 
up a patch for that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71372



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


[Lldb-commits] [lldb] 782ad91 - [lldb] Fix that TestNoSuchArch.py was passing for the wrong reason

2020-01-09 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-01-09T12:09:48+01:00
New Revision: 782ad91cc423bf602718e2bf9ffc59e55350463f

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

LOG: [lldb] Fix that TestNoSuchArch.py was passing for the wrong reason

The command here failed due to the type in 'create' but the expect
did not actually check for the error message. This fixes the typo
and adds a check for the actuall error message we should see.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/target/create-no-such-arch/TestNoSuchArch.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/create-no-such-arch/TestNoSuchArch.py
 
b/lldb/packages/Python/lldbsuite/test/commands/target/create-no-such-arch/TestNoSuchArch.py
index a780ca275664..4d7f0838f877 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/target/create-no-such-arch/TestNoSuchArch.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/create-no-such-arch/TestNoSuchArch.py
@@ -19,8 +19,8 @@ def test(self):
 # Check that passing an invalid arch via the command-line fails but
 # doesn't crash
 self.expect(
-"target crete --arch nothingtoseehere %s" %
-(exe), error=True)
+"target create --arch nothingtoseehere %s" %
+(exe), error=True, substrs=["error: invalid triple 
'nothingtoseehere'"])
 
 # Check that passing an invalid arch via the SB API fails but doesn't
 # crash



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


[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2020-01-09 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:342-343
+section_type,  // Section type.
+sect_info.offset & 0x, // VM address.
+sect_info.size, // VM size in bytes of this section.
+sect_info.offset &

paolosev wrote:
> labath wrote:
> > paolosev wrote:
> > > labath wrote:
> > > > Are the debug info sections actually loaded into memory for wasm? 
> > > > Should these be zero (that's what they are for elf)?
> > > Yes, I was thinking that the debug sections should be loaded into memory; 
> > > not sure how this works for ELF, how does the debugger find the debug 
> > > info in that case?
> > Are you referring to the load-from-memory, or load-from-file scenario? 
> > Normally, the debug info is not loaded into memory, and if lldb is loading 
> > the module from a file, then the debug info is loaded from the file (and we 
> > use the "file offset" field to locate them). Loading files from memory does 
> > not work in general (because we can't find the whole file there -- e.g., 
> > section headers are missing). The only case it does work is in case of 
> > jitted files. I'm not 100% sure how that works, but given that there is no 
> > `if(memory)` block in the section creation code, those sections must too 
> > get `vm size = 0`.
> > 
> > In practice, I don't think it does not matter that much what you put here 
> > -- I expect things will mostly work regardless. I am just trying to make 
> > this consistent in some way. If these sections are not found in the memory 
> > at the address which you set here (possibly adjusted by the load bias) then 
> > I think it makes sense to set `vm_size=vm_addr=0`. If they are indeed 
> > present there, then setting it to those values is perfectly fine.
> Modified, but I am not sure I completely understood the difference of file 
> addresses and vm addresses.
> 
> In the case of Wasm, we can have two cases:
> a) Wasm module contains executable code and also DWARF data embedded in DWARF 
> sections
> b) Wasm module contains code and has a custom section that points to a 
> separated Wasm module that only contains DWARF sections
> 
> The file of Wasm modules that contains code should never be loaded directly 
> by LLDB; LLDB should use GDB-remote to connect to the Wasm engine that loaded 
> the module and retrieve the module content from the engine.
> But when the DWARF data has been stripped into a separate Wasm file, that 
> file should be directly loaded by LLDB in order to load the debug sections.
> So, if I am not wrong, only in the first case we should assume that the debug 
> info is loaded into memory, and have vm_size != 0?
You're right, this is getting pretty confusing, as a lot of the concepts we're 
talking about here are overloaded (and not even consistently used within lldb). 
Let me try to elaborate here.

I'll start by describing various Section fields (I'll use ELF as a reference):
- file offset (`m_file_offset`) - where the section is physically located in 
the file. It does not matter if the file is loaded from inferior memory or not 
(in the former case, this is an offset from location of the first byte of the 
file). In elf this corresponds to the `sh_offset` field.
- file size (`m_file_size`) - size of the section in the file. Some sections 
don't take up any space in the file (`.bss`), so they have this zero. This is 
roughly the `sh_size` field in elf (but it is adjusted for SHT_NOBITS sections 
like .bss)
- file address (`m_file_addr`) - The address where the object file says this 
section should be loaded to. Note that this may not be the final address due to 
ASLR or such. It is the job of the SetLoadAddress function to compute the 
actual final address (which is then called the "load address"). This 
corresponds to the `sh_addr` field in elf, but it is also sometimes called the 
"vm address", because of the `p_vaddr` program header field
- vm size (`m_byte_size) size of the section when it gets loaded into memory. 
Sections which don't get loaded into memory have this as 0. This is also 
"rougly" `sh_size`, but only for SHF_ALLOC sections.

All of these fields are really geared for the case where lldb opens a file from 
disk, and then uses that to understand the contents of process memory. They 
become pretty redundant if you have loaded the file from memory, but it should 
still be possible to assign meaningful values to each of them.

The file offset+file size combo should reflect the locations of the sections 
within the file (regardless of whether it's a "real" file or just a chunk of 
memory). And the file address+vm size combo should reflect the locations of the 
sections in memory (modulo ASLR, and again independently of where lldb happened 
to read the file from).

Looking at the patch, I think you've got most of these right. The only quest

[Lldb-commits] [lldb] cd5da94 - [lldb/DWARF] Fix mixed v4+v5 location lists

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

Author: Pavel Labath
Date: 2020-01-09T13:19:29+01:00
New Revision: cd5da94d80b2b0f2bdb2d0157e24705a4cbd2a4e

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

LOG: [lldb/DWARF] Fix mixed v4+v5 location lists

Summary:
Our code was expecting that a single (symbol) file contains only one
kind of location lists. This is not correct (on non-apple platforms, at
least) as a file can compile units with different dwarf versions.

This patch moves the deteremination of location list flavour down to the
compile unit level, fixing this problem. I have also tried to rougly
align the code with the llvm DWARFUnit. Fully matching the API is not
possible because of how lldb's DWARFExpression lives separately from the
rest of the DWARF code, but this is at least a step in the right
direction.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: dblaikie, lldb-commits

Tags: #lldb

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

Added: 
lldb/test/Shell/SymbolFile/DWARF/debug_loc_and_loclists.s

Modified: 
lldb/include/lldb/Expression/DWARFExpression.h
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 1e32957443fd..bfae142d5e01 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -34,15 +34,6 @@ namespace lldb_private {
 /// location expression or a location list and interprets it.
 class DWARFExpression {
 public:
-  enum LocationListFormat : uint8_t {
-NonLocationList, // Not a location list
-RegularLocationList, // Location list format used in non-split dwarf files
-SplitDwarfLocationList, // Location list format used in pre-DWARF v5 split
-// dwarf files (.debug_loc.dwo)
-LocLists,   // Location list format used in DWARF v5
-// (.debug_loclists/.debug_loclists.dwo).
-  };
-
   DWARFExpression();
 
   /// Constructor

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index c67e35b14518..69c84640ef93 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -54,29 +54,6 @@ ReadAddressFromDebugAddrSection(const DWARFUnit *dwarf_cu,
   return LLDB_INVALID_ADDRESS;
 }
 
-/// Return the location list parser for the given format.
-static std::unique_ptr
-GetLocationTable(DWARFExpression::LocationListFormat format, const 
DataExtractor &data) {
-  llvm::DWARFDataExtractor llvm_data(
-  toStringRef(data.GetData()),
-  data.GetByteOrder() == lldb::eByteOrderLittle, 
data.GetAddressByteSize());
-
-  switch (format) {
-  case DWARFExpression::NonLocationList:
-return nullptr;
-  // DWARF<=4 .debug_loc
-  case DWARFExpression::RegularLocationList:
-return std::make_unique(llvm_data);
-  // Non-standard DWARF 4 extension (fission) .debug_loc.dwo
-  case DWARFExpression::SplitDwarfLocationList:
-  // DWARF 5 .debug_loclists(.dwo)
-  case DWARFExpression::LocLists:
-return std::make_unique(
-llvm_data, format == DWARFExpression::LocLists ? 5 : 4);
-  }
-  llvm_unreachable("Invalid LocationListFormat!");
-}
-
 // DWARFExpression constructor
 DWARFExpression::DWARFExpression()
 : m_module_wp(), m_data(), m_dwarf_cu(nullptr),
@@ -157,10 +134,8 @@ void DWARFExpression::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   if (IsLocationList()) {
 // We have a location list
 lldb::offset_t offset = 0;
-std::unique_ptr loctable_up = GetLocationTable(
-m_dwarf_cu->GetSymbolFileDWARF().GetLocationListFormat(), m_data);
-if (!loctable_up)
-  return;
+std::unique_ptr loctable_up =
+m_dwarf_cu->GetLocationTable(m_data);
 
 llvm::MCRegisterInfo *MRI = abi ? &abi->GetMCRegisterInfo() : nullptr;
 
@@ -2812,10 +2787,8 @@ DWARFExpression::GetLocationExpression(addr_t 
load_function_start,
addr_t addr) const {
   Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
 
-  std::unique_ptr loctable_up = GetLocationTable(
-  m_dwarf_cu->GetSymbolFileDWARF().GetLocationListFormat(), m_data);
-  if (!loctable_up)
-return llvm::None;
+  std::unique_ptr loctable_up =
+  m_dwarf_cu->GetLocationTa

[Lldb-commits] [lldb] 9bb01ef - [lldb/DWARF] Add is_dwo member to DWARFUnit

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

Author: Pavel Labath
Date: 2020-01-09T13:19:29+01:00
New Revision: 9bb01efa49ca7f069bc7acba7e4c9bf64d972e79

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

LOG: [lldb/DWARF] Add is_dwo member to DWARFUnit

Summary:
A skeleton unit can easily be detected by checking the m_dwo_symbol_file
member, but we cannot tell a split unit from a normal unit from the
"inside", which is sometimes useful.

This patch adds a m_is_dwo member to enable this, and align the code
with llvm::DWARFUnit. Right now it's only used to avoid creating a split
unit inside another split unit (which removes one override from
SymbolFileDWARFDwo and brings us a step closer to deleting it), but my
main motivation is fixing the handling of location lists in mixed v4&v5
files. This comes in a separate patch.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: dblaikie, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index 75647dbb082f..454637ef981c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -24,8 +24,8 @@ class DWARFCompileUnit : public DWARFUnit {
   DWARFCompileUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
const DWARFUnitHeader &header,
const DWARFAbbreviationDeclarationSet &abbrevs,
-   DIERef::Section section)
-  : DWARFUnit(dwarf, uid, header, abbrevs, section) {}
+   DIERef::Section section, bool is_dwo)
+  : DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
 
   DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit);
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
index add042384039..24baac90aa44 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -41,8 +41,6 @@ class DWARFContext {
   SectionData m_data_debug_str_offsets;
   SectionData m_data_debug_types;
 
-  bool isDwo() { return m_dwo_section_list != nullptr; }
-
   const DWARFDataExtractor &
   LoadOrGetSection(lldb::SectionType main_section_type,
llvm::Optional dwo_section_type,
@@ -67,6 +65,8 @@ class DWARFContext {
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
 
+  bool isDwo() { return m_dwo_section_list != nullptr; }
+
   llvm::DWARFContext &GetAsLLVM();
 };
 } // namespace lldb_private

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
index 6ff73ecd8efa..8967509c081a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
@@ -28,8 +28,8 @@ class DWARFTypeUnit : public DWARFUnit {
   DWARFTypeUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
 const DWARFUnitHeader &header,
 const DWARFAbbreviationDeclarationSet &abbrevs,
-DIERef::Section section)
-  : DWARFUnit(dwarf, uid, header, abbrevs, section) {}
+DIERef::Section section, bool is_dwo)
+  : DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
 
   friend class DWARFUnit;
 };

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index d8d70bae0232..32f0f89c042a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -32,9 +32,9 @@ extern int g_verbose;
 DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
  const DWARFUnitHeader &header,
  const DWARFAbbreviationDeclarationSet &abbrevs,
- DIERef::Section section)
+ DIERef::Section section, bool is_dwo)
 : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
-  m_cancel_scopes(false), m_section(section) {}
+  m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo) {}
 
 DWARFUnit::~DWARFUnit() = default;
 
@@ -336,6 +336,9 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry 
&

[Lldb-commits] [PATCH] D71751: [lldb/DWARF] Fix mixed v4+v5 location lists

2020-01-09 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd5da94d80b2: [lldb/DWARF] Fix mixed v4+v5 location lists 
(authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71751

Files:
  lldb/include/lldb/Expression/DWARFExpression.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/test/Shell/SymbolFile/DWARF/debug_loc_and_loclists.s

Index: lldb/test/Shell/SymbolFile/DWARF/debug_loc_and_loclists.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/debug_loc_and_loclists.s
@@ -0,0 +1,154 @@
+# Test that we can handle DWARF 4 and 5 location lists in the same object file
+# (but different compile units).
+
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t -o "image lookup -v -s loc" -o "image lookup -v -s loclists" \
+# RUN:   -o exit | FileCheck %s
+
+
+# CHECK-LABEL: image lookup -v -s loc
+# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = DW_OP_reg5 RDI,
+
+# CHECK-LABEL: image lookup -v -s loclists
+# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = DW_OP_reg0 RAX,
+
+
+loc:
+nop
+.Lloc_end:
+
+loclists:
+nop
+.Lloclists_end:
+
+.section.debug_loc,"",@progbits
+.Lloc_list:
+.quad loc-loc
+.quad .Lloc_end-loc
+.short 1
+.byte   85  # super-register DW_OP_reg5
+.quad 0
+.quad 0
+
+.section.debug_loclists,"",@progbits
+.long   .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
+.Ldebug_loclist_table_start0:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   0   # Offset entry count
+
+.Lloclists_list:
+.byte   4   # DW_LLE_offset_pair
+.uleb128 loclists-loclists
+.uleb128 .Lloclists_end-loclists
+.uleb128 1
+.byte   80  # super-register DW_OP_reg0
+.byte   0   # DW_LLE_end_of_list
+.Ldebug_loclist_table_end0:
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   19  # DW_AT_language
+.byte   5   # DW_FORM_data2
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_CHILDREN_yes
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   16  # DW_FORM_ref_addr
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   3   # Abbreviation Code
+.byte   5   # DW_TAG_formal_parameter
+.byte   0   # DW_CHILDREN_no
+.byte   2   # DW_AT_location
+.byte   23  # DW_FORM_sec_offset
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   16  # DW_FORM_ref_addr
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   4   # Abbreviation Code
+.byte   36  # DW_TAG_b

[Lldb-commits] [PATCH] D71750: [lldb/DWARF] Add is_dwo member to DWARFUnit

2020-01-09 Thread Pavel Labath via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9bb01efa49ca: [lldb/DWARF] Add is_dwo member to DWARFUnit 
(authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71750

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -47,12 +47,6 @@
   DWARFDIE
   GetDIE(const DIERef &die_ref) override;
 
-  std::unique_ptr
-  GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
- const DWARFDebugInfoEntry &cu_die) override {
-return nullptr;
-  }
-
   DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
 
   llvm::Optional GetDwoNum() override { return GetID() >> 32; }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -287,7 +287,7 @@
 
   lldb::user_id_t GetUID(DIERef ref);
 
-  virtual std::unique_ptr
+  std::unique_ptr
   GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
  const DWARFDebugInfoEntry &cu_die);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -247,7 +247,7 @@
   DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
 const DWARFUnitHeader &header,
 const DWARFAbbreviationDeclarationSet &abbrevs,
-DIERef::Section section);
+DIERef::Section section, bool is_dwo);
 
   llvm::Error ExtractHeader(SymbolFileDWARF &dwarf,
 const lldb_private::DWARFDataExtractor &data,
@@ -314,6 +314,7 @@
   llvm::Optional m_loclist_table_header;
 
   const DIERef::Section m_section;
+  bool m_is_dwo;
 
 private:
   void ParseProducerInfo();
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -32,9 +32,9 @@
 DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
  const DWARFUnitHeader &header,
  const DWARFAbbreviationDeclarationSet &abbrevs,
- DIERef::Section section)
+ DIERef::Section section, bool is_dwo)
 : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
-  m_cancel_scopes(false), m_section(section) {}
+  m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo) {}
 
 DWARFUnit::~DWARFUnit() = default;
 
@@ -336,6 +336,9 @@
 }
   }
 
+  if (m_is_dwo)
+return;
+
   std::unique_ptr dwo_symbol_file =
   m_dwarf.GetDwoSymbolFileForCompileUnit(*this, cu_die);
   if (!dwo_symbol_file)
@@ -872,11 +875,12 @@
 return llvm::make_error(
 "No abbrev exists at the specified offset.");
 
+  bool is_dwo = dwarf.GetDWARFContext().isDwo();
   if (expected_header->IsTypeUnit())
-return DWARFUnitSP(
-new DWARFTypeUnit(dwarf, uid, *expected_header, *abbrevs, section));
-  return DWARFUnitSP(
-  new DWARFCompileUnit(dwarf, uid, *expected_header, *abbrevs, section));
+return DWARFUnitSP(new DWARFTypeUnit(dwarf, uid, *expected_header, *abbrevs,
+ section, is_dwo));
+  return DWARFUnitSP(new DWARFCompileUnit(dwarf, uid, *expected_header,
+  *abbrevs, section, is_dwo));
 }
 
 const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
@@ -28,8 +28,8 @@
   DWARFTypeUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
 const DWARFUnitHeader &header,
 const DWARFAbbreviationDeclarationSet &abbrevs,
-DIERef::Section section)
-  : DWARFUnit(dwarf, uid, header, abbrevs

[Lldb-commits] [lldb] 5c4661b - [lldb] Modernize OptionValue::SetValueChangedCallback

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

Author: Pavel Labath
Date: 2020-01-09T14:17:17+01:00
New Revision: 5c4661b7784115cb330996b3a6461c5927339aef

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

LOG: [lldb] Modernize OptionValue::SetValueChangedCallback

instead of a function pointer + void*, take a std::function. This
removes a bunch of repetitive, unsafe void* casts.

Added: 


Modified: 
lldb/include/lldb/Interpreter/OptionValue.h
lldb/include/lldb/Interpreter/OptionValueProperties.h
lldb/include/lldb/Interpreter/Property.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/Interpreter/OptionValueProperties.cpp
lldb/source/Interpreter/Property.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index 734c92b4bcad..44c7f621a582 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -58,8 +58,7 @@ class OptionValue {
 eDumpGroupExport = (eDumpOptionCommand | eDumpOptionName | 
eDumpOptionValue)
   };
 
-  OptionValue()
-  : m_callback(nullptr), m_baton(nullptr), m_value_was_set(false) {}
+  OptionValue() : m_value_was_set(false) {}
 
   virtual ~OptionValue() = default;
 
@@ -304,22 +303,19 @@ class OptionValue {
 m_parent_wp = parent_sp;
   }
 
-  void SetValueChangedCallback(OptionValueChangedCallback callback,
-   void *baton) {
-assert(m_callback == nullptr);
-m_callback = callback;
-m_baton = baton;
+  void SetValueChangedCallback(std::function callback) {
+assert(!m_callback);
+m_callback = std::move(callback);
   }
 
   void NotifyValueChanged() {
 if (m_callback)
-  m_callback(m_baton, this);
+  m_callback();
   }
 
 protected:
   lldb::OptionValueWP m_parent_wp;
-  OptionValueChangedCallback m_callback;
-  void *m_baton;
+  std::function m_callback;
   bool m_value_was_set; // This can be used to see if a value has been set
 // by a call to SetValueFromCString(). It is often
 // handy to know if an option value was set from the

diff  --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h 
b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index bea2b3c91e00..980f01183ef5 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -198,8 +198,7 @@ class OptionValueProperties
ConstString name);
 
   void SetValueChangedCallback(uint32_t property_idx,
-   OptionValueChangedCallback callback,
-   void *baton);
+   std::function callback);
 
 protected:
   Property *ProtectedGetPropertyAtIndex(uint32_t idx) {

diff  --git a/lldb/include/lldb/Interpreter/Property.h 
b/lldb/include/lldb/Interpreter/Property.h
index 797aee4be815..76264832705b 100644
--- a/lldb/include/lldb/Interpreter/Property.h
+++ b/lldb/include/lldb/Interpreter/Property.h
@@ -64,8 +64,7 @@ class Property {
uint32_t output_width,
bool display_qualified_name) const;
 
-  void SetValueChangedCallback(OptionValueChangedCallback callback,
-   void *baton);
+  void SetValueChangedCallback(std::function callback);
 
 protected:
   ConstString m_name;

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 47c5c7870405..2ba996d4995f 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -85,9 +85,6 @@ class ProcessProperties : public Properties {
   std::chrono::seconds GetUtilityExpressionTimeout() const;
 
 protected:
-  static void OptionValueChangedCallback(void *baton,
- OptionValue *option_value);
-
   Process *m_process; // Can be nullptr for global ProcessProperties
 };
 

diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 6f8d60731acf..1e9153c401ef 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -209,26 +209,15 @@ class TargetProperties : public Properties {
 
 private:
   // Callbacks for m_launch_info.
-  static void Arg0ValueChangedCallback(void *target_property_ptr,
-   OptionValue *);
-  static void RunArgsValueChangedCallback(void *target_property_ptr,
-  OptionValue *);
-  static void EnvVarsValueChangedCallback(void *target_property_ptr,
-

[Lldb-commits] [PATCH] D72086: [lldb] Fix that SBThread.GetStopDescription is returning strings with uninitialized memory at the end.

2020-01-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

For reasons that are beyond my understanding this change seems to break 
`SBProcess.GetSTDOUT` in random tests like this:

  ==
  ERROR: test_change_value_dwarf (TestChangeValueAPI.ChangeValueAPITestCase)
 Exercise the SBValue::SetValueFromCString API.
  --
  Traceback (most recent call last):
File 
"/home/teemperor/work/ci/llvm/lldb/packages/Python/lldbsuite/test/lldbtest.py", 
line 1732, in test_method
  return attrvalue(self)
File 
"/home/teemperor/work/ci/llvm/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 454, in wrapper
  func(*args, **kwargs)
File 
"/home/teemperor/work/ci/llvm/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 110, in wrapper
  func(*args, **kwargs)
File 
"/home/teemperor/work/ci/llvm/lldb/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py",
 line 149, in test_change_value
  stdout = process.GetSTDOUT(1000)
File 
"/home/teemperor/work/ci/build/lib/python3.8/site-packages/lldb/__init__.py", 
line 8020, in GetSTDOUT
  return _lldb.SBProcess_GetSTDOUT(self, dst)
  SystemError:  returned NULL without 
setting an error
  Config=x86_64-/home/teemperor/work/ci/build/bin/clang-10

Anyone got a clue what is going on here? It seems like these tests only fail 
when run in combination with some other tests as running them alone is fine.


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

https://reviews.llvm.org/D72086



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


[Lldb-commits] [PATCH] D72447: [lldb] Mark several tests as not dependent on debug info

2020-01-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: labath, jingham, aprantl, mib.
Herald added a reviewer: jfb.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

This just adds `NO_DEBUG_INFO_TESTCASE` to tests that don't really exercise 
anything debug information specific
and therefore don't need to be rerun for all debug information variants.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D72447

Files:
  
lldb/packages/Python/lldbsuite/test/commands/apropos/with-process/TestAproposWithProcess.py
  
lldb/packages/Python/lldbsuite/test/commands/command/nested_alias/TestNestedAlias.py
  
lldb/packages/Python/lldbsuite/test/commands/command/script_alias/TestCommandScriptAlias.py
  
lldb/packages/Python/lldbsuite/test/commands/expression/calculator_mode/TestCalculatorMode.py
  lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py
  
lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
  
lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/TestAttachResume.py
  
lldb/packages/Python/lldbsuite/test/commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py
  lldb/packages/Python/lldbsuite/test/commands/statistics/basic/TestStats.py
  
lldb/packages/Python/lldbsuite/test/commands/target/create-no-such-arch/TestNoSuchArch.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/variable_out_of_scope/TestWatchedVarHitWhenInScope.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/TestOffsetofCpp.py
  lldb/packages/Python/lldbsuite/test/python_api/debugger/TestDebuggerAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
  lldb/packages/Python/lldbsuite/test/python_api/event/TestEvents.py
  
lldb/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py
  
lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py
  lldb/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
  lldb/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py
  
lldb/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py
  lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
  
lldb/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py
  lldb/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
  lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

Index: lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
+++ lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
@@ -14,6 +14,7 @@
 class TargetWatchAddressAPITestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
 
 def setUp(self):
 # Call super's setUp().
Index: lldb/packages/Python/lldbsuite/t

[Lldb-commits] [PATCH] D72086: [lldb] Fix that SBThread.GetStopDescription is returning strings with uninitialized memory at the end.

2020-01-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Ah, seems like we match in the type map by function signature and GetSTDOUT 
matches the signature by accident


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

https://reviews.llvm.org/D72086



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


[Lldb-commits] [PATCH] D72447: [lldb] Mark several tests as not dependent on debug info

2020-01-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.
Herald added a subscriber: dexonsmith.

Some of the tests technically touch debug information but don't test features 
specific to it. If anyone thinks some of these tests are worthwhile to run with 
all debug information variants then let me know.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72447



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


[Lldb-commits] [PATCH] D72447: [lldb] Mark several tests as not dependent on debug info

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

These all seem fine to me...




Comment at: 
lldb/packages/Python/lldbsuite/test/commands/gui/basic/TestGuiBasic.py:13
 mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
 

This shouldn't be needed as all `PExpectTest`s set this by default...



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py:18
 mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
 

duplicate annotation


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72447



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


[Lldb-commits] [PATCH] D71770: [lldb] Don't process symlinks deep inside DWARFUnit

2020-01-09 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 237076.
labath added a comment.

Use a slightly different approach as the previous one didn't work on macos (the
reason for that is that each .o file gets a separate module -- the patch
populated the path map of the .o modules, but the remapping was being done by
the main module).

In this version I move the remapping code from SymbolFileDWARF into generic
code. I think this makes sense as the /proc/self/cwd trick is not really
specific to DWARF. It can be used e.g. with clang-cl and PDBs too (if
cross-compiling on a platform which supports symbolic links).

A small behavioral change here is that in order for a change in the setting
value to "kick in", one has to change it before the module gets created --
previously one could do it before debug info gets parsed. I don't think this is
particularly important as the only way to get reliable results was to change the
value before creating a target -- debug info parsing happens lazily, and a
pending breakpoing could cause it to get parsed immediately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71770

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Core/ModuleList.h
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/ModuleList.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
@@ -1,10 +1,6 @@
 include "../../../../include/lldb/Core/PropertiesBase.td"
 
 let Definition = "symbolfiledwarf" in {
-  def SymLinkPaths: Property<"comp-dir-symlink-paths", "FileSpecList">,
-Global,
-DefaultStringValue<"">,
-Desc<"If the DW_AT_comp_dir matches any of these paths the symbolic links will be resolved at DWARF parse time.">;
   def IgnoreIndexes: Property<"ignore-file-indexes", "Boolean">,
 Global,
 DefaultFalse,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -90,8 +90,6 @@
   static lldb_private::SymbolFile *
   CreateInstance(lldb::ObjectFileSP objfile_sp);
 
-  static lldb_private::FileSpecList GetSymlinkPaths();
-
   // Constructors and Destructors
 
   SymbolFileDWARF(lldb::ObjectFileSP objfile_sp,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -135,14 +135,6 @@
 m_collection_sp->Initialize(g_symbolfiledwarf_properties);
   }
 
-  FileSpecList GetSymLinkPaths() {
-const OptionValueFileSpecList *option_value =
-m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(
-nullptr, true, ePropertySymLinkPaths);
-assert(option_value);
-return option_value->GetCurrentValue();
-  }
-
   bool IgnoreFileIndexes() const {
 return m_collection_sp->GetPropertyAtIndexAsBoolean(
 nullptr, ePropertyIgnoreIndexes, false);
@@ -227,10 +219,6 @@
   return support_files;
 }
 
-FileSpecList SymbolFileDWARF::GetSymlinkPaths() {
-  return GetGlobalPluginProperties()->GetSymLinkPaths();
-}
-
 void SymbolFileDWARF::Initialize() {
   LogChannelDWARF::Initialize();
   PluginManager::RegisterPlugin(GetPluginNameStatic(),
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -738,25 +738,6 @@
   return path;
 }
 
-static FileSpec resolveCompDir(const FileSpec &path) {
-  bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex(
-0, path, /*full*/ true) != UINT32_MAX;
-
-  if (!is_symlink)
-return path;
-
-  namespace fs = llvm::sys::fs;
-  if (fs::get_file_type(path.GetPath(), false) != fs::file_type::symlink_file)
-return path;
-
-  FileSpec resolved_symlink;
-  const auto error = FileSystem::Instance().Readlink(path, resolved_symlink);
-  if (error.Success())
-return resolved_symlink;
-
-  return path;
-}
-
 void DWARFUnit::ComputeCompDirAndGues

[Lldb-commits] [PATCH] D71770: [lldb] Don't process symlinks deep inside DWARFUnit

2020-01-09 Thread Pavel Labath via Phabricator via lldb-commits
labath requested review of this revision.
labath edited reviewers, added: jingham; removed: jdoerfert.
labath added a comment.
Herald added a reviewer: jdoerfert.

Re-requesting review, as this is essentially a different patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71770



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


[Lldb-commits] [PATCH] D71905: [lldb][tests] Take into account all parent's categories when traverse folders upwards

2020-01-09 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 237079.
tatyana-krasnukha added a comment.

Stop iterating when reach the top-level test folder


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71905

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


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -106,9 +106,8 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
-at the top level directory so we do not end up looping endlessly.
+collecting values of ".categories" files. We start at the folder the 
test is in
+and traverse the hierarchy upwards until the test-suite root directory.
 """
 import inspect
 import os.path
@@ -120,20 +119,22 @@
 start_path = inspect.getfile(test.__class__)
 
 folder = os.path.dirname(start_path)
-while folder != '/':
+
+from lldbsuite import lldb_test_root as test_root
+if test_root != os.path.commonprefix([folder, test_root]):
+raise Exception("The test file %s is outside the test root 
directory" % start_path)
+
+categories = set()
+while not os.path.samefile(folder, test_root):
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
-raise Exception("Did not find a .categories file, starting at: %s" % 
start_path)
+categories.update(categories_str.split(','))
+folder = os.path.dirname(folder)
 
+return list(categories)
 
 def getCategoriesForTest(self, test):
 """


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -106,9 +106,8 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
-at the top level directory so we do not end up looping endlessly.
+collecting values of ".categories" files. We start at the folder the test is in
+and traverse the hierarchy upwards until the test-suite root directory.
 """
 import inspect
 import os.path
@@ -120,20 +119,22 @@
 start_path = inspect.getfile(test.__class__)
 
 folder = os.path.dirname(start_path)
-while folder != '/':
+
+from lldbsuite import lldb_test_root as test_root
+if test_root != os.path.commonprefix([folder, test_root]):
+raise Exception("The test file %s is outside the test root directory" % start_path)
+
+categories = set()
+while not os.path.samefile(folder, test_root):
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
-raise Exception("Did not find a .categories file, starting at: %s" % start_path)
+categories.update(categories_str.split(','))
+folder = os.path.dirname(folder)
 
+return list(categories)
 
 def getCategoriesForTest(self, test):
 """
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://l

[Lldb-commits] [PATCH] D72437: [lldb/Bindings] Move bindings into their own subdirectory

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

In D72437#1811474 , @labath wrote:

> I think this is a great idea. I'm not convinced of the need to pluralize 
> "interfaces" (header files are in "include", even though that folder usually 
> contains more than one file), but I don't care much either way...


Good point, I didn't consider the `header` analogy, let's keep it singular.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72437



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


[Lldb-commits] [PATCH] D71825: [lldb/Lua] Support loading Lua modules.

2020-01-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 237088.
JDevlieghere added a comment.

- Remove unused dense map.
- Set the global variable.


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

https://reviews.llvm.org/D71825

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/test/Shell/ScriptInterpreter/Lua/Inputs/testmodule.lua
  lldb/test/Shell/ScriptInterpreter/Lua/command_script_import.test

Index: lldb/test/Shell/ScriptInterpreter/Lua/command_script_import.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/command_script_import.test
@@ -0,0 +1,3 @@
+# REQUIRES: lua
+# RUN: %lldb --script-language lua -o 'command script import %S/Inputs/testmodule.lua' -o 'script testmodule.foo()' 2>&1 | FileCheck %s
+# CHECK: Hello World!
Index: lldb/test/Shell/ScriptInterpreter/Lua/Inputs/testmodule.lua
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/Inputs/testmodule.lua
@@ -0,0 +1,7 @@
+local mymodule = {}
+
+function mymodule.foo()
+  print("Hello World!")
+end
+
+return mymodule
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -25,6 +25,11 @@
 
   void ExecuteInterpreterLoop() override;
 
+  virtual bool
+  LoadScriptingModule(const char *filename, bool init_session,
+  lldb_private::Status &error,
+  StructuredData::ObjectSP *module_sp = nullptr) override;
+
   // Static Functions
   static void Initialize();
 
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -77,6 +77,18 @@
   debugger.PushIOHandler(io_handler_sp);
 }
 
+bool ScriptInterpreterLua::LoadScriptingModule(
+const char *filename, bool init_session, lldb_private::Status &error,
+StructuredData::ObjectSP *module_sp) {
+
+  if (llvm::Error e = m_lua->LoadModule(filename)) {
+error.SetErrorStringWithFormatv("lua failed to import '{0}': {1}\n",
+filename, llvm::toString(std::move(e)));
+return false;
+  }
+  return true;
+}
+
 void ScriptInterpreterLua::Initialize() {
   static llvm::once_flag g_once_flag;
 
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -36,8 +36,10 @@
   }
 
   llvm::Error Run(llvm::StringRef buffer);
+  llvm::Error LoadModule(llvm::StringRef filename);
 
 private:
+  llvm::Expected FormatQuoted(llvm::StringRef str);
   std::mutex m_mutex;
   lua_State *m_lua_state;
 };
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include "Lua.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/FileSpec.h"
 #include "llvm/Support/FormatVariadic.h"
 
 using namespace lldb_private;
@@ -26,3 +28,32 @@
   lua_pop(m_lua_state, 1);
   return e;
 }
+
+llvm::Error Lua::LoadModule(llvm::StringRef filename) {
+  FileSpec file(filename);
+  if (!FileSystem::Instance().Exists(file)) {
+return llvm::make_error("invalid path",
+   llvm::inconvertibleErrorCode());
+  }
+
+  ConstString module_extension = file.GetFileNameExtension();
+  if (module_extension != ".lua") {
+return llvm::make_error("invalid extension",
+   llvm::inconvertibleErrorCode());
+  }
+
+  int error = luaL_loadfile(m_lua_state, filename.data()) ||
+  lua_pcall(m_lua_state, 0, LUA_MULTRET, 0);
+  if (error) {
+llvm::Error e = llvm::make_error(
+llvm::formatv("{0}\n", lua_tostring(m_lua_state, -1)),
+llvm::inconvertibleErrorCode());
+// Pop error message from the stack.
+lua_pop(m_lua_state, 1);
+return e;
+  }
+
+  ConstString module_name = file.GetFileNameStrippingExtension();
+  lua_setglobal(m_lua_state, module_name.GetCString());
+  return llvm::Error::success();
+}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https:

[Lldb-commits] [PATCH] D71825: [lldb/Lua] Support loading Lua modules.

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

In D71825#1811587 , @labath wrote:

> Now back to the current patch: I see that you've dropped the part which 
> assigns the result of evaluating the module to a global variable (and 
> consequently, dropped the "local" keyword from the "mymodule" declaration). 
> That seems unfortunate, as the recommended way for writing modules is to make 
> the variable local, and return the module as a result.
>
> What's the reasoning behind that? I was expecting we would keep that part... 
> All it would take is adding an extra `lua_setglobal(m_lua_state, name)` call 
> after the `pcall` stuff.


Thanks! I couldn't get it to work yesterday evening because I was vastly 
overthinking it after looking at the package implementation and getting 
sidetracked by the meta table. I thought the runtime was doing some magic which 
I didn't fully understand and that made me overlook the stupidly simply 
solution of using using the result as a global...


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

https://reviews.llvm.org/D71825



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


[Lldb-commits] [lldb] 93a1e9c - [lldb/SWIG] Add missing '\' in macros again

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

Author: Jonas Devlieghere
Date: 2020-01-09T08:15:41-08:00
New Revision: 93a1e9c90c96a9130352bf358df0379ebb48

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

LOG: [lldb/SWIG] Add missing '\' in macros again

Making the string conversion operator a macro unintentionally dropped
the backslash before '\n' and '\r' and was therefore incorrectly
stripping 'n' and 'r' from the object description.

Added: 


Modified: 
lldb/scripts/macros.swig

Removed: 




diff  --git a/lldb/scripts/macros.swig b/lldb/scripts/macros.swig
index e0756c2f1793..0387f27f3cb9 100644
--- a/lldb/scripts/macros.swig
+++ b/lldb/scripts/macros.swig
@@ -6,7 +6,7 @@
 $self->GetDescription (stream, Level);
 const char *desc = stream.GetData();
 size_t desc_len = stream.GetSize();
-if (desc_len > 0 && (desc[desc_len-1] == 'n' || desc[desc_len-1] == 'r')) {
+if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == 
'\r')) {
   --desc_len;
 }
 return std::string(desc, desc_len);
@@ -23,7 +23,7 @@
 $self->GetDescription (stream);
 const char *desc = stream.GetData();
 size_t desc_len = stream.GetSize();
-if (desc_len > 0 && (desc[desc_len-1] == 'n' || desc[desc_len-1] == 'r')) {
+if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == 
'\r')) {
   --desc_len;
 }
 return std::string(desc, desc_len);



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


[Lldb-commits] [lldb] 45c971f - [lldb/Lua] Make lldb.debugger et al available to Lua

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

Author: Jonas Devlieghere
Date: 2020-01-09T08:15:41-08:00
New Revision: 45c971f7eef18ef2b77a5f64133dbd7bd5939d5f

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

LOG: [lldb/Lua] Make lldb.debugger et al available to Lua

The Python script interpreter makes the current debugger, target,
process, thread and frame available to interactive scripting sessions
through convenience variables. This patch does the same for Lua.

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

Added: 
lldb/test/Shell/ScriptInterpreter/Lua/Inputs/independent_state.in
lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions.in
lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions_2.in
lldb/test/Shell/ScriptInterpreter/Lua/convenience_variables.test
lldb/test/Shell/ScriptInterpreter/Lua/independent_state.test
lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test

Modified: 
lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h

Removed: 




diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
index dc64139fa4e5..1dd0a9eade0c 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -10,9 +10,9 @@
 #include "llvm/Support/FormatVariadic.h"
 
 using namespace lldb_private;
+using namespace lldb;
 
 llvm::Error Lua::Run(llvm::StringRef buffer) {
-  std::lock_guard lock(m_mutex);
   int error =
   luaL_loadbuffer(m_lua_state, buffer.data(), buffer.size(), "buffer") ||
   lua_pcall(m_lua_state, 0, 0, 0);

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
index ed1d159590ac..adc6c6118436 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_Lua_h_
 #define liblldb_Lua_h_
 
+#include "lldb/lldb-types.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
@@ -38,7 +39,6 @@ class Lua {
   llvm::Error Run(llvm::StringRef buffer);
 
 private:
-  std::mutex m_mutex;
   lua_State *m_lua_state;
 };
 

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
index d5423b78b8c4..e46851c45092 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -27,7 +27,13 @@ class IOHandlerLuaInterpreter : public IOHandlerDelegate,
   : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
   ">>> ", "..> ", true, debugger.GetUseColor(), 0,
   *this, nullptr),
-m_script_interpreter(script_interpreter) {}
+m_script_interpreter(script_interpreter) {
+llvm::cantFail(m_script_interpreter.EnterSession(debugger.GetID()));
+  }
+
+  ~IOHandlerLuaInterpreter() {
+llvm::cantFail(m_script_interpreter.LeaveSession());
+  }
 
   void IOHandlerInputComplete(IOHandler &io_handler,
   std::string &data) override {
@@ -89,6 +95,33 @@ void ScriptInterpreterLua::Initialize() {
 
 void ScriptInterpreterLua::Terminate() {}
 
+llvm::Error ScriptInterpreterLua::EnterSession(user_id_t debugger_id) {
+  if (m_session_is_active)
+return llvm::Error::success();
+
+  const char *fmt_str =
+  "lldb.debugger = lldb.SBDebugger.FindDebuggerWithID({0}); "
+  "lldb.target = lldb.debugger:GetSelectedTarget(); "
+  "lldb.process = lldb.target:GetProcess(); "
+  "lldb.thread = lldb.process:GetSelectedThread(); "
+  "lldb.frame = lldb.thread:GetSelectedFrame()";
+  return m_lua->Run(llvm::formatv(fmt_str, debugger_id).str());
+}
+
+llvm::Error ScriptInterpreterLua::LeaveSession() {
+  if (!m_session_is_active)
+return llvm::Error::success();
+
+  m_session_is_active = false;
+
+  llvm::StringRef str = "lldb.debugger = nil; "
+"lldb.target = nil; "
+"lldb.process = nil; "
+"lldb.thread = nil; "
+"lldb.frame = nil";
+  return m_lua->Run(str);
+}
+
 lldb::ScriptInterpreterSP
 ScriptInterpreterLua::CreateInstance(Debugger &debugger) {
   return std::make_shared(debugger);

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h 
b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
index b34c7d0e8217..550e1035567c 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpr

[Lldb-commits] [PATCH] D71801: [lldb/Lua] Make lldb.debugger et al available to Lua

2020-01-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45c971f7eef1: [lldb/Lua] Make lldb.debugger et al available 
to Lua (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D71801?vs=236846&id=237093#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71801

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/test/Shell/ScriptInterpreter/Lua/Inputs/independent_state.in
  lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions.in
  lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions_2.in
  lldb/test/Shell/ScriptInterpreter/Lua/convenience_variables.test
  lldb/test/Shell/ScriptInterpreter/Lua/independent_state.test
  lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test

Index: lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test
@@ -0,0 +1,12 @@
+# REQUIRES: lua
+# RUN: mkdir -p %t
+# RUN: echo "int main() { return 0; }" | %clang_host -x c - -o %t/foo
+# RUN: echo "int main() { return 0; }" | %clang_host -x c - -o %t/bar
+# RUN:  %lldb --script-language lua -o "file %t/bar" -o "file %t/foo" -s %S/Inputs/nested_sessions.in  -s %S/Inputs/nested_sessions_2.in 2>&1 | FileCheck %s
+# CHECK: script
+# CHECK-NEXT: foo foo
+# CHECK-NEXT: foo bar
+# CHECK-NEXT: foo bar
+# CHECK-NEXT: foo bar
+# CHECK: script
+# CHECK-NEXT: bar bar
Index: lldb/test/Shell/ScriptInterpreter/Lua/independent_state.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/independent_state.test
@@ -0,0 +1,6 @@
+# REQUIRES: lua
+#
+# RUN:  %lldb --script-language lua -s %S/Inputs/independent_state.in 2>&1 | FileCheck %s
+# CHECK: 47
+# CHECK: 47
+# CHECK: 42
Index: lldb/test/Shell/ScriptInterpreter/Lua/convenience_variables.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/convenience_variables.test
@@ -0,0 +1,17 @@
+# REQUIRES: lua
+#
+# This tests that the convenience variables are not nil. Given that there is no
+# target we only expect the debugger to be valid.
+#
+# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
+script
+print(string.format("lldb.debugger is valid: %s", lldb.debugger:IsValid()))
+print(string.format("lldb.target is valid: %s", lldb.target:IsValid()))
+print(string.format("lldb.process is valid: %s", lldb.process:IsValid()))
+print(string.format("lldb.thread is valid: %s", lldb.thread:IsValid()))
+print(string.format("lldb.frame is valid: %s", lldb.frame:IsValid()))
+# CHECK: debugger is valid: true
+# CHECK: target is valid: false
+# CHECK: process is valid: false
+# CHECK: thread is valid: false
+# CHECK: frame is valid: false
Index: lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions_2.in
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions_2.in
@@ -0,0 +1,2 @@
+script
+print(lldb.target, lldb.debugger:GetSelectedTarget())
Index: lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions.in
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/Inputs/nested_sessions.in
@@ -0,0 +1,6 @@
+script
+print(lldb.target, lldb.debugger:GetSelectedTarget())
+lldb.debugger:SetSelectedTarget(lldb.debugger:GetTargetAtIndex(0))
+print(lldb.target, lldb.debugger:GetSelectedTarget())
+lldb.debugger:HandleCommand("script print(lldb.target, lldb.debugger:GetSelectedTarget())")
+print(lldb.target, lldb.debugger:GetSelectedTarget())
Index: lldb/test/Shell/ScriptInterpreter/Lua/Inputs/independent_state.in
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/Inputs/independent_state.in
@@ -0,0 +1,6 @@
+script foobar = 40 + 7
+script print(foobar)
+script d = lldb.SBDebugger.Create()
+script d:HandleCommand("script foobar = 40 + 2")
+script print(foobar)
+script d:HandleCommand("script print(foobar)")
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -43,8 +43,12 @@
 
   Lua &GetLua();
 
+  llvm::Error EnterSession(lldb::user_id_t debugger_id);
+  llvm::Error LeaveSession();
+
 private:
   std::unique_ptr m_lua;
+  bool m_session_is_active = false;
 };
 
 } // namespace lldb_private
Index: lldb/s

[Lldb-commits] [lldb] 6498aff - [lldb/Bindings] Move bindings into their own subdirectory

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

Author: Jonas Devlieghere
Date: 2020-01-09T08:44:34-08:00
New Revision: 6498aff249a1c3c6bad33137df3b90e2973722d6

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

LOG: [lldb/Bindings] Move bindings into their own subdirectory

All the code required to generate the language bindings for Python and
Lua lives under scripts, even though the majority of this code aren't
scripts at all, and surrounded by scripts that are totally unrelated.

I've reorganized these files and moved everything related to the
language bindings into a new top-level directory named bindings. This
makes the corresponding files self contained and much more discoverable.

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

Added: 
lldb/bindings/CMakeLists.txt
lldb/bindings/headers.swig
lldb/bindings/interface/SBAddress.i
lldb/bindings/interface/SBAttachInfo.i
lldb/bindings/interface/SBBlock.i
lldb/bindings/interface/SBBreakpoint.i
lldb/bindings/interface/SBBreakpointLocation.i
lldb/bindings/interface/SBBreakpointName.i
lldb/bindings/interface/SBBroadcaster.i
lldb/bindings/interface/SBCommandInterpreter.i
lldb/bindings/interface/SBCommandReturnObject.i
lldb/bindings/interface/SBCommunication.i
lldb/bindings/interface/SBCompileUnit.i
lldb/bindings/interface/SBData.i
lldb/bindings/interface/SBDebugger.i
lldb/bindings/interface/SBDeclaration.i
lldb/bindings/interface/SBError.i
lldb/bindings/interface/SBEvent.i
lldb/bindings/interface/SBExecutionContext.i
lldb/bindings/interface/SBExpressionOptions.i
lldb/bindings/interface/SBFile.i
lldb/bindings/interface/SBFileSpec.i
lldb/bindings/interface/SBFileSpecList.i
lldb/bindings/interface/SBFrame.i
lldb/bindings/interface/SBFunction.i
lldb/bindings/interface/SBHostOS.i
lldb/bindings/interface/SBInstruction.i
lldb/bindings/interface/SBInstructionList.i
lldb/bindings/interface/SBLanguageRuntime.i
lldb/bindings/interface/SBLaunchInfo.i
lldb/bindings/interface/SBLineEntry.i
lldb/bindings/interface/SBListener.i
lldb/bindings/interface/SBMemoryRegionInfo.i
lldb/bindings/interface/SBMemoryRegionInfoList.i
lldb/bindings/interface/SBModule.i
lldb/bindings/interface/SBModuleSpec.i
lldb/bindings/interface/SBPlatform.i
lldb/bindings/interface/SBProcess.i
lldb/bindings/interface/SBProcessInfo.i
lldb/bindings/interface/SBQueue.i
lldb/bindings/interface/SBQueueItem.i
lldb/bindings/interface/SBSection.i
lldb/bindings/interface/SBSourceManager.i
lldb/bindings/interface/SBStream.i
lldb/bindings/interface/SBStringList.i
lldb/bindings/interface/SBStructuredData.i
lldb/bindings/interface/SBSymbol.i
lldb/bindings/interface/SBSymbolContext.i
lldb/bindings/interface/SBSymbolContextList.i
lldb/bindings/interface/SBTarget.i
lldb/bindings/interface/SBThread.i
lldb/bindings/interface/SBThreadCollection.i
lldb/bindings/interface/SBThreadPlan.i
lldb/bindings/interface/SBTrace.i
lldb/bindings/interface/SBTraceOptions.i
lldb/bindings/interface/SBType.i
lldb/bindings/interface/SBTypeCategory.i
lldb/bindings/interface/SBTypeEnumMember.i
lldb/bindings/interface/SBTypeFilter.i
lldb/bindings/interface/SBTypeFormat.i
lldb/bindings/interface/SBTypeNameSpecifier.i
lldb/bindings/interface/SBTypeSummary.i
lldb/bindings/interface/SBTypeSynthetic.i
lldb/bindings/interface/SBUnixSignals.i
lldb/bindings/interface/SBValue.i
lldb/bindings/interface/SBValueList.i
lldb/bindings/interface/SBVariablesOptions.i
lldb/bindings/interface/SBWatchpoint.i
lldb/bindings/interfaces.swig
lldb/bindings/lua.swig
lldb/bindings/macros.swig
lldb/bindings/python.swig
lldb/bindings/python/createPythonInit.py
lldb/bindings/python/python-extensions.swig
lldb/bindings/python/python-swigsafecast.swig
lldb/bindings/python/python-typemaps.swig
lldb/bindings/python/python-wrapper.swig

Modified: 
lldb/CMakeLists.txt
lldb/docs/CMakeLists.txt
lldb/source/API/CMakeLists.txt

Removed: 
lldb/scripts/CMakeLists.txt
lldb/scripts/Python/createPythonInit.py
lldb/scripts/Python/python-extensions.swig
lldb/scripts/Python/python-swigsafecast.swig
lldb/scripts/Python/python-typemaps.swig
lldb/scripts/Python/python-wrapper.swig
lldb/scripts/headers.swig
lldb/scripts/interface/SBAddress.i
lldb/scripts/interface/SBAttachInfo.i
lldb/scripts/interface/SBBlock.i
lldb/scripts/interface/SBBreakpoint.i
lldb/scripts/interface/SBBreakpointLocation.i
lldb/scripts/interface/SBBreakpointName.i
lldb/scripts/interface/SBBroadcaster.i
lldb/scripts/interface/SBCommandInterpreter.i
lldb/scripts/interface/SBCommandReturnObject.i
lldb/scripts/interface/SBCommunication.i
lldb/scrip

[Lldb-commits] [PATCH] D72460: RangeDataVector: Support custom sorting for D63540

2020-01-09 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: labath.
jankratochvil added a project: LLDB.
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.
jankratochvil added a child revision: D63540: Fix lookup of symbols with the 
same address range but different binding.



Comment at: lldb/include/lldb/Utility/RangeMap.h:602
   RangeData(B base, S size, DataType d) : Range(base, size), data(d) {}
-
-  bool operator<(const RangeData &rhs) const {
-if (this->base == rhs.base) {
-  if (this->size == rhs.size)
-return this->data < rhs.data;
-  else
-return this->size < rhs.size;
-}
-return this->base < rhs.base;
-  }
-
-  bool operator==(const RangeData &rhs) const {
-return this->GetRangeBase() == rhs.GetRangeBase() &&
-   this->GetByteSize() == rhs.GetByteSize() && this->data == rhs.data;
-  }
-
-  bool operator!=(const RangeData &rhs) const {
-return this->GetRangeBase() != rhs.GetRangeBase() ||
-   this->GetByteSize() != rhs.GetByteSize() || this->data != rhs.data;
-  }
 };
 

These functions were used just by `RangeDataVector` (=after I removed them LLDB 
still builds fine) which no longer uses them so I removed them.



As suggested by @labath extended RangeDataVector so that user can provide 
custom sorting of the `Entry`'s `data' field.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72460

Files:
  lldb/include/lldb/Utility/RangeMap.h
  lldb/unittests/Utility/RangeMapTest.cpp

Index: lldb/unittests/Utility/RangeMapTest.cpp
===
--- lldb/unittests/Utility/RangeMapTest.cpp
+++ lldb/unittests/Utility/RangeMapTest.cpp
@@ -52,3 +52,45 @@
   // TODO: This should probably return the range (0, 40) as well.
   EXPECT_THAT(Map.FindEntryThatContains(35), nullptr);
 }
+
+TEST(RangeDataVector, CustomSort) {
+  // First the default ascending order sorting of the data field.
+  auto Map = RangeDataVectorT();
+  Map.Append(EntryT(0, 10, 50));
+  Map.Append(EntryT(0, 10, 52));
+  Map.Append(EntryT(0, 10, 53));
+  Map.Append(EntryT(0, 10, 51));
+  Map.Sort();
+
+  EXPECT_THAT(Map.GetSize(), 4);
+  EXPECT_THAT(Map.GetEntryRef(0).data, 50);
+  EXPECT_THAT(Map.GetEntryRef(1).data, 51);
+  EXPECT_THAT(Map.GetEntryRef(2).data, 52);
+  EXPECT_THAT(Map.GetEntryRef(3).data, 53);
+
+  // And then a custom descending order sorting of the data field.
+  class CtorParam {};
+  class CustomSort {
+  public:
+CustomSort(CtorParam) {}
+bool operator()(const uint32_t a_data, const uint32_t b_data) {
+  return a_data > b_data;
+}
+  };
+  using RangeDataVectorCustomSortT =
+  RangeDataVector;
+  using EntryT = RangeDataVectorT::Entry;
+
+  auto MapC = RangeDataVectorCustomSortT(CtorParam());
+  MapC.Append(EntryT(0, 10, 50));
+  MapC.Append(EntryT(0, 10, 52));
+  MapC.Append(EntryT(0, 10, 53));
+  MapC.Append(EntryT(0, 10, 51));
+  MapC.Sort();
+
+  EXPECT_THAT(MapC.GetSize(), 4);
+  EXPECT_THAT(MapC.GetEntryRef(0).data, 53);
+  EXPECT_THAT(MapC.GetEntryRef(1).data, 52);
+  EXPECT_THAT(MapC.GetEntryRef(2).data, 51);
+  EXPECT_THAT(MapC.GetEntryRef(3).data, 50);
+}
Index: lldb/include/lldb/Utility/RangeMap.h
===
--- lldb/include/lldb/Utility/RangeMap.h
+++ lldb/include/lldb/Utility/RangeMap.h
@@ -599,36 +599,17 @@
   RangeData(B base, S size) : Range(base, size), data() {}
 
   RangeData(B base, S size, DataType d) : Range(base, size), data(d) {}
-
-  bool operator<(const RangeData &rhs) const {
-if (this->base == rhs.base) {
-  if (this->size == rhs.size)
-return this->data < rhs.data;
-  else
-return this->size < rhs.size;
-}
-return this->base < rhs.base;
-  }
-
-  bool operator==(const RangeData &rhs) const {
-return this->GetRangeBase() == rhs.GetRangeBase() &&
-   this->GetByteSize() == rhs.GetByteSize() && this->data == rhs.data;
-  }
-
-  bool operator!=(const RangeData &rhs) const {
-return this->GetRangeBase() != rhs.GetRangeBase() ||
-   this->GetByteSize() != rhs.GetByteSize() || this->data != rhs.data;
-  }
 };
 
-template 
+template >
 class RangeDataVector {
 public:
   typedef lldb_private::Range Range;
   typedef RangeData Entry;
   typedef llvm::SmallVector Collection;
 
-  RangeDataVector() = default;
+  RangeDataVector(Compare compare = Compare()) : m_compare(compare) {}
 
   ~RangeDataVector() = default;
 
@@ -636,7 +617,14 @@
 
   void Sort() {
 if (m_entries.size() > 1)
-  std::stable_sort(m_entries.begin(), m_entries.end());
+  std::stable_sort(m_entries.begin(), m_entries.end(),
+   [&compare = m_compare](const Entry &a, const Entry &b) {
+ if (a.base != b.base)
+   return a.base < b.base;
+ if (a.size != b.size)
+   return a.s

[Lldb-commits] [PATCH] D72460: RangeDataVector: Support custom sorting for D63540

2020-01-09 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: lldb/include/lldb/Utility/RangeMap.h:602
   RangeData(B base, S size, DataType d) : Range(base, size), data(d) {}
-
-  bool operator<(const RangeData &rhs) const {
-if (this->base == rhs.base) {
-  if (this->size == rhs.size)
-return this->data < rhs.data;
-  else
-return this->size < rhs.size;
-}
-return this->base < rhs.base;
-  }
-
-  bool operator==(const RangeData &rhs) const {
-return this->GetRangeBase() == rhs.GetRangeBase() &&
-   this->GetByteSize() == rhs.GetByteSize() && this->data == rhs.data;
-  }
-
-  bool operator!=(const RangeData &rhs) const {
-return this->GetRangeBase() != rhs.GetRangeBase() ||
-   this->GetByteSize() != rhs.GetByteSize() || this->data != rhs.data;
-  }
 };
 

These functions were used just by `RangeDataVector` (=after I removed them LLDB 
still builds fine) which no longer uses them so I removed them.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72460



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


[Lldb-commits] [PATCH] D72437: [lldb/Bindings] Move bindings into their own subdirectory

2020-01-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6498aff249a1: [lldb/Bindings] Move bindings into their own 
subdirectory (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D72437?vs=236968&id=237102#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72437

Files:
  lldb/CMakeLists.txt
  lldb/bindings/CMakeLists.txt
  lldb/bindings/headers.swig
  lldb/bindings/interface/SBAddress.i
  lldb/bindings/interface/SBAttachInfo.i
  lldb/bindings/interface/SBBlock.i
  lldb/bindings/interface/SBBreakpoint.i
  lldb/bindings/interface/SBBreakpointLocation.i
  lldb/bindings/interface/SBBreakpointName.i
  lldb/bindings/interface/SBBroadcaster.i
  lldb/bindings/interface/SBCommandInterpreter.i
  lldb/bindings/interface/SBCommandReturnObject.i
  lldb/bindings/interface/SBCommunication.i
  lldb/bindings/interface/SBCompileUnit.i
  lldb/bindings/interface/SBData.i
  lldb/bindings/interface/SBDebugger.i
  lldb/bindings/interface/SBDeclaration.i
  lldb/bindings/interface/SBError.i
  lldb/bindings/interface/SBEvent.i
  lldb/bindings/interface/SBExecutionContext.i
  lldb/bindings/interface/SBExpressionOptions.i
  lldb/bindings/interface/SBFile.i
  lldb/bindings/interface/SBFileSpec.i
  lldb/bindings/interface/SBFileSpecList.i
  lldb/bindings/interface/SBFrame.i
  lldb/bindings/interface/SBFunction.i
  lldb/bindings/interface/SBHostOS.i
  lldb/bindings/interface/SBInstruction.i
  lldb/bindings/interface/SBInstructionList.i
  lldb/bindings/interface/SBLanguageRuntime.i
  lldb/bindings/interface/SBLaunchInfo.i
  lldb/bindings/interface/SBLineEntry.i
  lldb/bindings/interface/SBListener.i
  lldb/bindings/interface/SBMemoryRegionInfo.i
  lldb/bindings/interface/SBMemoryRegionInfoList.i
  lldb/bindings/interface/SBModule.i
  lldb/bindings/interface/SBModuleSpec.i
  lldb/bindings/interface/SBPlatform.i
  lldb/bindings/interface/SBProcess.i
  lldb/bindings/interface/SBProcessInfo.i
  lldb/bindings/interface/SBQueue.i
  lldb/bindings/interface/SBQueueItem.i
  lldb/bindings/interface/SBSection.i
  lldb/bindings/interface/SBSourceManager.i
  lldb/bindings/interface/SBStream.i
  lldb/bindings/interface/SBStringList.i
  lldb/bindings/interface/SBStructuredData.i
  lldb/bindings/interface/SBSymbol.i
  lldb/bindings/interface/SBSymbolContext.i
  lldb/bindings/interface/SBSymbolContextList.i
  lldb/bindings/interface/SBTarget.i
  lldb/bindings/interface/SBThread.i
  lldb/bindings/interface/SBThreadCollection.i
  lldb/bindings/interface/SBThreadPlan.i
  lldb/bindings/interface/SBTrace.i
  lldb/bindings/interface/SBTraceOptions.i
  lldb/bindings/interface/SBType.i
  lldb/bindings/interface/SBTypeCategory.i
  lldb/bindings/interface/SBTypeEnumMember.i
  lldb/bindings/interface/SBTypeFilter.i
  lldb/bindings/interface/SBTypeFormat.i
  lldb/bindings/interface/SBTypeNameSpecifier.i
  lldb/bindings/interface/SBTypeSummary.i
  lldb/bindings/interface/SBTypeSynthetic.i
  lldb/bindings/interface/SBUnixSignals.i
  lldb/bindings/interface/SBValue.i
  lldb/bindings/interface/SBValueList.i
  lldb/bindings/interface/SBVariablesOptions.i
  lldb/bindings/interface/SBWatchpoint.i
  lldb/bindings/interfaces.swig
  lldb/bindings/lua.swig
  lldb/bindings/macros.swig
  lldb/bindings/python.swig
  lldb/bindings/python/createPythonInit.py
  lldb/bindings/python/python-extensions.swig
  lldb/bindings/python/python-swigsafecast.swig
  lldb/bindings/python/python-typemaps.swig
  lldb/bindings/python/python-wrapper.swig
  lldb/docs/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/Python/createPythonInit.py
  lldb/scripts/Python/python-extensions.swig
  lldb/scripts/Python/python-swigsafecast.swig
  lldb/scripts/Python/python-typemaps.swig
  lldb/scripts/Python/python-wrapper.swig
  lldb/scripts/headers.swig
  lldb/scripts/interface/SBAddress.i
  lldb/scripts/interface/SBAttachInfo.i
  lldb/scripts/interface/SBBlock.i
  lldb/scripts/interface/SBBreakpoint.i
  lldb/scripts/interface/SBBreakpointLocation.i
  lldb/scripts/interface/SBBreakpointName.i
  lldb/scripts/interface/SBBroadcaster.i
  lldb/scripts/interface/SBCommandInterpreter.i
  lldb/scripts/interface/SBCommandReturnObject.i
  lldb/scripts/interface/SBCommunication.i
  lldb/scripts/interface/SBCompileUnit.i
  lldb/scripts/interface/SBData.i
  lldb/scripts/interface/SBDebugger.i
  lldb/scripts/interface/SBDeclaration.i
  lldb/scripts/interface/SBError.i
  lldb/scripts/interface/SBEvent.i
  lldb/scripts/interface/SBExecutionContext.i
  lldb/scripts/interface/SBExpressionOptions.i
  lldb/scripts/interface/SBFile.i
  lldb/scripts/interface/SBFileSpec.i
  lldb/scripts/interface/SBFileSpecList.i
  lldb/scripts/interface/SBFrame.i
  lldb/scripts/interface/SBFunction.i
  lldb/scripts/interface/SBHostOS.i
  lldb/scripts/interface/SBInstruction.i
  lldb/scripts/interface/SBInstructionList.i
  lldb/scripts/interface/SBLanguageRuntime.i
  lldb/scripts/interfa

[Lldb-commits] [PATCH] D63540: Fix lookup of symbols with the same address range but different binding

2020-01-09 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D63540#1809725 , @labath wrote:

> - make the RangeMap constructor take a `const Compare &` instead of a 
> template pack. The std containers do the same, and I don't see a reason to 
> diverge..


Done. I have mistaken it as optimization but that does not apply in this case.

> - make Compare operate only on the "data" field of the map. The RangeMap 
> methods assume the entries are sorted in a certain way, so changing that in 
> the comparator does not seem useful. The std::sort call can take a lambda or 
> something to first compare the ranges and then the data fields...
> 
>   It might also be nice to split this off into a separate patch with a unit 
> test and all...

Done in D72460 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63540



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


[Lldb-commits] [PATCH] D63540: Fix lookup of symbols with the same address range but different binding

2020-01-09 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 237103.
jankratochvil added a comment.

This patch is now on top of D72460 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63540

Files:
  lldb/include/lldb/Symbol/Symtab.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Symbol/Symtab.cpp
  lldb/test/Shell/SymbolFile/Inputs/symbol-binding.s
  lldb/test/Shell/SymbolFile/symbol-binding.test

Index: lldb/test/Shell/SymbolFile/symbol-binding.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/symbol-binding.test
@@ -0,0 +1,22 @@
+# Some targets do not have the .size directive.
+# RUN: %clang -target x86_64-unknown-unknown-elf %S/Inputs/symbol-binding.s -c -o %t.o
+# RUN: %lldb %t.o -s %s -o quit | FileCheck %s
+
+image lookup --address 4
+# CHECK: Summary: symbol-binding.test.tmp.o`case1_global
+image lookup --address 5
+# CHECK: Summary: symbol-binding.test.tmp.o`case2_weak
+image lookup --address 6
+# CHECK: Summary: symbol-binding.test.tmp.o`case3_global
+image dump symtab
+# CHECK: Index   UserID DSX TypeFile Address/Value Load Address   Size   Flags  Name
+# CHECK-NEXT:--- -- --- --- -- -- -- -- --
+# CHECK-NEXT:[0]  1 Code0x00040x0001 0x case1_local
+# CHECK-NEXT:[1]  2 Code0x00050x0001 0x case2_local
+# CHECK-NEXT:[2]  3 Code0x00030x0001 0x sizeend
+# CHECK-NEXT:[3]  4 Code0x00010x0002 0x sizeful
+# CHECK-NEXT:[4]  5 Code0x00010x0002 0x sizeless
+# CHECK-NEXT:[5]  6   X Code0x00040x0001 0x0010 case1_global
+# CHECK-NEXT:[6]  7 Code0x00050x0001 0x0020 case2_weak
+# CHECK-NEXT:[7]  8   X Code0x00060x0001 0x0010 case3_global
+# CHECK-NEXT:[8]  9 Code0x00060x0001 0x0020 case3_weak
Index: lldb/test/Shell/SymbolFile/Inputs/symbol-binding.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/Inputs/symbol-binding.s
@@ -0,0 +1,22 @@
+.text
+.byte   0
+sizeless:
+sizeful:
+.byte   0
+.byte   0
+sizeend:
+.size   sizeful, sizeend - sizeful
+.byte   0
+case1_local:
+case1_global:
+.globl  case1_global
+.byte   0
+case2_local:
+case2_weak:
+.weak   case2_weak
+.byte   0
+case3_weak:
+.weak   case3_weak
+case3_global:
+.globl  case3_global
+.byte   0
Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -28,7 +28,7 @@
 using namespace lldb_private;
 
 Symtab::Symtab(ObjectFile *objfile)
-: m_objfile(objfile), m_symbols(), m_file_addr_to_index(),
+: m_objfile(objfile), m_symbols(), m_file_addr_to_index(*this),
   m_name_to_index(), m_mutex(), m_file_addr_to_index_computed(false),
   m_name_indexes_computed(false) {}
 
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2258,6 +2258,8 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
+if (symbol.getBinding() == STB_WEAK)
+  dc_symbol.SetIsWeak(true);
 symtab->AddSymbol(dc_symbol);
   }
   return i;
Index: lldb/include/lldb/Symbol/Symtab.h
===
--- lldb/include/lldb/Symbol/Symtab.h
+++ lldb/include/lldb/Symbol/Symtab.h
@@ -143,7 +143,29 @@
   typedef std::vector collection;
   typedef collection::iterator iterator;
   typedef collection::const_iterator const_iterator;
-  typedef RangeDataVector
+  class FileRangeToIndexMapCompare {
+  public:
+FileRangeToIndexMapCompare(const Symtab &symtab) : m_symtab(symtab) {}
+bool operator()(const uint32_t a_data, const uint32_t b_data) const {
+  return rank(a_data) > rank(b_data);
+}
+
+  private:
+// How much preferr

[Lldb-commits] [PATCH] D70846: Expression eval lookup speedup by not returning methods in ManualDWARFIndex::GetFunctions

2020-01-09 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

In D70846#1809837 , @labath wrote:

> This looks fine to me. @shafik, @teemperor, do you have any more comments?


Just a minor comment.




Comment at: lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp:67
+
+// FULL: Found 0 functions:
 

You don't actually run a `FULL` test, is this purposeful? 


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

https://reviews.llvm.org/D70846



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


[Lldb-commits] [PATCH] D72447: [lldb] Mark several tests as not dependent on debug info

2020-01-09 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

I believe that all of these make sense.




Comment at: 
lldb/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py:12
 
 class Radar12481949DataFormatterTestCase(TestBase):
 

Do you think you could dig up that radar and rename this to something more 
meaningful?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72447



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


[Lldb-commits] [lldb] 5e0bf67 - [lldb/SWIG] Fix capitalization for case sensitive file systems.

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

Author: Jonas Devlieghere
Date: 2020-01-09T09:23:01-08:00
New Revision: 5e0bf6772e2ca450d3433fca8b47ce7bac5a6cc7

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

LOG: [lldb/SWIG] Fix capitalization for case sensitive file systems.

When moving the Python directory I renamed it to python (lowercase) but
didn't update the python.swig file.

Added: 


Modified: 
lldb/bindings/python.swig

Removed: 




diff  --git a/lldb/bindings/python.swig b/lldb/bindings/python.swig
index cf716da4a477..56fab9ff1795 100644
--- a/lldb/bindings/python.swig
+++ b/lldb/bindings/python.swig
@@ -111,12 +111,12 @@ def lldb_iter(obj, getsize, getelem):
 %}
 
 %include 
-%include "./Python/python-typemaps.swig"
+%include "./python/python-typemaps.swig"
 %include "./macros.swig"
 %include "./headers.swig"
 
 %{
-#include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h"
+#include "../source/Plugins/ScriptInterpreter/python/PythonDataObjects.h"
 #include "../bindings/python/python-swigsafecast.swig"
 using namespace lldb_private;
 using namespace lldb_private::python;
@@ -124,8 +124,8 @@ using namespace lldb;
 %}
 
 %include "./interfaces.swig"
-%include "./Python/python-extensions.swig"
-%include "./Python/python-wrapper.swig"
+%include "./python/python-extensions.swig"
+%include "./python/python-wrapper.swig"
 
 %pythoncode%{
 debugger_unique_id = 0



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


[Lldb-commits] [PATCH] D72413: Add missing nullptr checks.

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

Should we merge this like that, or is there a better way of doing this?


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

https://reviews.llvm.org/D72413



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


[Lldb-commits] [lldb] 7bbd407 - [lldb/SWIG] Undo incorrect substitution

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

Author: Jonas Devlieghere
Date: 2020-01-09T09:55:39-08:00
New Revision: 7bbd4076c1984165568c978ff15b77dbfe52b6f0

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

LOG: [lldb/SWIG] Undo incorrect substitution

The Python directory for the script interpreter is still capitalized.

Added: 


Modified: 
lldb/bindings/python.swig

Removed: 




diff  --git a/lldb/bindings/python.swig b/lldb/bindings/python.swig
index 56fab9ff1795..b086d436e57b 100644
--- a/lldb/bindings/python.swig
+++ b/lldb/bindings/python.swig
@@ -116,7 +116,7 @@ def lldb_iter(obj, getsize, getelem):
 %include "./headers.swig"
 
 %{
-#include "../source/Plugins/ScriptInterpreter/python/PythonDataObjects.h"
+#include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h"
 #include "../bindings/python/python-swigsafecast.swig"
 using namespace lldb_private;
 using namespace lldb_private::python;



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


[Lldb-commits] [PATCH] D72359: [lldb] Fix TestClangASTContext.TestFunctionTemplateInRecordConstruction in Debug builds

2020-01-09 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72359



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


[Lldb-commits] [PATCH] D72391: [lldb] Add a display name to ClangASTContext instances

2020-01-09 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

Perhaps it makes sense to modify the `dump()` method to also display the new 
name?




Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:609
+  m_ast_context.reset(new ClangASTContext(
+  "Expression AST for '" + m_filename + "'", ast_context));
 

AST -> ASTContext?



Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:164
+  m_ast_context.reset(new ClangASTContext(
+  "ClangModulesDeclVendor AST", m_compiler_instance->getASTContext()));
 }

AST -> ASTContext?



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp:147
+  m_ast_ctx(
+  "AppleObjCDeclVendor AST",
+  runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple()),

AST -> ASTContext?

Below you use "scratch ASTContext"



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp:27
+m_scratch_ast_ctx_up.reset(new ClangASTContext(
+"AppleObjCTypeEncodingParser AST",
+runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple()));

AST -> ASTContext?



Comment at: lldb/unittests/Symbol/TestClangASTContext.cpp:29
   void SetUp() override {
-m_ast.reset(new ClangASTContext(HostInfo::GetTargetTriple()));
+m_ast.reset(new ClangASTContext("test AST", HostInfo::GetTargetTriple()));
   }

AST -> ASTContext?



Comment at: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp:42
EnsureAllDIEsInDeclContextHaveBeenParsedParsesOnlyMatchingEntries) {
-  ClangASTContext ast_ctx(HostInfoBase::GetTargetTriple());
+  ClangASTContext ast_ctx("dummy", HostInfoBase::GetTargetTriple());
   DWARFASTParserClangStub ast_parser(ast_ctx);

dummy -> dummy ASTContext



Comment at: lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h:25
 inline std::unique_ptr createAST() {
-  return std::make_unique(HostInfo::GetTargetTriple());
+  return std::make_unique("test AST",
+   HostInfo::GetTargetTriple());

AST -> ASTContext?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72391



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


[Lldb-commits] [PATCH] D72391: [lldb] Add a display name to ClangASTContext instances

2020-01-09 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

In D72391#1809751 , @teemperor wrote:

> I don't know if this needs a unit test where we call the constructor and 
> explicitly check the name is the one we passed in. Let me know if you think 
> this would make sense.


I think we should.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72391



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


[Lldb-commits] [PATCH] D72391: [lldb] Add a display name to ClangASTContext instances

2020-01-09 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

In D72391#1811589 , @teemperor wrote:

> @clayborg We can easily append the ptr value to the display name. All names 
> should always be unique as long as there is one target, but in the off-chance 
> that one isn't unique it might be useful.


I think the pointer values would be useful to have.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D72391



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


[Lldb-commits] [PATCH] D72437: [lldb/Bindings] Move bindings into their own subdirectory

2020-01-09 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This is a great cleanup.  Thanks for doing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72437



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


[Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2020-01-09 Thread Ted Woodward via Phabricator via lldb-commits
ted added a comment.

In D71372#1811594 , @labath wrote:

> In D71372#1810687 , @ted wrote:
>
> > I've got another failure case for this. If the remote gdbserver doesn't 
> > implement qMemoryRegionInfo or qXfer:memory-map:read, thread step-out will 
> > fail.
> >  
>
>
> That's a good point Ted. I think we should give targets which don't support 
> fetching permissions the benefit of the doubt, and treat all memory as 
> potentially executable. Would removing the `return` statement from the 
> `if(!GetLoadAddressPermissions)` branch solve your problem? If so, can you 
> whip up a patch for that?


Removing the return statement fixes the issue. I'll put up a patch. Keeping the 
m_constructor_errors.Printf line doesn't cause a failure; it might be useful to 
keep that in case the breakpoint can't be created for other reasons. What do 
you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71372



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


[Lldb-commits] [PATCH] D72413: Add missing nullptr checks.

2020-01-09 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

In D72413#1812464 , @aprantl wrote:

> Should we merge this like that, or is there a better way of doing this?


We should merge it like this, IMHO.


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

https://reviews.llvm.org/D72413



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


[Lldb-commits] [PATCH] D72413: Add missing nullptr checks.

2020-01-09 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

@teemperor what do you think?


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

https://reviews.llvm.org/D72413



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


[Lldb-commits] [lldb] 58b3dec - [lldb/Lua] Add lua typemaps for INOUT params

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

Author: Jonas Devlieghere
Date: 2020-01-09T14:51:13-08:00
New Revision: 58b3dec6c108eb9ae4af2cde5c831743d5605c79

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

LOG: [lldb/Lua] Add lua typemaps for INOUT params

Added: 
lldb/bindings/lua/lua-typemaps.swig

Modified: 
lldb/bindings/lua.swig

Removed: 




diff  --git a/lldb/bindings/lua.swig b/lldb/bindings/lua.swig
index 3b279a6b69e7..9bfc49b359bc 100644
--- a/lldb/bindings/lua.swig
+++ b/lldb/bindings/lua.swig
@@ -9,6 +9,7 @@
 %module lldb
 
 %include 
+%include "./lua/lua-typemaps.swig"
 %include "./macros.swig"
 %include "./headers.swig"
 

diff  --git a/lldb/bindings/lua/lua-typemaps.swig 
b/lldb/bindings/lua/lua-typemaps.swig
new file mode 100644
index ..28d63fa2f402
--- /dev/null
+++ b/lldb/bindings/lua/lua-typemaps.swig
@@ -0,0 +1 @@
+%include 



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


[Lldb-commits] [PATCH] D70238: [lldb] Allow loading of minidumps with no process id

2020-01-09 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

I would prefer that we just pick a PID of 1 for minidumps if they are missing 
and we have minidump files that don't have PIDs. Then no other logic needs to 
change? Have you seen real minidumps that have memory and threads and no 
process ID?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70238



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


[Lldb-commits] [PATCH] D70238: [lldb] Allow loading of minidumps with no process id

2020-01-09 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

The pid usually comes from the MinidumpMiscInfoFlags::ProcessID right? This is 
a minidump supported directory entry. We don't actually rely on /proc/%d/status 
right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70238



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


[Lldb-commits] [lldb] b81c8c6 - [lldb] Remove spurious file

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

Author: Jonas Devlieghere
Date: 2020-01-09T15:32:09-08:00
New Revision: b81c8c6976b987a25fc54fa2bf3524919759a898

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

LOG: [lldb] Remove spurious file

Added: 


Modified: 


Removed: 
lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake



diff  --git a/lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake 
b/lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake
deleted file mode 100644
index 90c902f74ae5..
--- a/lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake
+++ /dev/null
@@ -1,51 +0,0 @@
-#.rst:
-# FindPythonInterpndLibs
-# ---
-#
-# Find the python interpreter and libraries as a whole.
-
-if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS AND PYTHON_EXECUTABLE)
-  set(PYTHONINTERPANDLIBS_FOUND TRUE)
-else()
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
-find_package(Python3 COMPONENTS Interpreter Development QUIET)
-if (Python3_FOUND AND Python3_Interpreter_FOUND)
-  set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
-  set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
-  set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
-  mark_as_advanced(
-PYTHON_LIBRARIES
-PYTHON_INCLUDE_DIRS
-PYTHON_EXECUTABLE)
-endif()
-  else()
-find_package(PythonInterp QUIET)
-find_package(PythonLibs QUIET)
-if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
-  if (NOT CMAKE_CROSSCOMPILING)
-string(REPLACE "." ";" pythonlibs_version_list 
${PYTHONLIBS_VERSION_STRING})
-list(GET pythonlibs_version_list 0 pythonlibs_major)
-list(GET pythonlibs_version_list 1 pythonlibs_minor)
-
-# Ignore the patch version. Some versions of macOS report a 
diff erent
-# patch version for the system provided interpreter and libraries.
-if (CMAKE_CROSSCOMPILING OR (PYTHON_VERSION_MAJOR VERSION_EQUAL 
pythonlibs_major AND
-PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor))
-  mark_as_advanced(
-PYTHON_LIBRARIES
-PYTHON_INCLUDE_DIRS
-PYTHON_EXECUTABLE)
-endif()
-  endif()
-endif()
-  endif()
-
-  include(FindPackageHandleStandardArgs)
-  find_package_handle_standard_args(PythonInterpAndLibs
-FOUND_VAR
-  PYTHONINTERPANDLIBS_FOUND
-REQUIRED_VARS
-  PYTHON_LIBRARIES
-  PYTHON_INCLUDE_DIRS
-  PYTHON_EXECUTABLE)
-endif()



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


[Lldb-commits] [lldb] 0211391 - When reading Aux file in chunks, read consecutive byte ranges

2020-01-09 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2020-01-09T16:05:38-08:00
New Revision: 02113918ed6b5e514afd7d1e007131d36ac13f1d

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

LOG: When reading Aux file in chunks, read consecutive byte ranges

qemu has a very small maximum packet size (4096) and it actually
only uses half of that buffer for some implementation reason,
so when lldb asks for the register target definitions, the x86_64
definition is larger than 4096/2 and we need to fetch it in two parts.

This patch and test is fixing a bug in
GDBRemoteCommunicationClient::ReadExtFeature when reading a target
file in multiple parts.  lldb was assuming that it would always
get back the maximum packet size response (4096) instead of
using the actual size received and asking for the next group of
bytes.

We now have two tests in gdb_remote_client for unique features
of qemu - TestNestedRegDefinitions.py would test the ability
of lldb to follow multiple levels of xml includes; I opted to
create a separate TestRegDefinitionInParts.py test to test this
wrinkle in qemu's gdb remote serial protocol stub implementation.
Instead of combining both tests into a single test file.



Added: 

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRegDefinitionInParts.py

Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRegDefinitionInParts.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRegDefinitionInParts.py
new file mode 100644
index ..c4ba19cc2b62
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRegDefinitionInParts.py
@@ -0,0 +1,160 @@
+from __future__ import print_function
+import lldb
+import time
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+class TestRegDefinitionInParts(GDBRemoteTestBase):
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+def test(self):
+"""
+Test that lldb correctly fetches the target definition file
+in multiple chunks if the remote server only provides the 
+content in small parts, and the small parts it provides is
+smaller than the maximum packet size that it declared at
+the start of the debug session.  qemu does this.
+"""
+class MyResponder(MockGDBServerResponder):
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+  
+  
+  i386:x86-64
+  
+  """, False
+
+if annex == "i386-64bit-core.xml" and offset == 0:
+return """
+
+
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+  
+  
+  
+  
+  
+  
+  
+  
+
+  
+  
+  
+  
+  
+  
+  
+  
+
+  
+  
+  
+  
+  
+  
+  
+  
+""", False
+
+return None, False
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return 
"0600c0b7c00080fff021c60080ff1a00020078b7c00080ff203f8ca090ff103f8ca090ff3025990a80ff8096980070009f0a80ff02eae10080ff1822d74f1a0078b7c00080ff0e124100800046027f03801f"
+
+def haltReason(self):
+return "T02thread:dead;threads:dead;"
+
+def qfThreadInfo(self):
+return "mdead"
+
+def qC(self):
+return ""
+
+def qSupported(self, client_supported):
+r

[Lldb-commits] [PATCH] D72489: [DWARF] Emit DW_AT_call_return_pc as an address

2020-01-09 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: aprantl, labath, dblaikie.
Herald added a subscriber: hiraditya.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLVM.

This reverts D53469 , which changed llvm's 
DWARF emission to emit
DW_AT_call_return_pc as a function-local offset. Such an encoding is not
compatible with post-link block re-ordering tools and isn't standards-
compliant.

In addition to reverting back to the original DW_AT_call_return_pc
encoding, teach lldb how to fix up DW_AT_call_return_pc when the address
comes from an object file pointed-to by a debug map. While doing this I
noticed that lldb's support for tail calls that cross a DSO/object file
boundary wasn't covered, so I added tests for that. This latter case
exercises the newly added return PC fixup.

The dsymutil changes in this patch were originall included in D49887 
:
the associated test should be sufficient to test DW_AT_call_return_pc
encoding purely on the llvm side.


https://reviews.llvm.org/D72489

Files:
  lldb/include/lldb/Symbol/Function.h
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One.mk
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One/One.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two.mk
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two/Two.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/main.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/shared.h
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/One.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Two.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/main.c
  
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/shared.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Symbol/Function.cpp
  llvm/include/llvm/CodeGen/DebugHandlerBase.h
  llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/tools/dsymutil/Inputs/call-site-entry.c
  llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64
  llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64.o
  llvm/test/tools/dsymutil/call-site-entry-linking.test
  llvm/tools/dsymutil/DwarfLinker.cpp

Index: llvm/tools/dsymutil/DwarfLinker.cpp
===
--- llvm/tools/dsymutil/DwarfLinker.cpp
+++ llvm/tools/dsymutil/DwarfLinker.cpp
@@ -1387,6 +1387,10 @@
   // it. Otherwise (when no relocations where applied) just use the
   // one we just decoded.
   Addr = (Info.OrigHighPc ? Info.OrigHighPc : Addr) + Info.PCOffset;
+  } else if (AttrSpec.Attr == dwarf::DW_AT_call_return_pc) {
+// Relocate a return PC address within a call site entry.
+if (Die.getTag() == dwarf::DW_TAG_call_site)
+  Addr += Info.PCOffset;
   }
 
   Die.addValue(DIEAlloc, static_cast(AttrSpec.Attr),
Index: llvm/test/tools/dsymutil/call-site-entry-linking.test
===
--- /dev/null
+++ llvm/test/tools/dsymutil/call-site-entry-linking.test
@@ -0,0 +1,4 @@
+RUN: dsymutil -oso-prepend-path=%p %p/Inputs/call-site-entry.macho.x86_64 -o %t.dSYM
+RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_return_pc
+
+CHECK: DW_AT_call_return_pc  (0x00010fa4)
Index: llvm/test/tools/dsymutil/Inputs/call-site-entry.c
===
--- /dev/null
+++ llvm/test/tools/dsymutil/Inputs/call-site-entry.c
@@ -0,0 +1,27 @@
+/*
+ * This file is used to test dsymutil support for call site entries
+ * (DW_TAG_call_site / DW_AT_call_return_pc).
+ *
+ * Instructions for regenerating binaries (on Darwin/x86_64):
+ *
+ * 1. Copy the source to a top-level directory to work around having absolute
+ *paths in the symtab's OSO entries.
+ *
+ *mkdir -p /Inputs/ && cp call-site-entry.c /Inputs && cd /Inputs
+ *
+ * 2. Compile with call site info enabled.
+ *
+ *clang -g -O1 -Xclang -disable-llvm-passes call-site-entry.c -c -o call-site-entry.macho.x86_64.o
+ *clang call-site-entry.macho.x86_

[Lldb-commits] [PATCH] D72489: [DWARF] Emit DW_AT_call_return_pc as an address

2020-01-09 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

Thanks for looking into this!

Could you measure the size of the object files of, for example, the clang 
binary before/after this change - and, if possible, on Linux (where relocations 
are required to fixup these addresses)? I'm concerned this might increase the 
size significantly.
Could you check if this does the right thing for Split DWARF or DWARFv5? (I 
suspect it does - if you're using the same API as is used for DW_TAG_label's 
low_pc, for instance - which I imagine you are) - in terms of adding the 
address to debug_addr, and using addrx encoding.

I was going to suggest we use a non-standard extension to preserve the 
subprogram-relative behavior, by using a different DW_FORM (such as data4) to 
communicate that this is a subprogram-relative value. But that won't be 
sufficient for PROPELLER, for instance, which fragments subprograms so there's 
no unique low_pc for it to be relative to. So that leaves us maybe really 
wanting the addr+offset encoding discussed here: 
http://lists.llvm.org/pipermail/llvm-dev/2020-January/138029.html


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

https://reviews.llvm.org/D72489



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