[Lldb-commits] [PATCH] D90298: [lldb] [Process/FreeBSDRemote] Implement thread GetName()

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

Implement NativeThreadFreeBSD::GetName().  This is based
on the equivalent code in the legacy FreeBSD plugin, except it is
modernized a bit to use llvm::Optional and std::vector for data storage.


https://reviews.llvm.org/D90298

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -74,6 +74,7 @@
   using WatchpointIndexMap = std::map;
   WatchpointIndexMap m_watchpoint_index_map;
   WatchpointIndexMap m_hw_break_index_map;
+  llvm::Optional m_thread_name;
 };
 
 typedef std::shared_ptr NativeThreadFreeBSDSP;
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -22,9 +22,11 @@
 #include 
 #include 
 #include 
+#include 
 // clang-format on
 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -146,7 +148,44 @@
   m_stop_info.reason = StopReason::eStopReasonNone;
 }
 
-std::string NativeThreadFreeBSD::GetName() { return ""; }
+std::string NativeThreadFreeBSD::GetName() {
+  if (!m_thread_name) {
+Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+
+std::vector kp;
+int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+  static_cast(GetProcess().GetID())};
+
+while (1) {
+  size_t len = kp.size() * sizeof(struct kinfo_proc);
+  void *ptr = len == 0 ? nullptr : kp.data();
+  int error = ::sysctl(mib, 4, ptr, &len, nullptr, 0);
+  if (ptr == nullptr || (error != 0 && errno == ENOMEM)) {
+// Add extra space in case threads are added before next call.
+kp.resize((len / sizeof(struct kinfo_proc)) + 10);
+continue;
+  }
+  if (error != 0) {
+len = 0;
+LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}", 
GetID(),
+ StateAsCString(m_state), strerror(errno));
+  }
+  kp.resize(len / sizeof(struct kinfo_proc));
+  break;
+}
+
+// empty == unknown
+m_thread_name = std::string();
+for (auto& procinfo : kp) {
+  if (procinfo.ki_tid == (lwpid_t)GetID()) {
+m_thread_name = procinfo.ki_tdname;
+break;
+  }
+}
+  }
+
+  return m_thread_name.getValue();
+}
 
 lldb::StateType NativeThreadFreeBSD::GetState() { return m_state; }
 


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -74,6 +74,7 @@
   using WatchpointIndexMap = std::map;
   WatchpointIndexMap m_watchpoint_index_map;
   WatchpointIndexMap m_hw_break_index_map;
+  llvm::Optional m_thread_name;
 };
 
 typedef std::shared_ptr NativeThreadFreeBSDSP;
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -22,9 +22,11 @@
 #include 
 #include 
 #include 
+#include 
 // clang-format on
 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -146,7 +148,44 @@
   m_stop_info.reason = StopReason::eStopReasonNone;
 }
 
-std::string NativeThreadFreeBSD::GetName() { return ""; }
+std::string NativeThreadFreeBSD::GetName() {
+  if (!m_thread_name) {
+Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+
+std::vector kp;
+int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+  static_cast(GetProcess().GetID())};
+
+while (1) {
+  size_t len = kp.size() * sizeof(struct kinfo_proc);
+  void *ptr = len == 0 ? nullptr : kp.data();
+  int error = ::sysctl(mib, 4, ptr, &len, nullptr, 0);
+  if (ptr == nullptr || (error != 0 && errno == ENOMEM)) {
+// Add extra space in case threads are added before next call.
+kp.resize((len / sizeof(struct kinfo_proc)) + 10);
+continue;
+  }
+  if (error != 0) {
+len = 0;
+LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}", GetID(),
+ StateAsCString(m_state), strerror(errno));
+  }
+  kp.resize(len /

[Lldb-commits] [PATCH] D90298: [lldb] [Process/FreeBSDRemote] Implement thread GetName()

2020-10-28 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp:151
 
-std::string NativeThreadFreeBSD::GetName() { return ""; }
+std::string NativeThreadFreeBSD::GetName() {
+  if (!m_thread_name) {

It is probably fine, but I would use:

1. `PT_GETNUMLWPS`
2. `PT_GETLWPLIST` with optional caching
3. Read `pl_tdname` from `ptrace_lwpinfo`



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp:164
+  if (ptr == nullptr || (error != 0 && errno == ENOMEM)) {
+// Add extra space in case threads are added before next call.
+kp.resize((len / sizeof(struct kinfo_proc)) + 10);

Isn't this call always synchronous and all the threads are stopped?


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

https://reviews.llvm.org/D90298

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


[Lldb-commits] [PATCH] D90298: [lldb] [Process/FreeBSDRemote] Implement thread GetName()

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

I am not sure that the caching is really needed, but this seems ok to me. I'm 
assuming that this fixes TestGdbRemoteThreadName.py...




Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp:164
+  if (ptr == nullptr || (error != 0 && errno == ENOMEM)) {
+// Add extra space in case threads are added before next call.
+kp.resize((len / sizeof(struct kinfo_proc)) + 10);

krytarowski wrote:
> Isn't this call always synchronous and all the threads are stopped?
I would certainly expect so



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp:171
+LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}", 
GetID(),
+ StateAsCString(m_state), strerror(errno));
+  }

just `m_state`, it's cleaner


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

https://reviews.llvm.org/D90298

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


[Lldb-commits] [PATCH] D89157: [lldb] Report old modules from ModuleList::ReplaceEquivalent

2020-10-28 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet added a comment.

I'd been hoping to get this bugfix into 11.0.1, but it (and D89156 
, which is just some cleanup that occurred to 
me while working on this code) have been stalled for a few weeks, and I don't 
have any insight into the reason.  If there's anything i can do to help either 
one along, please let me know.  One idea I had is that I could rebase this on 
master so it doesn't depend on the other, would that help?

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89157

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


[Lldb-commits] [PATCH] D88483: Add possibility to get module from SBType

2020-10-28 Thread Ilya Bukonkin via Phabricator via lldb-commits
fallkrum updated this revision to Diff 301271.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88483

Files:
  lldb/bindings/interface/SBType.i
  lldb/include/lldb/API/SBModule.h
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/source/API/SBType.cpp
  lldb/source/Symbol/Type.cpp
  lldb/test/API/functionalities/type_get_module/Makefile
  lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
  lldb/test/API/functionalities/type_get_module/compile_unit1.c
  lldb/test/API/functionalities/type_get_module/compile_unit2.c
  lldb/test/API/functionalities/type_get_module/main.c

Index: lldb/test/API/functionalities/type_get_module/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/type_get_module/main.c
@@ -0,0 +1 @@
+int main() { return 0; }
Index: lldb/test/API/functionalities/type_get_module/compile_unit2.c
===
--- /dev/null
+++ lldb/test/API/functionalities/type_get_module/compile_unit2.c
@@ -0,0 +1,6 @@
+struct compile_unit2_type {
+  int x;
+  int y;
+};
+
+struct compile_unit2_type compile_unit2_var = {2, 2};
Index: lldb/test/API/functionalities/type_get_module/compile_unit1.c
===
--- /dev/null
+++ lldb/test/API/functionalities/type_get_module/compile_unit1.c
@@ -0,0 +1,6 @@
+struct compile_unit1_type {
+  int x;
+  int y;
+};
+
+struct compile_unit1_type compile_unit1_var = {1, 1};
Index: lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
===
--- /dev/null
+++ lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
@@ -0,0 +1,42 @@
+"""
+Test that SBType returns SBModule of executable file but not
+of compile unit's object file.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestTypeGetModule(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+self.build()
+target  = lldbutil.run_to_breakpoint_make_target(self)
+exe_module = target.GetModuleAtIndex(0)
+
+type1_name = 'compile_unit1_type'
+type2_name = 'compile_unit2_type'
+
+num_comp_units = exe_module.GetNumCompileUnits()
+self.assertEqual(num_comp_units, 3)
+
+comp_unit = exe_module.GetCompileUnitAtIndex(1)
+type_name = comp_unit.GetTypes().GetTypeAtIndex(0).GetName()
+self.assertEqual(type_name, type1_name)
+
+comp_unit = exe_module.GetCompileUnitAtIndex(2)
+type_name = comp_unit.GetTypes().GetTypeAtIndex(0).GetName()
+self.assertEqual(type_name, type2_name)
+
+type1 = target.FindFirstType(type1_name)
+self.assertTrue(type1.IsValid())
+
+type2 = target.FindFirstType(type2_name)
+self.assertTrue(type2.IsValid())
+
+self.assertTrue(exe_module == type1.GetModule() and
+exe_module == type2.GetModule())
Index: lldb/test/API/functionalities/type_get_module/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/type_get_module/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c compile_unit1.c compile_unit2.c
+include Makefile.rules
Index: lldb/source/Symbol/Type.cpp
===
--- lldb/source/Symbol/Type.cpp
+++ lldb/source/Symbol/Type.cpp
@@ -727,6 +727,14 @@
   return ModuleSP();
 }
 
+ModuleSP Type::GetExeModule() {
+  if (m_compiler_type) {
+SymbolFile *symbol_file = m_compiler_type.GetTypeSystem()->GetSymbolFile();
+return symbol_file->GetObjectFile()->GetModule();
+  }
+  return ModuleSP();
+}
+
 TypeAndOrName::TypeAndOrName(TypeSP &in_type_sp) {
   if (in_type_sp) {
 m_compiler_type = in_type_sp->GetForwardCompilerType();
@@ -821,6 +829,7 @@
 void TypeImpl::SetType(const lldb::TypeSP &type_sp) {
   if (type_sp) {
 m_static_type = type_sp->GetForwardCompilerType();
+m_exe_module_wp = type_sp->GetExeModule();
 m_module_wp = type_sp->GetModule();
   } else {
 m_static_type.Clear();
@@ -847,6 +856,15 @@
 }
 
 bool TypeImpl::CheckModule(lldb::ModuleSP &module_sp) const {
+  return CheckModuleCommon(m_module_wp, module_sp);
+}
+
+bool TypeImpl::CheckExeModule(lldb::ModuleSP &module_sp) const {
+  return CheckModuleCommon(m_exe_module_wp, module_sp);
+}
+
+bool TypeImpl::CheckModuleCommon(const lldb::ModuleWP &input_module_wp,
+ lldb::ModuleSP &module_sp) const {
   // Check if we have a module for this type. If we do and the shared pointer
   // is can be successfully initialized with m_module_wp, return true. Else
   //

[Lldb-commits] [PATCH] D88483: Add possibility to get module from SBType

2020-10-28 Thread Ilya Bukonkin via Phabricator via lldb-commits
fallkrum added a comment.

Please commit it for me.
Ilya Bukonkin fallk...@yahoo.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88483

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


[Lldb-commits] [PATCH] D90313: [lldb] Use reverse connection method for lldb-server tests

2020-10-28 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: rupprecht, JDevlieghere.
Herald added a subscriber: jfb.
Herald added a project: LLDB.
labath requested review of this revision.

This fixes an flakyness is all gdb-remote tests. These tests have been
(mildly) flaky since we started using "localhost" instead of 127.0.0.1
in the test suite. The reason is that lldb-server needs to create two
sockets (v4 and v6) to listen for localhost connections. The algorithm
it uses first tries to select a random port (bind(localhost:0)) for the
first address, and then bind the same port for the second one.

The creating of the second socket can fail as there's no guarantee that
port will be available -- it seems that the (linux) kernel tries to
choose an unused port for the first socket (I've had to create thousands
of sockets to reproduce this reliably), but this can apparantly fail
when the system is under load (and our test suite creates a _lot_ of
sockets).

The socket creationg operation is considered successful if it creates at
least one socket is created, but the test harness has no way of knowing
which one it is, so it can end up connecting to the wrong address.

I'm not aware of a way to atomically create two sockets bound to the
same port. One way to fix this would be to make lldb-server report the
address is it listening on instead of just the port. However, this would
be a breaking change and it's not clear to me that's worth it (the
algorithm works pretty well under normal circumstances).

Instead, this patch sidesteps that problem by using "reverse"
connections. This way, the test harness is responsible for creating the
listening socket so it can pass the address that it has managed to open.
It also results in much simpler code overall.

To preserve test coverage for the named pipe method, I've moved the
relevant code to a dedicated test. To avoid original problem, this test
passes raw addresses (as obtained by getaddrinfo(localhost)) instead of
"localhost".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90313

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py

Index: lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
===
--- lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py
+++ /dev/null
@@ -1,105 +0,0 @@
-from __future__ import print_function
-
-import errno
-import gdbremote_testcase
-import lldbgdbserverutils
-import re
-import select
-import socket
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestStubReverseConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-# Set up the test.
-gdbremote_testcase.GdbRemoteTestCaseBase.setUp(self)
-
-# Create a listener on a local port.
-self.listener_socket = self.create_listener_socket()
-self.assertIsNotNone(self.listener_socket)
-self.listener_port = self.listener_socket.getsockname()[1]
-
-def create_listener_socket(self):
-try:
-sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-except OSError as e:
-if e.errno != errno.EAFNOSUPPORT:
-raise
-sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
-self.assertIsNotNone(sock)
-
-sock.settimeout(self.DEFAULT_TIMEOUT)
-if sock.family == socket.AF_INET:
-bind_addr = ("127.0.0.1", 0)
-elif sock.family == socket.AF_INET6:
-bind_addr = ("::1", 0)
-sock.bind(bind_addr)
-sock.listen(1)
-
-def tear_down_listener():
-try:
-sock.shutdown(socket.SHUT_RDWR)
-except:
-# ignore
-None
-
-self.addTearDownHook(tear_down_listener)
-return sock
-
-def reverse_connect_works(self):
-# Indicate stub startup should do a reverse connect.
-appended_stub_args = ["--reverse-connect"]
-if self.debug_monitor_extra_args:
-self.debug_monitor_extra_args += appended_stub_args
-else:
-self.debug_monitor_extra_args = appended_stub_args
-
-self.stub_hostname = "127.0.0.1"
-self.port = self.listener_port
-
-triple = self.dbg.GetSelectedPlatform().GetTriple()
-if re.match(".*-.*-.*-android", triple):
-self.forward_adb_port(
-self.port,
-self.port,
-"reverse",
-self.stub_device)
-
-# Start the stub.
-server = self.launch_debug_monitor(logfile=sys.stdout)
-self.assertIsNotNone(server)
-self.assertTrue(
-l

[Lldb-commits] [PATCH] D90313: [lldb] Use reverse connection method for lldb-server tests

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

On GreenDragon we've also noticed the increased flakiness and it sounds like it 
could very well be the same issue? It seems like this would only solve it for 
lldb-server, while we run these tests with debugserver. The latter doesn't 
support `--reverse-connect`, so I'm wondering if there's something else we can 
do to solve the flakiness for both? Should we just return to using `127.0.0.1`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90313

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


[Lldb-commits] [PATCH] D90313: [lldb] Use reverse connection method for lldb-server tests

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

In D90313#2359273 , @JDevlieghere 
wrote:

> On GreenDragon we've also noticed the increased flakiness and it sounds like 
> it could very well be the same issue? It seems like this would only solve it 
> for lldb-server, while we run these tests with debugserver. The latter 
> doesn't support `--reverse-connect`, so I'm wondering if there's something 
> else we can do to solve the flakiness for both? Should we just return to 
> using `127.0.0.1`?

It does support --reverse-connect, and I've checked that this works with it. 
The only tricky part is that the option does not show up in its --help output. 
(it didn't used to show for lldb-server either, that's why I did the libOption 
patch :P).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90313

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


[Lldb-commits] [PATCH] D90313: [lldb] Use reverse connection method for lldb-server tests

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

In D90313#2359300 , @labath wrote:

> In D90313#2359273 , @JDevlieghere 
> wrote:
>
>> On GreenDragon we've also noticed the increased flakiness and it sounds like 
>> it could very well be the same issue? It seems like this would only solve it 
>> for lldb-server, while we run these tests with debugserver. The latter 
>> doesn't support `--reverse-connect`, so I'm wondering if there's something 
>> else we can do to solve the flakiness for both? Should we just return to 
>> using `127.0.0.1`?
>
> It does support --reverse-connect, and I've checked that this works with it. 
> The only tricky part is that the option does not show up in its --help 
> output. (it didn't used to show for lldb-server either, that's why I did the 
> libOption patch :P).

Haha, it feels like you read my mind because that's exactly what I checked. Now 
the pieces are falling in place ;-) LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90313

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


[Lldb-commits] [PATCH] D90276: [lldb/utils] Add the lldb-env tool

2020-10-28 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.

>> Re: making the lit.site.cfg self-contained, IIUC the situation is that there 
>> are a couple places where we shell out via `subprocess`, but that you'd like 
>> to get rid of these? I wonder whether we could bundle up the necessary 
>> scripts along with lit.site.cfg instead.
>
> My remark was not so much about the need for another tool but rather the need 
> to configure it. Right now I can hand-write a `lit.site.cfg.py`, omit a bunch 
> of values, and point lit to it. With this tool I'd need to also configure it 
> (i.e. replacing `@LLVM_USE_SANITIZER@` and `@CMAKE_CXX_COMPILER@`.

Not sure I follow: why would introducing an lldb-env tool make it necessary for 
the top-level lit.site.cfg.py to be configured by the build (i.e. why would it 
preclude using a hand-written lit.site.cfg.py)?

Or: if you meant, the need to configure lldb-env is in and of itself an issue, 
not sure I follow that either. We rely on other configured files (e.g. the 
lit.site.cfg.py's) - is the issue that the configuration logic in 
lldb-dotest/CMakeLists.txt is especially hard to maintain?

> I wonder if there's any way to make `lldb-dotest` and this tool load the 
> `lit.site.cfg.py` and use the variables that we put in the config there.

I think it's possible. The lit.site.cfg.py we want should have a known location 
relative to the lldb executable, so an lldb-env tool could import it. Perhaps 
I'm underestimating the complexity (there are actually at least two possible 
locations, `$(dirname path/to/lldb)/{../tools/lldb/test, 
../test}/lit.site.cfg.py`).

>>> FWIW my plan was to deprecate `lldb-dotest` at some in favor of either 
>>> using `llvm-lit` directly or by wrapping it. I hate maintaining the code in 
>>> `lldb-dotest/CMakeLists.txt` because I always break the standalone build 
>>> when I forget to add a variable.
>>
>> My intention was to make sure we get an lldb-env everywhere we already 
>> expect a lldb-dotest. If that's not required, I'd be fine with moving the 
>> new tool elsewhere.
>
> I think that if we were to move this under `lldb/test` we might get that for 
> free if we use the same `@`-variable names as the `lit.site.cfg.py`. I think 
> that'd be a good idea regardless (and also most certainly a different patch).

I'm not sure what the suggestion is here exactly. Is it to move the lldb-env 
tool under TEST_EXEC_ROOT? That should work for what I'm trying to do -- from 
that location, lldb-env can look up all the build info it needs by importing 
the adjacent lit.site.cfg.py, without needing to be configured.

Happy to rework things, ultimately I'm just looking for a reliable/consistent 
way to invoke bin/lldb without "being" a test. Also happy to discuss further 
offline: it may turn out that we don't really want/need to support running the 
just-built lldb outside of test/. After all we're interested in setting up a 
test in CI that runs the lldb driver -- perhaps this can just live in 
lldb/test/Shell.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90276

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


[Lldb-commits] [PATCH] D90298: [lldb] [Process/FreeBSDRemote] Implement thread GetName()

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



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp:151
 
-std::string NativeThreadFreeBSD::GetName() { return ""; }
+std::string NativeThreadFreeBSD::GetName() {
+  if (!m_thread_name) {

krytarowski wrote:
> It is probably fine, but I would use:
> 
> 1. `PT_GETNUMLWPS`
> 2. `PT_GETLWPLIST` with optional caching
> 3. Read `pl_tdname` from `ptrace_lwpinfo`
`PT_GETLWPLIST` returns only LWP IDs. `struct ptrace_lwpinfo` is used by 
`PT_LWPINFO` which returns info about the thread causing the process to stop, 
not an arbitrary thread.


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

https://reviews.llvm.org/D90298

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


[Lldb-commits] [PATCH] D90298: [lldb] [Process/FreeBSDRemote] Implement thread GetName()

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

Removed overallocation and put plain `m_state` into log message.


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

https://reviews.llvm.org/D90298

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -74,6 +74,7 @@
   using WatchpointIndexMap = std::map;
   WatchpointIndexMap m_watchpoint_index_map;
   WatchpointIndexMap m_hw_break_index_map;
+  llvm::Optional m_thread_name;
 };
 
 typedef std::shared_ptr NativeThreadFreeBSDSP;
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -22,9 +22,11 @@
 #include 
 #include 
 #include 
+#include 
 // clang-format on
 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -146,7 +148,43 @@
   m_stop_info.reason = StopReason::eStopReasonNone;
 }
 
-std::string NativeThreadFreeBSD::GetName() { return ""; }
+std::string NativeThreadFreeBSD::GetName() {
+  if (!m_thread_name) {
+Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+
+std::vector kp;
+int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+  static_cast(GetProcess().GetID())};
+
+while (1) {
+  size_t len = kp.size() * sizeof(struct kinfo_proc);
+  void *ptr = len == 0 ? nullptr : kp.data();
+  int error = ::sysctl(mib, 4, ptr, &len, nullptr, 0);
+  if (ptr == nullptr || (error != 0 && errno == ENOMEM)) {
+kp.resize(len / sizeof(struct kinfo_proc));
+continue;
+  }
+  if (error != 0) {
+len = 0;
+LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}", 
GetID(),
+ m_state, strerror(errno));
+  }
+  kp.resize(len / sizeof(struct kinfo_proc));
+  break;
+}
+
+// empty == unknown
+m_thread_name = std::string();
+for (auto& procinfo : kp) {
+  if (procinfo.ki_tid == (lwpid_t)GetID()) {
+m_thread_name = procinfo.ki_tdname;
+break;
+  }
+}
+  }
+
+  return m_thread_name.getValue();
+}
 
 lldb::StateType NativeThreadFreeBSD::GetState() { return m_state; }
 


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -74,6 +74,7 @@
   using WatchpointIndexMap = std::map;
   WatchpointIndexMap m_watchpoint_index_map;
   WatchpointIndexMap m_hw_break_index_map;
+  llvm::Optional m_thread_name;
 };
 
 typedef std::shared_ptr NativeThreadFreeBSDSP;
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -22,9 +22,11 @@
 #include 
 #include 
 #include 
+#include 
 // clang-format on
 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -146,7 +148,43 @@
   m_stop_info.reason = StopReason::eStopReasonNone;
 }
 
-std::string NativeThreadFreeBSD::GetName() { return ""; }
+std::string NativeThreadFreeBSD::GetName() {
+  if (!m_thread_name) {
+Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+
+std::vector kp;
+int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+  static_cast(GetProcess().GetID())};
+
+while (1) {
+  size_t len = kp.size() * sizeof(struct kinfo_proc);
+  void *ptr = len == 0 ? nullptr : kp.data();
+  int error = ::sysctl(mib, 4, ptr, &len, nullptr, 0);
+  if (ptr == nullptr || (error != 0 && errno == ENOMEM)) {
+kp.resize(len / sizeof(struct kinfo_proc));
+continue;
+  }
+  if (error != 0) {
+len = 0;
+LLDB_LOG(log, "tid = {0} in state {1} failed to get thread name: {2}", GetID(),
+ m_state, strerror(errno));
+  }
+  kp.resize(len / sizeof(struct kinfo_proc));
+  break;
+}
+
+// empty == unknown
+m_thread_name = std::string();
+for (auto& procinfo : kp) {
+  if (procinfo.ki_tid == (lwpid_t)GetID()) {
+m_thread_name = procinfo.ki_tdname;
+break;
+  }
+}
+  }
+
+  return m_thread_name.getValue();
+}
 
 lldb::StateType NativeThreadF

[Lldb-commits] [PATCH] D90318: Return actual type from SBType::GetArrayElementType

2020-10-28 Thread Andy Yankovsky via Phabricator via lldb-commits
werat created this revision.
werat added reviewers: teemperor, jarin.
Herald added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
werat requested review of this revision.

`SBType::GetArrayElementType` should return the actual type, not the canonical 
type (e.g. `int32_t`, not the underlying `int`).

Added a test case to validate the new behavior. I also ran all other tests on 
Linux (`ninja check-lldb`), they all pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90318

Files:
  lldb/source/API/SBType.cpp
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/type/main.cpp


Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -56,5 +56,8 @@
 // This corresponds to an empty task list.
 Task *empty_task_head = new Task(-1, NULL);
 
+typedef int myint;
+myint myint_arr[] = {1, 2, 3};
+
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -131,3 +131,16 @@
 # (lldb-enumerations.h).
 int_type = id_type.GetBasicType(lldb.eBasicTypeInt)
 self.assertTrue(id_type == int_type)
+
+# Find 'myint_arr' and check the array element type.
+myint_arr = frame0.FindVariable('myint_arr')
+self.assertTrue(myint_arr, VALID_VARIABLE)
+self.DebugSBValue(myint_arr)
+myint_arr_type = myint_arr.GetType()
+self.DebugSBType(myint_arr_type)
+self.assertTrue(myint_arr_type.IsArrayType())
+myint_arr_element_type = myint_arr_type.GetArrayElementType()
+self.DebugSBType(myint_arr_element_type)
+myint_type = target.FindFirstType('myint')
+self.DebugSBType(myint_type)
+self.assertTrue(myint_arr_element_type == myint_type)
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -212,10 +212,8 @@
 
   if (!IsValid())
 return LLDB_RECORD_RESULT(SBType());
-  CompilerType canonical_type =
-  m_opaque_sp->GetCompilerType(true).GetCanonicalType();
-  return LLDB_RECORD_RESULT(SBType(
-  TypeImplSP(new TypeImpl(canonical_type.GetArrayElementType(nullptr);
+  return LLDB_RECORD_RESULT(SBType(TypeImplSP(new TypeImpl(
+  m_opaque_sp->GetCompilerType(true).GetArrayElementType(nullptr);
 }
 
 SBType SBType::GetArrayType(uint64_t size) {


Index: lldb/test/API/python_api/type/main.cpp
===
--- lldb/test/API/python_api/type/main.cpp
+++ lldb/test/API/python_api/type/main.cpp
@@ -56,5 +56,8 @@
 // This corresponds to an empty task list.
 Task *empty_task_head = new Task(-1, NULL);
 
+typedef int myint;
+myint myint_arr[] = {1, 2, 3};
+
 return 0; // Break at this line
 }
Index: lldb/test/API/python_api/type/TestTypeList.py
===
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -131,3 +131,16 @@
 # (lldb-enumerations.h).
 int_type = id_type.GetBasicType(lldb.eBasicTypeInt)
 self.assertTrue(id_type == int_type)
+
+# Find 'myint_arr' and check the array element type.
+myint_arr = frame0.FindVariable('myint_arr')
+self.assertTrue(myint_arr, VALID_VARIABLE)
+self.DebugSBValue(myint_arr)
+myint_arr_type = myint_arr.GetType()
+self.DebugSBType(myint_arr_type)
+self.assertTrue(myint_arr_type.IsArrayType())
+myint_arr_element_type = myint_arr_type.GetArrayElementType()
+self.DebugSBType(myint_arr_element_type)
+myint_type = target.FindFirstType('myint')
+self.DebugSBType(myint_type)
+self.assertTrue(myint_arr_element_type == myint_type)
Index: lldb/source/API/SBType.cpp
===
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -212,10 +212,8 @@
 
   if (!IsValid())
 return LLDB_RECORD_RESULT(SBType());
-  CompilerType canonical_type =
-  m_opaque_sp->GetCompilerType(true).GetCanonicalType();
-  return LLDB_RECORD_RESULT(SBType(
-  TypeImplSP(new TypeImpl(canonical_type.GetArrayElementType(nullptr);
+  return LLDB_RECORD_RESULT(SBType(TypeImplSP(new TypeImpl(
+  m_opaque_sp->GetCompilerType(true).GetArrayElementType(nullptr);
 }
 
 SBType SBType::GetArrayType(uint64_t size) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90318: Return actual type from SBType::GetArrayElementType

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

This was done on purpose, in commit 902974277d507a149e33487d32e4ba58c41451b6 
.  The 
comment there is:

  Data formatters: Look through array element typedefs
  
  Summary:
  Motivation: When formatting an array of typedefed chars, we would like to 
display the array as a string.
  
  The string formatter currently does not trigger because the formatter lookup 
does not resolve typedefs for array elements (this behavior is inconsistent 
with pointers, for those we do look through pointee typedefs). This patch tries 
to make the array formatter lookup somewhat consistent with the pointer 
formatter lookup.

So far as I can tell from the discussion in that review, it removed some lower 
level code that was resolving the typedef too early, then added it at the SB 
layer to preserve previous behavior, even though that behavior was acknowledged 
to be not great.  There was some promise to come back and fix the SB layer 
which it doesn't seem like it even happened.

So this patch seems in line with the intent of the previous revision, but 
Raphael and Greg were the ones active in the review of that older patch, maybe 
they remember more about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90318

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


[Lldb-commits] [PATCH] D90276: [lldb/utils] Add the lldb-env tool

2020-10-28 Thread Vedant Kumar via Phabricator via lldb-commits
vsk abandoned this revision.
vsk added a comment.

Jonas walked me through some of the issues here offline:

- Looks like this makes testing depend on having a configured lldb-env tool, 
this will make it hard to run testing against an lldb root.
- If we need to launch ./bin/lldb in some other workflow, we can consider 
having lldb-env derive all the info it needs from a root lit.site.cfg.py.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90276

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


[Lldb-commits] [PATCH] D90325: [lldb][NFC] Refactor getUUID functionality

2020-10-28 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu created this revision.
zequanwu added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
zequanwu requested review of this revision.
Herald added a subscriber: JDevlieghere.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90325

Files:
  lldb/include/lldb/Utility/UUID.h
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/source/Utility/UUID.cpp

Index: lldb/source/Utility/UUID.cpp
===
--- lldb/source/Utility/UUID.cpp
+++ lldb/source/Utility/UUID.cpp
@@ -35,6 +35,21 @@
   }
 }
 
+UUID UUID::fromData(const UUID::CvRecordPdb70 *debug_info, bool swapByteOrder) {
+  UUID::CvRecordPdb70 swapped;
+  if (swapByteOrder) {
+swapped = *debug_info;
+llvm::sys::swapByteOrder(swapped.Uuid.Data1);
+llvm::sys::swapByteOrder(swapped.Uuid.Data2);
+llvm::sys::swapByteOrder(swapped.Uuid.Data3);
+llvm::sys::swapByteOrder(swapped.Age);
+debug_info = &swapped;
+  }
+  if (debug_info->Age)
+return UUID::fromOptionalData(debug_info, sizeof(*debug_info));
+  return UUID::fromOptionalData(&debug_info->Uuid, sizeof(debug_info->Uuid));
+}
+
 std::string UUID::GetAsString(llvm::StringRef separator) const {
   std::string result;
   llvm::raw_string_ostream os(result);
Index: lldb/source/Plugins/Process/minidump/MinidumpTypes.h
===
--- lldb/source/Plugins/Process/minidump/MinidumpTypes.h
+++ lldb/source/Plugins/Process/minidump/MinidumpTypes.h
@@ -40,21 +40,6 @@
   ElfBuildId = 0x4270454c, // BpEL (Breakpad/Crashpad minidumps)
 };
 
-// Reference:
-// https://crashpad.chromium.org/doxygen/structcrashpad_1_1CodeViewRecordPDB70.html
-struct CvRecordPdb70 {
-  struct {
-llvm::support::ulittle32_t Data1;
-llvm::support::ulittle16_t Data2;
-llvm::support::ulittle16_t Data3;
-uint8_t Data4[8];
-  } Uuid;
-  llvm::support::ulittle32_t Age;
-  // char PDBFileName[];
-};
-static_assert(sizeof(CvRecordPdb70) == 20,
-  "sizeof CvRecordPdb70 is not correct!");
-
 enum class MinidumpMiscInfoFlags : uint32_t {
   ProcessID = (1 << 0),
   ProcessTimes = (1 << 1),
Index: lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -62,27 +62,12 @@
   static_cast(static_cast(*signature));
 
   if (cv_signature == CvSignature::Pdb70) {
-const CvRecordPdb70 *pdb70_uuid = nullptr;
+const UUID::CvRecordPdb70 *pdb70_uuid = nullptr;
 Status error = consumeObject(cv_record, pdb70_uuid);
 if (error.Fail())
   return UUID();
-
-CvRecordPdb70 swapped;
-if (!GetArchitecture().GetTriple().isOSBinFormatELF()) {
-  // LLDB's UUID class treats the data as a sequence of bytes, but breakpad
-  // interprets it as a sequence of little-endian fields, which it converts
-  // to big-endian when converting to text. Swap the bytes to big endian so
-  // that the string representation comes out right.
-  swapped = *pdb70_uuid;
-  llvm::sys::swapByteOrder(swapped.Uuid.Data1);
-  llvm::sys::swapByteOrder(swapped.Uuid.Data2);
-  llvm::sys::swapByteOrder(swapped.Uuid.Data3);
-  llvm::sys::swapByteOrder(swapped.Age);
-  pdb70_uuid = &swapped;
-}
-if (pdb70_uuid->Age != 0)
-  return UUID::fromOptionalData(pdb70_uuid, sizeof(*pdb70_uuid));
-return UUID::fromOptionalData(&pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid));
+return UUID::fromData(pdb70_uuid,
+  !GetArchitecture().GetTriple().isOSBinFormatELF());
   } else if (cv_signature == CvSignature::ElfBuildId)
 return UUID::fromOptionalData(cv_record);
 
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -43,45 +43,16 @@
 
 LLDB_PLUGIN_DEFINE(ObjectFilePECOFF)
 
-struct CVInfoPdb70 {
-  // 16-byte GUID
-  struct _Guid {
-llvm::support::ulittle32_t Data1;
-llvm::support::ulittle16_t Data2;
-llvm::support::ulittle16_t Data3;
-uint8_t Data4[8];
-  } Guid;
-
-  llvm::support::ulittle32_t Age;
-};
-
 static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj) {
   const llvm::codeview::DebugInfo *pdb_info = nullptr;
   llvm::StringRef pdb_file;
 
-  // This part is similar with what has done in minidump parser.
   if (!coff_obj.getDebugPDBInfo(pdb_info, pdb_file) && pdb_info) {
 if (pdb_info->PDB70.CVSignature == llvm::OMF::Signature::PDB70) {
-  using llvm::support::endian::read

[Lldb-commits] [PATCH] D90318: Return actual type from SBType::GetArrayElementType

2020-10-28 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin accepted this revision.
jarin added a comment.
This revision is now accepted and ready to land.

The code change looks good to me and it is in line with the change that Raphael 
and Greg wanted in https://reviews.llvm.org/D72133. As far as I remember, 
https://reviews.llvm.org/D72133 did not change the previous behavior because I 
felt that changing API semantics was out of scope of what I wanted to do with 
the formatters.

Someone else should look at the test. The addition seems to be a bit ad-hoc, 
but overall reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90318

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


[Lldb-commits] [lldb] 158f336 - [lldb] Delete lldb/utils/test

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

Author: Vedant Kumar
Date: 2020-10-28T12:06:02-07:00
New Revision: 158f3360438f92cefc60041dcb8db980d7d1c744

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

LOG: [lldb] Delete lldb/utils/test

These utilities aren't useful any more -- delete them as a cleanup.

Discussion:
http://lists.llvm.org/pipermail/lldb-dev/2020-October/016536.html

Added: 


Modified: 


Removed: 
lldb/utils/test/README-disasm
lldb/utils/test/README-lldb-disasm
lldb/utils/test/README-run-until-faulted
lldb/utils/test/disasm.py
lldb/utils/test/lldb-disasm.py
lldb/utils/test/llvm-mc-shell.py
lldb/utils/test/main.c
lldb/utils/test/ras.py
lldb/utils/test/run-dis.py
lldb/utils/test/run-until-faulted.py



diff  --git a/lldb/utils/test/README-disasm b/lldb/utils/test/README-disasm
deleted file mode 100644
index 00e9ab681a24..
--- a/lldb/utils/test/README-disasm
+++ /dev/null
@@ -1,406 +0,0 @@
-This README describes a sample invocation of disasm.py whose purpose is to test
-the low level ARM/Thumb disassembly functionality from llvm using the llvm-mc
-command line.  We invoke gdb on an executable, try to disassemble a function,
-and then read the memory contents of the disassembled function.
-
-The byte contents are written into a file named disasm-input.txt and then we
-invoke llvm-mc -disassemble plus options (set with the -o/--options) on the
-byte contents.
-
-See the following for a sample session using this command:
-
-[16:26:57] johnny:/Volumes/data/Radar/9131529 $ 
/Volumes/data/lldb/svn/trunk/utils/test/disasm.py -C 'set 
shlib-path-substitutions /usr 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr 
/System 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System 
/Library 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library' 
-O '-arch armv7' -m /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -e 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
 -f printf --options='-triple=thumb-apple-darwin -debug-only=arm-disassembler'
-gdb commands: ['set shlib-path-substitutions /usr 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr 
/System 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System 
/Library 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library']
-gdb options: -arch armv7
-executable: 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
-function: printf
-llvm-mc: /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc
-llvm-mc options: -triple=thumb-apple-darwin -debug-only=arm-disassembler
-GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
-Copyright 2004 Free Software Foundation, Inc.
-GDB is free software, covered by the GNU General Public License, and you are
-welcome to change it and/or distribute copies of it under certain conditions.
-Type "show copying" to see the conditions.
-There is absolutely no warranty for GDB.  Type "show warranty" for details.
-This GDB was configured as "--host=x86_64-apple-darwin 
--target=arm-apple-darwin".
-: push{r0, r1, r2, r3}
-0x0704cdd2 : push{r4, r5, r7, lr}
-0x0704cdd4 : add r7, sp, #8
-0x0704cdd6 : sub sp, #4
-0x0704cdd8 : add r3, sp, #20
-0x0704cdda :ldr.w   r5, [r3], #4
-0x0704cdde :str r3, [sp, #0]
-0x0704cde0 :ldr r3, [pc, #52]   (0x704ce18 )
-0x0704cde2 :add r3, pc
-0x0704cde4 :ldr r0, [r3, #0]
-0x0704cde6 :ldr r4, [r0, #0]
-0x0704cde8 :ldr r0, [pc, #48]   (0x704ce1c )
-0x0704cdea :add r0, pc
-0x0704cdec :ldr r0, [r0, #0]
-0x0704cdee :ldr r0, [r0, #0]
-0x0704cdf0 :blx 0x707ba30 
-0x0704cdf4 :cbnzr0, 0x704cdfe 
-0x0704cdf6 :ldr r1, [pc, #40]   (0x704ce20 )
-0x0704cdf8 :add r1, pc
-0x0704cdfa :ldr r1, [r1, #0]
-0x0704cdfc :b.n 0x704ce00 
-0x0704cdfe :mov r1, r0
-0x0704ce00 :mov r0, r4
-0x0704ce02 :mov r2, r5
-0x0704ce04 :ldr r3, [sp, #0]
-0x0704ce06 :bl  0x704ad44 
-0x0704ce0a :sub.w   sp, r7, #8  ; 0x8
-0x0704ce0e :ldmia.w sp!, {r4, r5, r7, lr}
-0x0704ce12 :add sp, #16
-0x0704ce14 :bx  lr
-0x0704ce16 :nop
-0x0704ce18 :movsr3, #142
-0x0704ce1a :lslsr5, r0, #0
-0x0704ce1c :addsr1, #122
-0x0704ce1e :lslsr5, r0, #0
-0x0704ce20 :addsr1, #104
-0x0704ce22 :lslsr5, r0, #0
-End of assembler dump.
-(gdb) x /2b 0x0704cdd0
-0x704cdd0 :0x0f0xb4
-(gdb) x /2b 0x0704

[Lldb-commits] [PATCH] D90325: [lldb][NFC] Refactor getUUID functionality

2020-10-28 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu updated this revision to Diff 301378.
zequanwu added a comment.

include correct header


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90325

Files:
  lldb/include/lldb/Utility/UUID.h
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/source/Utility/UUID.cpp

Index: lldb/source/Utility/UUID.cpp
===
--- lldb/source/Utility/UUID.cpp
+++ lldb/source/Utility/UUID.cpp
@@ -35,6 +35,21 @@
   }
 }
 
+UUID UUID::fromData(const UUID::CvRecordPdb70 *debug_info, bool swapByteOrder) {
+  UUID::CvRecordPdb70 swapped;
+  if (swapByteOrder) {
+swapped = *debug_info;
+llvm::sys::swapByteOrder(swapped.Uuid.Data1);
+llvm::sys::swapByteOrder(swapped.Uuid.Data2);
+llvm::sys::swapByteOrder(swapped.Uuid.Data3);
+llvm::sys::swapByteOrder(swapped.Age);
+debug_info = &swapped;
+  }
+  if (debug_info->Age)
+return UUID::fromOptionalData(debug_info, sizeof(*debug_info));
+  return UUID::fromOptionalData(&debug_info->Uuid, sizeof(debug_info->Uuid));
+}
+
 std::string UUID::GetAsString(llvm::StringRef separator) const {
   std::string result;
   llvm::raw_string_ostream os(result);
Index: lldb/source/Plugins/Process/minidump/MinidumpTypes.h
===
--- lldb/source/Plugins/Process/minidump/MinidumpTypes.h
+++ lldb/source/Plugins/Process/minidump/MinidumpTypes.h
@@ -40,21 +40,6 @@
   ElfBuildId = 0x4270454c, // BpEL (Breakpad/Crashpad minidumps)
 };
 
-// Reference:
-// https://crashpad.chromium.org/doxygen/structcrashpad_1_1CodeViewRecordPDB70.html
-struct CvRecordPdb70 {
-  struct {
-llvm::support::ulittle32_t Data1;
-llvm::support::ulittle16_t Data2;
-llvm::support::ulittle16_t Data3;
-uint8_t Data4[8];
-  } Uuid;
-  llvm::support::ulittle32_t Age;
-  // char PDBFileName[];
-};
-static_assert(sizeof(CvRecordPdb70) == 20,
-  "sizeof CvRecordPdb70 is not correct!");
-
 enum class MinidumpMiscInfoFlags : uint32_t {
   ProcessID = (1 << 0),
   ProcessTimes = (1 << 1),
Index: lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -62,27 +62,12 @@
   static_cast(static_cast(*signature));
 
   if (cv_signature == CvSignature::Pdb70) {
-const CvRecordPdb70 *pdb70_uuid = nullptr;
+const UUID::CvRecordPdb70 *pdb70_uuid = nullptr;
 Status error = consumeObject(cv_record, pdb70_uuid);
 if (error.Fail())
   return UUID();
-
-CvRecordPdb70 swapped;
-if (!GetArchitecture().GetTriple().isOSBinFormatELF()) {
-  // LLDB's UUID class treats the data as a sequence of bytes, but breakpad
-  // interprets it as a sequence of little-endian fields, which it converts
-  // to big-endian when converting to text. Swap the bytes to big endian so
-  // that the string representation comes out right.
-  swapped = *pdb70_uuid;
-  llvm::sys::swapByteOrder(swapped.Uuid.Data1);
-  llvm::sys::swapByteOrder(swapped.Uuid.Data2);
-  llvm::sys::swapByteOrder(swapped.Uuid.Data3);
-  llvm::sys::swapByteOrder(swapped.Age);
-  pdb70_uuid = &swapped;
-}
-if (pdb70_uuid->Age != 0)
-  return UUID::fromOptionalData(pdb70_uuid, sizeof(*pdb70_uuid));
-return UUID::fromOptionalData(&pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid));
+return UUID::fromData(pdb70_uuid,
+  !GetArchitecture().GetTriple().isOSBinFormatELF());
   } else if (cv_signature == CvSignature::ElfBuildId)
 return UUID::fromOptionalData(cv_record);
 
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -43,45 +43,16 @@
 
 LLDB_PLUGIN_DEFINE(ObjectFilePECOFF)
 
-struct CVInfoPdb70 {
-  // 16-byte GUID
-  struct _Guid {
-llvm::support::ulittle32_t Data1;
-llvm::support::ulittle16_t Data2;
-llvm::support::ulittle16_t Data3;
-uint8_t Data4[8];
-  } Guid;
-
-  llvm::support::ulittle32_t Age;
-};
-
 static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj) {
   const llvm::codeview::DebugInfo *pdb_info = nullptr;
   llvm::StringRef pdb_file;
 
-  // This part is similar with what has done in minidump parser.
   if (!coff_obj.getDebugPDBInfo(pdb_info, pdb_file) && pdb_info) {
 if (pdb_info->PDB70.CVSignature == llvm::OMF::Signature::PDB70) {
-  using llvm::support::endian::read16be;
-  using llvm::support::endian::read32be;
-
-

[Lldb-commits] [PATCH] D90332: Mark the execution of commands in stop hooks as non-interactive

2020-10-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
jingham requested review of this revision.

stop-hooks were not intended to be interactive, that would be really confusing 
when there are many in flight.  So this patch marks the results as 
non-interactive.

Beyond correctness, then main reason for doing this patch is that when you go 
to run a command based stop hook that includes a Python command, if the command 
is marked as interactive, Python would try to act on stdin (fflush it) when 
switching to the Python Session, and if stdin was backed by an lldb NativeFile, 
the the fflush would deadlock against the I/O handler thread that was sitting 
in read on the same file handle.

That is a more general problem that this patch does not address.  The only 
place it has shown up IRL is in this scenario, and since doing the right thing 
for the stop-hook execution works around it, the more general fix can wait on 
somebody else's free time.  But I did add a test that will deadlock without 
this patch, and succeeds with it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90332

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/api/multithreaded/TestMultithreaded.py
  lldb/test/API/api/multithreaded/some_cmd.py
  lldb/test/API/api/multithreaded/test_stop-hook.cpp.template

Index: lldb/test/API/api/multithreaded/test_stop-hook.cpp.template
===
--- /dev/null
+++ lldb/test/API/api/multithreaded/test_stop-hook.cpp.template
@@ -0,0 +1,130 @@
+// LLDB C++ API Test: Verify that when the Debugger stdin
+// is set to a FILE *, lldb can still successfully run a
+// python command in a stop hook.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+%include_SB_APIs%
+
+#include "common.h"
+
+using namespace lldb;
+
+void test(SBDebugger &dbg, std::vector args) {
+  // The problem we had was that when the thread that was
+  // waiting on input went into the call to 'read' it had
+  // the file handle lock.  Then when the python interpreter
+  // Initialized itself to run the python command, it tried
+  // to flush the file channel, and that deadlocked.
+  // This only happens when Async is true, since otherwise
+  // the process event is handled on the I/O read thread,
+  // which sidestepped the problem.
+  dbg.SetAsync(true);
+
+  SBTarget target = dbg.CreateTarget(args.at(0).c_str());
+  if (!target.IsValid())
+throw Exception("invalid target");
+
+  SBBreakpoint breakpoint = target.BreakpointCreateByName("next");
+  if (!breakpoint.IsValid())
+throw Exception("invalid breakpoint");
+
+  SBCommandInterpreter interp = dbg.GetCommandInterpreter();
+  SBCommandReturnObject result;
+
+  // Bring in the python command. We actually add two commands,
+  // one that runs in the stop hook and sets a variable when it
+  // runs, and one that reports out the variable so we can ensure
+  // that we did indeed run the stop hook.
+  const char *source_dir = "%SOURCE_DIR%";
+  SBFileSpec script_spec(source_dir);
+  script_spec.AppendPathComponent("some_cmd.py");
+  char path[PATH_MAX];
+  script_spec.GetPath(path, PATH_MAX);
+
+  std::string import_command("command script import ");
+  import_command.append(path);
+  interp.HandleCommand(import_command.c_str(), result);
+  if (!result.Succeeded())
+throw Exception("Couldn't import %SOURCE_DIR%/some_cmd.py");
+
+  SBProcess process = target.LaunchSimple(nullptr, nullptr, nullptr);
+  if (!process.IsValid())
+throw Exception("Couldn't launch process.");
+  if (process.GetState() != lldb::eStateStopped)
+throw Exception("Process was not stopped");
+
+  process.SetSelectedThreadByIndexID(0);
+
+  // Now add the stop hook:
+  interp.HandleCommand("target stop-hook add -o some-cmd", result);
+  if (!result.Succeeded())
+throw Exception("Couldn't add a stop hook.");
+
+  // Now switch the I/O over to a pipe, which will be handled by the
+  // NativeFile class:
+  int to_lldb_des[2];
+  int pipe_result = pipe(to_lldb_des);
+  FILE *fh_lldb_in = fdopen(to_lldb_des[0], "r");
+  FILE *fh_to_lldb = fdopen(to_lldb_des[1], "w");
+
+  // We need to reset the handle before destroying the debugger
+  // or the same deadlock will stall exiting:
+  class Cleanup {
+  public:
+Cleanup(SBDebugger dbg, int filedes[2]) : m_dbg(dbg) {
+  m_file = m_dbg.GetInputFileHandle();
+  m_filedes[0] = filedes[0];
+  m_filedes[1] = filedes[1];
+}
+~Cleanup() {
+  m_dbg.SetInputFileHandle(m_file, false);
+  close(m_filedes[0]);
+  close(m_filedes[1]);
+}
+
+  private:
+FILE *m_file;
+SBDebugger m_dbg;
+int m_filedes[2];
+  };
+  Cleanup cleanup(dbg, to_lldb_des);
+
+  dbg.SetInputFileHandle(fh_lldb_in, false);
+
+  // Now run the command interpreter.  You have to 

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

2020-10-28 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 301450.
aadsm added a comment.

- Fixed formatting issues
- Updated comment on the reason we need to do this
- Improved the lit test by also checking how many matches it found


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87172

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/Shell/SymbolFile/DWARF/line-entries-invalid-addresses.yaml

Index: lldb/test/Shell/SymbolFile/DWARF/line-entries-invalid-addresses.yaml
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/line-entries-invalid-addresses.yaml
@@ -0,0 +1,421 @@
+# RUN: yaml2obj %s > %t
+# RUN: %lldb %t -b -o "image lookup -f main.cpp -l 2 -v" | FileCheck %s
+# CHECK: 1 match found in main.cpp:2 {{.*}}
+# CHECK: LineEntry: {{.*}}main.cpp:2:{{.*}}
+
+# int foo() {
+# return 42;
+# }
+#
+# int main() {
+# int x = foo();
+# return x;
+# }
+# dwarfdump -debug-line:
+# AddressLine   Column File   ISA Discriminator Flags
+# -- -- -- -- --- - -
+# 0x00010f80  1  0  1   0 0  is_stmt
+# 0x00010f84  2  5  1   0 0  is_stmt prologue_end
+# 0x00010f8b  2  5  1   0 0  is_stmt end_sequence
+# 0x00010f90  5  0  1   0 0  is_stmt
+# 0x00010f90  5  0  1   0 0  is_stmt end_sequence
+# 0x000f  2 13  1   0 0  is_stmt prologue_end
+# 0x0014  2  9  1   0 0
+# 0x0017  3 12  1   0 0  is_stmt
+# 0x001d  3 12  1   0 0  end_sequence
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x0107
+  cpusubtype:  0x0003
+  filetype:0x000A
+  ncmds:   7
+  sizeofcmds:  1400
+  flags:   0x
+  reserved:0x
+LoadCommands:
+  - cmd: LC_UUID
+cmdsize: 24
+uuid:605D6BBF-4DB2-39F7-8068-F9BB3896DF0C
+  - cmd: LC_BUILD_VERSION
+cmdsize: 24
+platform:1
+minos:   659200
+sdk: 659206
+ntools:  0
+  - cmd: LC_SYMTAB
+cmdsize: 24
+symoff:  4096
+nsyms:   3
+stroff:  4144
+strsize: 37
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __PAGEZERO
+vmaddr:  0
+vmsize:  1
+fileoff: 0
+filesize:0
+maxprot: 0
+initprot:0
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 232
+segname: __TEXT
+vmaddr:  4294967296
+vmsize:  4096
+fileoff: 0
+filesize:0
+maxprot: 5
+initprot:5
+nsects:  2
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x00010F80
+size:48
+offset:  0x
+align:   4
+reloff:  0x
+nreloc:  0
+flags:   0x8400
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+content: CFFAEDFE070103000A00070078051B001800605D6BBF4DB239F7
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x00010FB0
+size:72
+offset:  0x
+align:   2
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+content: CFFAEDFE070103000A00070078051B001800605D6BBF4DB239F78068F9BB3896DF0C32001800010F0A00
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __LINKEDIT
+vmaddr:  4294971392
+vmsize:  4096
+fileoff: 4096
+filesize:85
+maxprot: 1
+initprot:1
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 952
+segname: __DWARF
+vmaddr:  4294975488
+vmsize:  4096
+fileoff: 8192
+filesize:839
+maxprot: 7
+initprot:3
+nsects:  4
+flags:   0
+Section

[Lldb-commits] [PATCH] D89157: [lldb] Report old modules from ModuleList::ReplaceEquivalent

2020-10-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

I can't see anything wrong with this, it seems to follow the practice of other 
parts of GetSharedModule.  I'm still not quite certain why I've never seen an 
instance where the absence of your fix has caused problems, and it isn't clear 
from the patch why that is.  If there something special about handling breakpad 
files that moves you out of the normal code path for replacing overridden 
modules?  So I still have a lurking feeling I'm missing something?

OTOH, seems like any time you find that one module is a newer version of one 
you held onto you should mention it, so this seems okay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89157

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


[Lldb-commits] [lldb] 49c84fd - Revert "[AppleObjCRuntimeV2] Force lazily allocated class names to be resolved."

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

Author: Jonas Devlieghere
Date: 2020-10-28T16:53:02-07:00
New Revision: 49c84fd5a4bd88cbf61ac6888a66c5da07705c5e

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

LOG: Revert "[AppleObjCRuntimeV2] Force lazily allocated class names to be 
resolved."

We're no longer convinced that this is needed and we have no test
coverage to disprove that. Backing out of this change until we're
convinced otherwise.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index d8be2b48da19..f7247b2fb955 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1178,28 +1178,6 @@ AppleObjCRuntimeV2::GetClassDescriptorFromISA(ObjCISA 
isa) {
   return class_descriptor_sp;
 }
 
-static std::pair ObjCGetClassNameRaw(
-  AppleObjCRuntime::ObjCISA isa,
-  Process *process) {
-  StreamString expr_string;
-  std::string input = std::to_string(isa);
-  expr_string.Printf("(const char *)objc_debug_class_getNameRaw(%s)",
- input.c_str());
-
-  ValueObjectSP result_sp;
-  EvaluateExpressionOptions eval_options;
-  eval_options.SetLanguage(lldb::eLanguageTypeObjC);
-  eval_options.SetResultIsInternal(true);
-  eval_options.SetGenerateDebugInfo(true);
-  eval_options.SetTimeout(process->GetUtilityExpressionTimeout());
-  auto eval_result = process->GetTarget().EvaluateExpression(
-  expr_string.GetData(),
-  process->GetThreadList().GetSelectedThread()->GetSelectedFrame().get(),
-  result_sp, eval_options);
-  ConstString type_name(result_sp->GetSummaryAsCString());
-  return std::make_pair(eval_result == eExpressionCompleted, type_name);
-}
-
 ObjCLanguageRuntime::ClassDescriptorSP
 AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
   ClassDescriptorSP objc_class_sp;
@@ -1235,10 +1213,7 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject 
&valobj) {
 return objc_class_sp;
 
   objc_class_sp = GetClassDescriptorFromISA(isa);
-
-  if (objc_class_sp)
-return objc_class_sp;
-  else {
+  if (isa && !objc_class_sp) {
 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS |
   LIBLLDB_LOG_TYPES));
 LLDB_LOGF(log,
@@ -1247,13 +1222,6 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject 
&valobj) {
   "not in class descriptor cache 0x%" PRIx64,
   isa_pointer, isa);
   }
-
-  ClassDescriptorSP descriptor_sp(new ClassDescriptorV2(*this, isa, nullptr));
-  auto resolved = ObjCGetClassNameRaw(isa, process);
-  if (resolved.first == true) {
-AddClass(isa, descriptor_sp, resolved.second.AsCString());
-objc_class_sp = descriptor_sp;
-  }
   return objc_class_sp;
 }
 



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


[Lldb-commits] [PATCH] D89999: [lldb] Implement ObjCGetClassNameRaw using a UtilityFunction

2020-10-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere abandoned this revision.
JDevlieghere added a comment.

49c84fd5a4bd 



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

https://reviews.llvm.org/D8

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


[Lldb-commits] [PATCH] D87173: Ignores functions that have a range starting outside of a code section

2020-10-28 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 301503.
aadsm added a comment.

Rewrote the test in lit.

I had to do it in an non standard way. It seems that lldb will exit with an 
error code if you do -b -o of a command that doesn't "work", (e.g.: image 
lookup finds nothing). Since lit runs this with set -o pipefail it will fail 
the FileCheck as well. To get around that I did echo ``, a bit lame but works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87173

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/function-entries-invalid-addresses.yaml

Index: lldb/test/Shell/SymbolFile/DWARF/function-entries-invalid-addresses.yaml
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/function-entries-invalid-addresses.yaml
@@ -0,0 +1,360 @@
+# RUN: yaml2obj %s > %t
+# RUN: %lldb %t -o "image lookup -F main" | FileCheck --check-prefix MAIN %s
+# MAIN: 1 match found {{.*}}
+
+# Using echo `` because image lookup -F foo will make lldb exit with code 1
+# RUN: echo `%lldb %t -o "image lookup -F foo"` | FileCheck --check-prefix FOO %s
+# FOO-NOT: 1 match found {{.*}}
+
+# int foo() {
+# return 1;
+# }
+#
+# int main() {
+# return 0;
+# }
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x0107
+  cpusubtype:  0x0003
+  filetype:0x000A
+  ncmds:   7
+  sizeofcmds:  1400
+  flags:   0x
+  reserved:0x
+LoadCommands:
+  - cmd: LC_UUID
+cmdsize: 24
+uuid:FD292DBF-A309-369B-A588-00E20D0E84CF
+  - cmd: LC_BUILD_VERSION
+cmdsize: 24
+platform:1
+minos:   659200
+sdk: 659206
+ntools:  0
+  - cmd: LC_SYMTAB
+cmdsize: 24
+symoff:  4096
+nsyms:   3
+stroff:  4144
+strsize: 33
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __PAGEZERO
+vmaddr:  0
+vmsize:  4294967296
+fileoff: 0
+filesize:0
+maxprot: 0
+initprot:0
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 232
+segname: __TEXT
+vmaddr:  4294967296
+vmsize:  16384
+fileoff: 0
+filesize:0
+maxprot: 5
+initprot:5
+nsects:  2
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x00013FA0
+size:24
+offset:  0x
+align:   4
+reloff:  0x
+nreloc:  0
+flags:   0x8400
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+content: CFFAEDFE070103000A0007007805
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x00013FB8
+size:72
+offset:  0x
+align:   2
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+content: CFFAEDFE070103000A00070078051B001800FD292DBFA309369BA58800E20D0E84CF32001800010F0A00
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __LINKEDIT
+vmaddr:  4294983680
+vmsize:  4096
+fileoff: 4096
+filesize:81
+maxprot: 1
+initprot:1
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 952
+segname: __DWARF
+vmaddr:  4294987776
+vmsize:  4096
+fileoff: 8192
+filesize:826
+maxprot: 7
+initprot:3
+nsects:  6
+flags:   0
+Sections:
+  - sectname:__debug_pubnames
+segname: __DWARF
+addr:0x00015052
+size:35
+offset:  0x2052
+align:   0
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  -