[Lldb-commits] [PATCH] D109797: Fix rendezvous for rebase_exec=true case

2021-09-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Since the meaning of `m_initial_modules_added` is basically "should I do a full 
scan through the linked list" and LoadAllCurrentModules (called from DidAttach) 
does a full scan, it seems to me the real bug is that this function does not 
set `m_initial_modules_added = true`. Would that fix your issue?

Also, what makes Android 28 special? Is it the presence/absence of a dynamic 
linker symlink? I'm wondering if we could reproduce (test) this more generally 
by ensuring we launch a binary through a symlink (or not).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109797

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


[Lldb-commits] [PATCH] D109777: [lldb] [Windows] Fix continuing from breakpoints and singlestepping on ARM/AArch64

2021-09-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

The real issue here is that there are two implementations in the first place. 
The lldb-server method is supposed to be the new thing, and the old should go 
away as soon as the new one is good enough. Therefore I wouldn't spend too much 
time trying to unify these. Rather, if anyone has the time, I'd recommend 
seeing what features does the lldb-server thing lack so it can be made the 
default one.




Comment at: 
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp:495-514
+int breakpoint_size = 1;
+switch (GetArchitecture().GetMachine()) {
+case llvm::Triple::aarch64:
+  breakpoint_size = 4;
+  break;
+
+case llvm::Triple::arm:

This should be the job of `GetSoftwareBreakpointPCOffset`, although the default 
implementation of that function returns zero for arm. If that is not desired 
(does windows automatically increment the PC or something?), then I guess you 
should override that function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109777

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


[Lldb-commits] [PATCH] D109272: [lldb] [gdb-remote] Try using for remote arch unconditionally

2021-09-16 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.

Sounds like a good idea.


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

https://reviews.llvm.org/D109272

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


[Lldb-commits] [PATCH] D108831: [lldb] [gdb-remote] Add x86_64 pseudo-registers when using gdbserver

2021-09-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext_x86.cpp:37-54
+static std::array partial_gpr_regs = {{
+{"rax", {{"eax"}, {"ax"}, {"ah"}, {"al"}}},
+{"rbx", {{"ebx"}, {"bx"}, {"bh"}, {"bl"}}},
+{"rcx", {{"ecx"}, {"cx"}, {"ch"}, {"cl"}}},
+{"rdx", {{"edx"}, {"dx"}, {"dh"}, {"dl"}}},
+{"rdi", {{"edi"}, {"di"}, {nullptr}, {"dil"}}},
+{"rsi", {{"esi"}, {"si"}, {nullptr}, {"sil"}}},

mgorny wrote:
> Also here I'm wondering if it wouldn't be better to just have an array of 
> `{"ax", "bx", ...}` and construct all other names from that base, plus 
> r8..r15 via numeric `for` loop.
I don't have a strong opinion on this. The names are sufficiently irregular 
that the other approach will (probably) be messy as well.

I'm more bothered by the fact that you're writing into these global variables. 
IIRC, the DynamicRegisterInfo class has some sort of a buffer to store the 
array data. It would be good to reuse that (or do something similar).



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext_x86.cpp:66-75
+static std::array mm_regs = {{
+{"st0", "mm0"},
+{"st1", "mm1"},
+{"st2", "mm2"},
+{"st3", "mm3"},
+{"st4", "mm4"},
+{"st5", "mm5"},

mgorny wrote:
> I've been somewhat basing this thing on how our process plugins do registers 
> but I'm wondering if it wouldn't be better to just do a `for (int x = 0; i < 
> 8; i++)` loop and dynamically generate `st${x}` and `mm${x}` names.
The loop idea seems reasonable here.


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

https://reviews.llvm.org/D108831

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


[Lldb-commits] [PATCH] D109777: [lldb] [Windows] Fix continuing from breakpoints and singlestepping on ARM/AArch64

2021-09-16 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

One thing that I forgot to ask, are there already tests that cover the scenario 
the bug reported?

Good chance there are but they only run on x86 due to the available bots. We 
(Linaro) are working to get more tests running on WoA bots so this would be 
covered eventually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109777

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


[Lldb-commits] [lldb] 6624932 - [lldb] [gdb-remote] Try using for remote arch unconditionally

2021-09-16 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-09-16T10:23:31+02:00
New Revision: 66249323d25f6db1dc76bd9fb3b9eebe436519a6

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

LOG: [lldb] [gdb-remote] Try using  for remote arch 
unconditionally

Try determining the process architecture from  tag
unconditionally, rather than for very specific cases.  Generic gdbserver
implementations do not support LLDB-specific packets used to determine
the process architecture, therefore this fallback is necessary to
support architecture-specific behavior on these targets.  Rather than
maintaining a mapping of all known architectures, just try mapping
the GDB values into triplets, as that is going to work most of the time.

This change is confirmed to fix LLDB against gdbserver when debugging
i386 and aarch64 executables.

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

Added: 
lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-i386.yaml

Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index b08fe3819bb97..87ad0a377ae2e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4649,24 +4649,22 @@ bool 
ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess(
   }
 }
 
-// If the target.xml includes an architecture entry like
+// gdbserver does not implement the LLDB packets used to determine host
+// or process architecture.  If that is the case, attempt to use
+// the  field from target.xml, e.g.:
+//
 //   i386:x86-64 (seen from VMWare ESXi)
-//   arm (seen from Segger JLink on 
unspecified arm board)
-// use that if we don't have anything better.
+//   arm (seen from Segger JLink on 
unspecified
+//   arm board)
 if (!arch_to_use.IsValid() && !target_info.arch.empty()) {
-  if (target_info.arch == "i386:x86-64") {
-// We don't have any information about vendor or OS.
-arch_to_use.SetTriple("x86_64--");
-GetTarget().MergeArchitecture(arch_to_use);
-  }
+  // We don't have any information about vendor or OS.
+  arch_to_use.SetTriple(llvm::StringSwitch(target_info.arch)
+.Case("i386:x86-64", "x86_64")
+.Default(target_info.arch) +
+"--");
 
-  // SEGGER J-Link jtag boards send this very-generic arch name,
-  // we'll need to use this if we have absolutely nothing better
-  // to work with or the register definitions won't be accepted.
-  if (target_info.arch == "arm") {
-arch_to_use.SetTriple("arm--");
+  if (arch_to_use.IsValid())
 GetTarget().MergeArchitecture(arch_to_use);
-  }
 }
 
 if (arch_to_use.IsValid()) {

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 255e36a3104a8..eabd7d807f5b3 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -150,3 +150,264 @@ def haltReason(self):
["rip = 0x8887868584838281"])
 self.match("register read flags",
["eflags = 0x94939291"])
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("X86")
+def test_i386_regs(self):
+"""Test grabbing various i386 registers from gdbserver."""
+reg_data = [
+"01020304",  # eax
+"11121314",  # ecx
+"21222324",  # edx
+"31323334",  # ebx
+"41424344",  # esp
+"51525354",  # ebp
+"61626364",  # esi
+"71727374",  # edi
+"81828384",  # eip
+"91929394",  # eflags
+"0102030405060708090a",  # st0
+"1112131415161718191a",  # st1
+] + 6 * [
+"2122232425262728292a"  # st2..st7
+] + [
+"8182838485868788898a8b8c8d8e8f90",  # xmm0
+"9192939495969798999a9b9c9d9e9fa0",  # xmm1
+] + 6 * [
+"a1a2a3a4a5a6a7a8a9aaabacadaeafb0",  # xmm2..xmm7
+] + [
+"",  # mxcsr
+] + [
+"b1b2b3b4b5b6b7b8b9babbbcbdbebfc0",  # ymm0h
+"c1c2c3c4c5c6c7c8c9cacbcccdcecfd0",  # ymm1h
+] + 6 * [
+"d1d2d3d4d5d6d7d8d9dadbdcdddedfe0",  # ymm2h..ymm7h
+]
+
+class MyRespond

[Lldb-commits] [lldb] c208deb - [lldb] [ABI/AArch64] Recognize special regs by their xN names too

2021-09-16 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-09-16T10:23:31+02:00
New Revision: c208deb9008260d3effc00c98493434a65af4b8d

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

LOG: [lldb] [ABI/AArch64] Recognize special regs by their xN names too

Recognize lr/sp/fp by their numeric register names in the ABI plugin.
This is necessary to mark them appropriately when interfacing with
gdbserver.

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

Added: 


Modified: 
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 42d73ce39ed6f..619c45dc12ec2 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -55,9 +55,9 @@ std::string ABIAArch64::GetMCName(std::string reg) {
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
-  .Case("lr", LLDB_REGNUM_GENERIC_RA)
-  .Case("sp", LLDB_REGNUM_GENERIC_SP)
-  .Case("fp", LLDB_REGNUM_GENERIC_FP)
+  .Cases("lr", "x30", LLDB_REGNUM_GENERIC_RA)
+  .Cases("sp", "x31", LLDB_REGNUM_GENERIC_SP)
+  .Cases("fp", "x29", LLDB_REGNUM_GENERIC_FP)
   .Case("cpsr", LLDB_REGNUM_GENERIC_FLAGS)
   .Case("x0", LLDB_REGNUM_GENERIC_ARG1)
   .Case("x1", LLDB_REGNUM_GENERIC_ARG2)

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index eabd7d807f5b3..13d7804286138 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -409,5 +409,11 @@ def haltReason(self):
["x0 = 0x0807060504030201"])
 self.match("register read arg2",
["x1 = 0x1817161514131211"])
+self.match("register read fp",
+   ["x29 = 0x3837363534333231"])
+self.match("register read lr",
+   ["x30 = 0x4847464544434241"])
+self.match("register read ra",
+   ["x30 = 0x4847464544434241"])
 self.match("register read flags",
["cpsr = 0x74737271"])



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


[Lldb-commits] [PATCH] D109272: [lldb] [gdb-remote] Try using for remote arch unconditionally

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66249323d25f: [lldb] [gdb-remote] Try using 
 for remote arch unconditionally (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D109272?vs=371136&id=372877#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109272

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
  lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-i386.yaml

Index: lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-i386.yaml
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-i386.yaml
@@ -0,0 +1,47 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+  Entry:   0x00401000
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00401000
+AddressAlign:0x0001
+Content: C3
+  - Name:.eh_frame
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+Address: 0x00402000
+AddressAlign:0x0008
+Content: 1800017A5200017810011B0C070890010E80010010002000DCEF0100
+Symbols:
+  - Name:.text
+Type:STT_SECTION
+Section: .text
+Value:   0x00401000
+  - Name:.eh_frame
+Type:STT_SECTION
+Section: .eh_frame
+Value:   0x00402000
+  - Name:_start
+Binding: STB_GLOBAL
+  - Name:__bss_start
+Section: .eh_frame
+Binding: STB_GLOBAL
+Value:   0x00404000
+  - Name:foo
+Section: .text
+Binding: STB_GLOBAL
+Value:   0x00401000
+  - Name:_edata
+Section: .eh_frame
+Binding: STB_GLOBAL
+Value:   0x00404000
+  - Name:_end
+Section: .eh_frame
+Binding: STB_GLOBAL
+Value:   0x00404000
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -150,3 +150,264 @@
["rip = 0x8887868584838281"])
 self.match("register read flags",
["eflags = 0x94939291"])
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("X86")
+def test_i386_regs(self):
+"""Test grabbing various i386 registers from gdbserver."""
+reg_data = [
+"01020304",  # eax
+"11121314",  # ecx
+"21222324",  # edx
+"31323334",  # ebx
+"41424344",  # esp
+"51525354",  # ebp
+"61626364",  # esi
+"71727374",  # edi
+"81828384",  # eip
+"91929394",  # eflags
+"0102030405060708090a",  # st0
+"1112131415161718191a",  # st1
+] + 6 * [
+"2122232425262728292a"  # st2..st7
+] + [
+"8182838485868788898a8b8c8d8e8f90",  # xmm0
+"9192939495969798999a9b9c9d9e9fa0",  # xmm1
+] + 6 * [
+"a1a2a3a4a5a6a7a8a9aaabacadaeafb0",  # xmm2..xmm7
+] + [
+"",  # mxcsr
+] + [
+"b1b2b3b4b5b6b7b8b9babbbcbdbebfc0",  # ymm0h
+"c1c2c3c4c5c6c7c8c9cacbcccdcecfd0",  # ymm1h
+] + 6 * [
+"d1d2d3d4d5d6d7d8d9dadbdcdddedfe0",  # ymm2h..ymm7h
+]
+
+class MyResponder(MockGDBServerResponder):
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+
+  i386
+  GNU/Linux
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+   

[Lldb-commits] [PATCH] D109691: [lldb] [ABI/AArch64] Recognize special regs by their xN names too

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc208deb90082: [lldb] [ABI/AArch64] Recognize special regs by 
their xN names too (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109691

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -409,5 +409,11 @@
["x0 = 0x0807060504030201"])
 self.match("register read arg2",
["x1 = 0x1817161514131211"])
+self.match("register read fp",
+   ["x29 = 0x3837363534333231"])
+self.match("register read lr",
+   ["x30 = 0x4847464544434241"])
+self.match("register read ra",
+   ["x30 = 0x4847464544434241"])
 self.match("register read flags",
["cpsr = 0x74737271"])
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -55,9 +55,9 @@
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
-  .Case("lr", LLDB_REGNUM_GENERIC_RA)
-  .Case("sp", LLDB_REGNUM_GENERIC_SP)
-  .Case("fp", LLDB_REGNUM_GENERIC_FP)
+  .Cases("lr", "x30", LLDB_REGNUM_GENERIC_RA)
+  .Cases("sp", "x31", LLDB_REGNUM_GENERIC_SP)
+  .Cases("fp", "x29", LLDB_REGNUM_GENERIC_FP)
   .Case("cpsr", LLDB_REGNUM_GENERIC_FLAGS)
   .Case("x0", LLDB_REGNUM_GENERIC_ARG1)
   .Case("x1", LLDB_REGNUM_GENERIC_ARG2)


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -409,5 +409,11 @@
["x0 = 0x0807060504030201"])
 self.match("register read arg2",
["x1 = 0x1817161514131211"])
+self.match("register read fp",
+   ["x29 = 0x3837363534333231"])
+self.match("register read lr",
+   ["x30 = 0x4847464544434241"])
+self.match("register read ra",
+   ["x30 = 0x4847464544434241"])
 self.match("register read flags",
["cpsr = 0x74737271"])
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -55,9 +55,9 @@
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
-  .Case("lr", LLDB_REGNUM_GENERIC_RA)
-  .Case("sp", LLDB_REGNUM_GENERIC_SP)
-  .Case("fp", LLDB_REGNUM_GENERIC_FP)
+  .Cases("lr", "x30", LLDB_REGNUM_GENERIC_RA)
+  .Cases("sp", "x31", LLDB_REGNUM_GENERIC_SP)
+  .Cases("fp", "x29", LLDB_REGNUM_GENERIC_FP)
   .Case("cpsr", LLDB_REGNUM_GENERIC_FLAGS)
   .Case("x0", LLDB_REGNUM_GENERIC_ARG1)
   .Case("x1", LLDB_REGNUM_GENERIC_ARG2)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] ceded41 - Don't set executable file in ObjectFileMachO::LoadCoreFileImages

2021-09-16 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2021-09-16T01:38:48-07:00
New Revision: ceded4153245322c45d28068860fb3d8d0a4884d

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

LOG: Don't set executable file in ObjectFileMachO::LoadCoreFileImages

When the corefile reader is adding binaries from the "all image
infos" LC_NOTE in a Mach-O corefile, it would detect if the binary
being added was an executable binary and set it as the Target's
executable binary.  This has the side effect of clearing the Target's
image list, so if the executable was in the middle of the all image
infos, the initial images would be dropped.  There's no need to set
the executable binary in the Target for these corefile processes,
so instead of doing multiple passes over the list to find the
executable, I'm dropping that.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index d96b591fd95ff..99aef04ab6038 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -7033,12 +7033,8 @@ bool 
ObjectFileMachO::LoadCoreFileImages(lldb_private::Process &process) {
image.load_address);
 }
   }
-  if (module_sp.get() && module_sp->GetObjectFile()) {
+  if (module_sp.get()) {
 added_images = true;
-if (module_sp->GetObjectFile()->GetType() ==
-ObjectFile::eTypeExecutable) {
-  process.GetTarget().SetExecutableModule(module_sp, 
eLoadDependentsNo);
-}
 for (auto name_vmaddr_tuple : image.segment_load_addresses) {
   SectionList *sectlist = module_sp->GetObjectFile()->GetSectionList();
   if (sectlist) {



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


[Lldb-commits] [PATCH] D109695: [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 372883.
mgorny retitled this revision from "[lldb] [Process/gdb-remote] Add x31 AArch64 
register for gdbserver" to "[lldb] [Process/gdb-remote] Alias sp to x31 on 
AArch64 for gdbserver".
mgorny edited the summary of this revision.
Herald added a subscriber: jeroen.dobbelaere.

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

https://reviews.llvm.org/D109695

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@
["x0 = 0x0807060504030201"])
 self.match("register read x1",
["x1 = 0x1817161514131211"])
+self.match("register read x29",
+   ["x29 = 0x3837363534333231"])
+self.match("register read x30",
+   ["x30 = 0x4847464544434241"])
+self.match("register read x31",
+   ["sp = 0x5857565554535251"])
 self.match("register read sp",
["sp = 0x5857565554535251"])
 self.match("register read pc",
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -581,8 +581,12 @@
 // We have to make a temporary ABI here, and not use the GetABI because
 // this code gets called in DidAttach, when the target architecture
 // (and consequently the ABI we'll get from the process) may be wrong.
-if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
+if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use)) {
   abi_sp->AugmentRegisterInfo(reg_info);
+  // AugmentRegisterInfo() can modify alt_name
+  if (reg_info.alt_name)
+alt_name.SetCString(reg_info.alt_name);
+}
 
 m_register_info_sp->AddRegister(reg_info, reg_name, alt_name, 
set_name);
   } else {
@@ -4554,8 +4558,12 @@
 reg_num_remote = reg_info.kinds[eRegisterKindProcessPlugin] + 1;
 ++reg_num_local;
 reg_info.name = reg_name.AsCString();
-if (abi_sp)
+if (abi_sp) {
   abi_sp->AugmentRegisterInfo(reg_info);
+  // AugmentRegisterInfo() can modify alt_name
+  if (reg_info.alt_name)
+alt_name.SetCString(reg_info.alt_name);
+}
 dyn_reg_info.AddRegister(reg_info, reg_name, alt_name, set_name);
 
 return true; // Keep iterating through all "reg" elements
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
+  void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
   using lldb_private::MCBasedABI::MCBasedABI;
 };
 #endif
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@
   MapRegisterName(reg, "x30", "lr");
   return reg;
 }
+
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
@@ -69,3 +70,11 @@
   .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
   .Default(LLDB_INVALID_REGNUM);
 }
+
+void ABIAArch64::AugmentRegisterInfo(lldb_private::RegisterInfo &info) {
+  lldb_private::MCBasedABI::AugmentRegisterInfo(info);
+
+  // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
+  if (!strcmp(info.name, "sp") && !info.alt_name)
+info.alt_name = "x31";
+}


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@
["x0 = 0x0807060504030201"])
 self.match("register read x1",
["x1 = 0x1817161514131211"])
+self.match("register read x29",
+   ["x29 = 0x3837363534333231"])
+self.match("register read x30",
+   ["x30 = 0x4847464544434241"])
+self.matc

[Lldb-commits] [PATCH] D109777: [lldb] [Windows] Fix continuing from breakpoints and singlestepping on ARM/AArch64

2021-09-16 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D109777#3003312 , @DavidSpickett 
wrote:

> One thing that I forgot to ask, are there already tests that cover the 
> scenario the bug reported?

No idea - this fixes a sequence of `b `, `run`, `step`, i.e. fairly 
trivial/basic breakpoint functionality. (It fixes it entirely on ARM64; on ARM 
there's other issues due to the thumb bit offset that I haven't had time to 
fix, but the aspects that this patch touches should be correct for ARM at 
least.)

> Good chance there are but they only run on x86 due to the available bots. We 
> (Linaro) are working to get more tests running on WoA bots so this would be 
> covered eventually.

That'd be great. I haven't ever run the LLDB testsuite properly on Windows on 
ARM - my only WoA hardware is in the absolute lowest end (Snapdragon 835) so I 
only cross compile things and test on the target device manually - doing cross 
testing of LLDB is tricky to say the least, and I wouldn't want to try to 
actually build LLDB and run the testsuite natively on that hardware...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109777

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


[Lldb-commits] [lldb] bd590a5 - [lldb] Make Platform::DebugProcess take a Target reference

2021-09-16 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-16T11:33:47+02:00
New Revision: bd590a5f895f50ceb7669de1b4a69bbcc8adb38b

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

LOG: [lldb] Make Platform::DebugProcess take a Target reference

instead of a pointer. There are just two callers of this function, and
both of them have a valid target pointer, so there's no need for all
implementations to concern themselves with whether the pointer is null.

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Target/Platform.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index df46466655c35..878739c46fa4a 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -363,11 +363,9 @@ class Platform : public PluginInterface {
   /// platforms will want to subclass this function in order to be able to
   /// intercept STDIO and possibly launch a separate process that will debug
   /// the debuggee.
-  virtual lldb::ProcessSP
-  DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
-   Target *target, // Can be nullptr, if nullptr create a new
-   // target, else use existing one
-   Status &error);
+  virtual lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
+   Debugger &debugger, Target &target,
+   Status &error);
 
   virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
  llvm::StringRef plugin_name,

diff  --git a/lldb/source/Commands/CommandObjectPlatform.cpp 
b/lldb/source/Commands/CommandObjectPlatform.cpp
index 7760eba290d4b..cd4d880e7 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1171,7 +1171,7 @@ class CommandObjectPlatformProcessLaunch : public 
CommandObjectParsed {
   target->GetRunArguments(m_options.launch_info.GetArguments());
 
 ProcessSP process_sp(platform_sp->DebugProcess(
-m_options.launch_info, debugger, target, error));
+m_options.launch_info, debugger, *target, error));
 if (process_sp && process_sp->IsAlive()) {
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
   return true;

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 925a3d110b1df..0919ba23e3713 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -177,11 +177,10 @@ Status PlatformAppleSimulator::DisconnectRemote() {
 #endif
 }
 
-lldb::ProcessSP PlatformAppleSimulator::DebugProcess(
-ProcessLaunchInfo &launch_info, Debugger &debugger,
-Target *target, // Can be NULL, if NULL create a new target, else use
-// existing one
-Status &error) {
+lldb::ProcessSP
+PlatformAppleSimulator::DebugProcess(ProcessLaunchInfo &launch_info,
+ Debugger &debugger, Target &target,
+ Status &error) {
 #if defined(__APPLE__)
   ProcessSP process_sp;
   // Make sure we stop at the entry point
@@ -195,7 +194,7 @@ lldb::ProcessSP PlatformAppleSimulator::DebugProcess(
   if (error.Success()) {
 if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
   ProcessAttachInfo attach_info(launch_info);
-  process_sp = Attach(attach_info, debugger, target, error);
+  process_sp = Attach(attach_info, debugger, &target, error);
   if (process_sp) {
 launch_info.SetHijackListener(attach_info.GetHijackListener());
 

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
index 2e6ce02635c53..fc428ad2be46a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
+++ b/lldb/source/Plugins/P

[Lldb-commits] [PATCH] D109872: [lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
mgorny requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Remove the name and alt_name parameters from AddRegister() and instead
pass them via RegisterInfo.name and .alt_name fields.  This makes
the API simpler and removes some duplication.


https://reviews.llvm.org/D109872

Files:
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -578,13 +578,14 @@
 }
 
 reg_info.name = reg_name.AsCString();
+reg_info.alt_name = alt_name.AsCString();
 // We have to make a temporary ABI here, and not use the GetABI because
 // this code gets called in DidAttach, when the target architecture
 // (and consequently the ABI we'll get from the process) may be wrong.
 if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
   abi_sp->AugmentRegisterInfo(reg_info);
 
-m_register_info_sp->AddRegister(reg_info, reg_name, alt_name, set_name);
+m_register_info_sp->AddRegister(reg_info, set_name);
   } else {
 break; // ensure exit before reg_num is incremented
   }
@@ -4554,9 +4555,10 @@
 reg_num_remote = reg_info.kinds[eRegisterKindProcessPlugin] + 1;
 ++reg_num_local;
 reg_info.name = reg_name.AsCString();
+reg_info.alt_name = alt_name.AsCString();
 if (abi_sp)
   abi_sp->AugmentRegisterInfo(reg_info);
-dyn_reg_info.AddRegister(reg_info, reg_name, alt_name, set_name);
+dyn_reg_info.AddRegister(reg_info, set_name);
 
 return true; // Keep iterating through all "reg" elements
   });
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -992,19 +992,12 @@
   }
 }
 for (i = 0; i < num_registers; ++i) {
-  ConstString name;
-  ConstString alt_name;
-  if (g_register_infos[i].name && g_register_infos[i].name[0])
-name.SetCString(g_register_infos[i].name);
-  if (g_register_infos[i].alt_name && g_register_infos[i].alt_name[0])
-alt_name.SetCString(g_register_infos[i].alt_name);
-
   if (i <= 15 || i == 25)
-AddRegister(g_register_infos[i], name, alt_name, gpr_reg_set);
+AddRegister(g_register_infos[i], gpr_reg_set);
   else if (i <= 24)
-AddRegister(g_register_infos[i], name, alt_name, sfp_reg_set);
+AddRegister(g_register_infos[i], sfp_reg_set);
   else
-AddRegister(g_register_infos[i], name, alt_name, vfp_reg_set);
+AddRegister(g_register_infos[i], vfp_reg_set);
 }
   } else {
 // Add composite registers to our primordial registers, then.
@@ -1040,8 +1033,6 @@
 // If "match" is true, then we can add extra registers.
 if (match) {
   for (i = 0; i < num_composites; ++i) {
-ConstString name;
-ConstString alt_name;
 const uint32_t first_primordial_reg =
 g_comp_register_infos[i].value_regs[0];
 const char *reg_name = g_register_infos[first_primordial_reg].name;
@@ -1054,9 +1045,7 @@
   // The name matches the existing primordial entry. Find and
   // assign the offset, and then add this composite register entry.
   g_comp_register_infos[i].byte_offset = reg_info->byte_offset;
-  name.SetCString(g_comp_register_infos[i].name);
-  AddRegister(g_comp_register_infos[i], name, alt_name,
-  vfp_reg_set);
+  AddRegister(g_comp_register_infos[i], vfp_reg_set);
 }
   }
 }
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -36,8 +36,6 @@
  const lldb_private::ArchSpec &arch);
 
   void AddRegister(lldb_private::RegisterInfo ®_info,
-   lldb_private::ConstString ®_name,
-   lldb_private::ConstString ®_alt_name,
lldb_private::ConstString &set_name);
 
   void Finalize(const lldb_private::ArchSpec &arch);
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
=

[Lldb-commits] [lldb] 86a58f1 - [lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo

2021-09-16 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-09-16T12:00:20+02:00
New Revision: 86a58f10284dea118703ecde0ef5b9a4f6e4d8be

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

LOG: [lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo

Remove the name and alt_name parameters from AddRegister() and instead
pass them via RegisterInfo.name and .alt_name fields.  This makes
the API simpler and removes some duplication.

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp 
b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index f3dfa5d57fc85..cc79260d0797f 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -396,14 +396,10 @@ DynamicRegisterInfo::SetRegisterInfo(const 
StructuredData::Dictionary &dict,
 }
 
 void DynamicRegisterInfo::AddRegister(RegisterInfo ®_info,
-  ConstString ®_name,
-  ConstString ®_alt_name,
   ConstString &set_name) {
   assert(!m_finalized);
   const uint32_t reg_num = m_regs.size();
-  reg_info.name = reg_name.AsCString();
   assert(reg_info.name);
-  reg_info.alt_name = reg_alt_name.AsCString(nullptr);
   uint32_t i;
   if (reg_info.value_regs) {
 for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)

diff  --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h 
b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
index 7e90454c6d9d9..663fbab578100 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -36,8 +36,6 @@ class DynamicRegisterInfo {
  const lldb_private::ArchSpec &arch);
 
   void AddRegister(lldb_private::RegisterInfo ®_info,
-   lldb_private::ConstString ®_name,
-   lldb_private::ConstString ®_alt_name,
lldb_private::ConstString &set_name);
 
   void Finalize(const lldb_private::ArchSpec &arch);

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 5c3f9b4baeae2..c050efbc36545 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -992,19 +992,12 @@ void 
GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
   }
 }
 for (i = 0; i < num_registers; ++i) {
-  ConstString name;
-  ConstString alt_name;
-  if (g_register_infos[i].name && g_register_infos[i].name[0])
-name.SetCString(g_register_infos[i].name);
-  if (g_register_infos[i].alt_name && g_register_infos[i].alt_name[0])
-alt_name.SetCString(g_register_infos[i].alt_name);
-
   if (i <= 15 || i == 25)
-AddRegister(g_register_infos[i], name, alt_name, gpr_reg_set);
+AddRegister(g_register_infos[i], gpr_reg_set);
   else if (i <= 24)
-AddRegister(g_register_infos[i], name, alt_name, sfp_reg_set);
+AddRegister(g_register_infos[i], sfp_reg_set);
   else
-AddRegister(g_register_infos[i], name, alt_name, vfp_reg_set);
+AddRegister(g_register_infos[i], vfp_reg_set);
 }
   } else {
 // Add composite registers to our primordial registers, then.
@@ -1040,8 +1033,6 @@ void 
GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
 // If "match" is true, then we can add extra registers.
 if (match) {
   for (i = 0; i < num_composites; ++i) {
-ConstString name;
-ConstString alt_name;
 const uint32_t first_primordial_reg =
 g_comp_register_infos[i].value_regs[0];
 const char *reg_name = g_register_infos[first_primordial_reg].name;
@@ -1054,9 +1045,7 @@ void 
GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
   // The name matches the existing primordial entry. Find and
   // assign the offset, and then add this composite register entry.
   g_comp_register_infos[i].byte_offset = reg_info->byte_offset;
-  name.SetCString(g_comp_register_infos[i].name);
-  AddRegister(g_comp_register_infos[i], name, alt_name,
-  vfp_reg_set);
+  AddR

[Lldb-commits] [PATCH] D109872: [lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG86a58f10284d: [lldb] [DynamicRegisterInfo] Pass 
name/alt_name via RegisterInfo (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109872

Files:
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -578,13 +578,14 @@
 }
 
 reg_info.name = reg_name.AsCString();
+reg_info.alt_name = alt_name.AsCString();
 // We have to make a temporary ABI here, and not use the GetABI because
 // this code gets called in DidAttach, when the target architecture
 // (and consequently the ABI we'll get from the process) may be wrong.
 if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
   abi_sp->AugmentRegisterInfo(reg_info);
 
-m_register_info_sp->AddRegister(reg_info, reg_name, alt_name, set_name);
+m_register_info_sp->AddRegister(reg_info, set_name);
   } else {
 break; // ensure exit before reg_num is incremented
   }
@@ -4554,9 +4555,10 @@
 reg_num_remote = reg_info.kinds[eRegisterKindProcessPlugin] + 1;
 ++reg_num_local;
 reg_info.name = reg_name.AsCString();
+reg_info.alt_name = alt_name.AsCString();
 if (abi_sp)
   abi_sp->AugmentRegisterInfo(reg_info);
-dyn_reg_info.AddRegister(reg_info, reg_name, alt_name, set_name);
+dyn_reg_info.AddRegister(reg_info, set_name);
 
 return true; // Keep iterating through all "reg" elements
   });
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -992,19 +992,12 @@
   }
 }
 for (i = 0; i < num_registers; ++i) {
-  ConstString name;
-  ConstString alt_name;
-  if (g_register_infos[i].name && g_register_infos[i].name[0])
-name.SetCString(g_register_infos[i].name);
-  if (g_register_infos[i].alt_name && g_register_infos[i].alt_name[0])
-alt_name.SetCString(g_register_infos[i].alt_name);
-
   if (i <= 15 || i == 25)
-AddRegister(g_register_infos[i], name, alt_name, gpr_reg_set);
+AddRegister(g_register_infos[i], gpr_reg_set);
   else if (i <= 24)
-AddRegister(g_register_infos[i], name, alt_name, sfp_reg_set);
+AddRegister(g_register_infos[i], sfp_reg_set);
   else
-AddRegister(g_register_infos[i], name, alt_name, vfp_reg_set);
+AddRegister(g_register_infos[i], vfp_reg_set);
 }
   } else {
 // Add composite registers to our primordial registers, then.
@@ -1040,8 +1033,6 @@
 // If "match" is true, then we can add extra registers.
 if (match) {
   for (i = 0; i < num_composites; ++i) {
-ConstString name;
-ConstString alt_name;
 const uint32_t first_primordial_reg =
 g_comp_register_infos[i].value_regs[0];
 const char *reg_name = g_register_infos[first_primordial_reg].name;
@@ -1054,9 +1045,7 @@
   // The name matches the existing primordial entry. Find and
   // assign the offset, and then add this composite register entry.
   g_comp_register_infos[i].byte_offset = reg_info->byte_offset;
-  name.SetCString(g_comp_register_infos[i].name);
-  AddRegister(g_comp_register_infos[i], name, alt_name,
-  vfp_reg_set);
+  AddRegister(g_comp_register_infos[i], vfp_reg_set);
 }
   }
 }
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -36,8 +36,6 @@
  const lldb_private::ArchSpec &arch);
 
   void AddRegister(lldb_private::RegisterInfo ®_info,
-   lldb_private::ConstString ®_name,
-   lldb_private::ConstString ®_alt_name,
lldb_private::ConstString &set_name);
 
   void Finalize(const lldb_private::ArchSpec &arch);
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.c

[Lldb-commits] [PATCH] D109695: [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 372889.
mgorny added a comment.

Rebased — we no longer need the alt_name dance.


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

https://reviews.llvm.org/D109695

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@
["x0 = 0x0807060504030201"])
 self.match("register read x1",
["x1 = 0x1817161514131211"])
+self.match("register read x29",
+   ["x29 = 0x3837363534333231"])
+self.match("register read x30",
+   ["x30 = 0x4847464544434241"])
+self.match("register read x31",
+   ["sp = 0x5857565554535251"])
 self.match("register read sp",
["sp = 0x5857565554535251"])
 self.match("register read pc",
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
+  void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
   using lldb_private::MCBasedABI::MCBasedABI;
 };
 #endif
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@
   MapRegisterName(reg, "x30", "lr");
   return reg;
 }
+
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
@@ -69,3 +70,11 @@
   .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
   .Default(LLDB_INVALID_REGNUM);
 }
+
+void ABIAArch64::AugmentRegisterInfo(lldb_private::RegisterInfo &info) {
+  lldb_private::MCBasedABI::AugmentRegisterInfo(info);
+
+  // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
+  if (!strcmp(info.name, "sp") && !info.alt_name)
+info.alt_name = "x31";
+}


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@
["x0 = 0x0807060504030201"])
 self.match("register read x1",
["x1 = 0x1817161514131211"])
+self.match("register read x29",
+   ["x29 = 0x3837363534333231"])
+self.match("register read x30",
+   ["x30 = 0x4847464544434241"])
+self.match("register read x31",
+   ["sp = 0x5857565554535251"])
 self.match("register read sp",
["sp = 0x5857565554535251"])
 self.match("register read pc",
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
+  void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
   using lldb_private::MCBasedABI::MCBasedABI;
 };
 #endif
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@
   MapRegisterName(reg, "x30", "lr");
   return reg;
 }
+
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
@@ -69,3 +70,11 @@
   .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
   .Default(LLDB_INVALID_REGNUM);
 }
+
+void ABIAArch64::AugmentRegisterInfo(lldb_private::RegisterInfo &info) {
+  lldb_private::MCBasedABI::AugmentRegisterInfo(info);
+
+  // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
+  if (!strcmp(info.name, "sp") && !info.alt_name)
+info.alt_name = "x31";
+}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 47d5754 - [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

2021-09-16 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-09-16T13:13:47+02:00
New Revision: 47d57547f43c6cf9404268b8a4c2f75c402615c2

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

LOG: [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

Alias the "sp" register to "x31" on AArch64 if one is present and does
not have the alt_name.  This is the case when connecting to gdbserver.

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

Added: 


Modified: 
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Removed: 




diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 619c45dc12ec..66a38ab6e3e9 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@ std::string ABIAArch64::GetMCName(std::string reg) {
   MapRegisterName(reg, "x30", "lr");
   return reg;
 }
+
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
@@ -69,3 +70,11 @@ uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
   .Default(LLDB_INVALID_REGNUM);
 }
+
+void ABIAArch64::AugmentRegisterInfo(lldb_private::RegisterInfo &info) {
+  lldb_private::MCBasedABI::AugmentRegisterInfo(info);
+
+  // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
+  if (!strcmp(info.name, "sp") && !info.alt_name)
+info.alt_name = "x31";
+}

diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
index 41bbf5cfdeb9..13dcfdd4c6d7 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@ class ABIAArch64: public lldb_private::MCBasedABI {
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
+  void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
   using lldb_private::MCBasedABI::MCBasedABI;
 };
 #endif

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 13d780428613..5d307fc1e3d4 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@ def haltReason(self):
["x0 = 0x0807060504030201"])
 self.match("register read x1",
["x1 = 0x1817161514131211"])
+self.match("register read x29",
+   ["x29 = 0x3837363534333231"])
+self.match("register read x30",
+   ["x30 = 0x4847464544434241"])
+self.match("register read x31",
+   ["sp = 0x5857565554535251"])
 self.match("register read sp",
["sp = 0x5857565554535251"])
 self.match("register read pc",



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


[Lldb-commits] [PATCH] D109695: [lldb] [Process/gdb-remote] Alias sp to x31 on AArch64 for gdbserver

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47d57547f43c: [lldb] [Process/gdb-remote] Alias sp to x31 on 
AArch64 for gdbserver (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109695

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@
["x0 = 0x0807060504030201"])
 self.match("register read x1",
["x1 = 0x1817161514131211"])
+self.match("register read x29",
+   ["x29 = 0x3837363534333231"])
+self.match("register read x30",
+   ["x30 = 0x4847464544434241"])
+self.match("register read x31",
+   ["sp = 0x5857565554535251"])
 self.match("register read sp",
["sp = 0x5857565554535251"])
 self.match("register read pc",
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
+  void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
   using lldb_private::MCBasedABI::MCBasedABI;
 };
 #endif
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@
   MapRegisterName(reg, "x30", "lr");
   return reg;
 }
+
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
@@ -69,3 +70,11 @@
   .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
   .Default(LLDB_INVALID_REGNUM);
 }
+
+void ABIAArch64::AugmentRegisterInfo(lldb_private::RegisterInfo &info) {
+  lldb_private::MCBasedABI::AugmentRegisterInfo(info);
+
+  // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
+  if (!strcmp(info.name, "sp") && !info.alt_name)
+info.alt_name = "x31";
+}


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -397,6 +397,12 @@
["x0 = 0x0807060504030201"])
 self.match("register read x1",
["x1 = 0x1817161514131211"])
+self.match("register read x29",
+   ["x29 = 0x3837363534333231"])
+self.match("register read x30",
+   ["x30 = 0x4847464544434241"])
+self.match("register read x31",
+   ["sp = 0x5857565554535251"])
 self.match("register read sp",
["sp = 0x5857565554535251"])
 self.match("register read pc",
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -31,6 +31,8 @@
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
+  void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+
   using lldb_private::MCBasedABI::MCBasedABI;
 };
 #endif
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -52,6 +52,7 @@
   MapRegisterName(reg, "x30", "lr");
   return reg;
 }
+
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)
@@ -69,3 +70,11 @@
   .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
   .Default(LLDB_INVALID_REGNUM);
 }
+
+void ABIAArch64::AugmentRegisterInfo(lldb_private::RegisterInfo &info) {
+  lldb_private::MCBasedABI::AugmentRegisterInfo(info);
+
+  // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
+  if (!strcmp(info.name, "sp") && !info.alt_name)
+info.alt_name = "x31";
+}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman

[Lldb-commits] [PATCH] D109834: [lldb/win] Improve check-lldb-shell with LLVM_ENABLE_DIA_SDK=NO

2021-09-16 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

In D109834#3003250 , @labath wrote:

> I fear this is going to be an endless whack-a-mole. There's no way every 
> contributor will remember to (correctly) add this feature.

I think that's ok. 10/250 shell tests need it and there isn't a ton of churn in 
these tests, so folks on windows can update it as needed.

(If you have a better idea, I'm all ears of course.)


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

https://reviews.llvm.org/D109834

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


[Lldb-commits] [lldb] 99ece01 - [lldb/win] Fix TestIRMemoryMapWindows.test when running tests in git bash

2021-09-16 Thread Nico Weber via lldb-commits

Author: Nico Weber
Date: 2021-09-16T07:40:54-04:00
New Revision: 99ece01a0f571f0df129a55bf679f7fbd0b01b75

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

LOG: [lldb/win] Fix TestIRMemoryMapWindows.test when running tests in git bash

lit.util.which('link') picks up the wrong link.exe in git bash, leading
to this error:

  # command stderr:
  /usr/bin/link: extra operand '/LIBPATH:C:\\Progra'
  Try '/usr/bin/link --help' for more information.

Instead, assume that link.exe is next to cl.exe.

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

Added: 


Modified: 
lldb/test/Shell/helper/toolchain.py

Removed: 




diff  --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index 6ccb529e8985..4303b2583e7b 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -90,11 +90,14 @@ def _use_msvc_substitutions(config):
 # detect the include and lib paths, and find cl.exe and link.exe and create
 # substitutions for each of them that explicitly specify /I and /L paths
 cl = lit.util.which('cl')
-link = lit.util.which('link')
 
-if not cl or not link:
+if not cl:
 return
 
+# Don't use lit.util.which() for link.exe: In `git bash`, it will pick
+# up /usr/bin/link (another name for ln).
+link = os.path.join(os.path.dirname(cl), 'link.exe')
+
 cl = '"' + cl + '"'
 link = '"' + link + '"'
 includes = os.getenv('INCLUDE', '').split(';')



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


[Lldb-commits] [PATCH] D109832: [lldb/win] Fix TestIRMemoryMapWindows.test when running tests in git bash

2021-09-16 Thread Nico Weber via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99ece01a0f57: [lldb/win] Fix TestIRMemoryMapWindows.test 
when running tests in git bash (authored by thakis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109832

Files:
  lldb/test/Shell/helper/toolchain.py


Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -90,11 +90,14 @@
 # detect the include and lib paths, and find cl.exe and link.exe and create
 # substitutions for each of them that explicitly specify /I and /L paths
 cl = lit.util.which('cl')
-link = lit.util.which('link')
 
-if not cl or not link:
+if not cl:
 return
 
+# Don't use lit.util.which() for link.exe: In `git bash`, it will pick
+# up /usr/bin/link (another name for ln).
+link = os.path.join(os.path.dirname(cl), 'link.exe')
+
 cl = '"' + cl + '"'
 link = '"' + link + '"'
 includes = os.getenv('INCLUDE', '').split(';')


Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -90,11 +90,14 @@
 # detect the include and lib paths, and find cl.exe and link.exe and create
 # substitutions for each of them that explicitly specify /I and /L paths
 cl = lit.util.which('cl')
-link = lit.util.which('link')
 
-if not cl or not link:
+if not cl:
 return
 
+# Don't use lit.util.which() for link.exe: In `git bash`, it will pick
+# up /usr/bin/link (another name for ln).
+link = os.path.join(os.path.dirname(cl), 'link.exe')
+
 cl = '"' + cl + '"'
 link = '"' + link + '"'
 includes = os.getenv('INCLUDE', '').split(';')
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add 32-bit pseudo-regs if missing [WIP]

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
Herald added a subscriber: kristof.beyls.
mgorny requested review of this revision.

Create 32-bit wN pseudo-registers if xN registers are present but wN
registers are missing.  This is the case when interacting with gdbserver
since GDB handles pseudo-registers on client side, not server side.


https://reviews.llvm.org/D109876

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -423,3 +423,7 @@
["x30 = 0x4847464544434241"])
 self.match("register read flags",
["cpsr = 0x74737271"])
+
+# test partial registers
+self.match("register read w0",
+   ["w0 = 0x04030201"])
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -453,6 +453,7 @@
   if (GetGDBServerRegisterInfo(arch_to_use))
 return;
 
+  ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use);
   char packet[128];
   uint32_t reg_offset = LLDB_INVALID_INDEX32;
   uint32_t reg_num = 0;
@@ -582,7 +583,7 @@
 // We have to make a temporary ABI here, and not use the GetABI because
 // this code gets called in DidAttach, when the target architecture
 // (and consequently the ABI we'll get from the process) may be wrong.
-if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
+if (abi_sp)
   abi_sp->AugmentRegisterInfo(reg_info);
 
 m_register_info_sp->AddRegister(reg_info, set_name);
@@ -595,6 +596,8 @@
   }
 
   if (m_register_info_sp->GetNumRegisters() > 0) {
+if (abi_sp)
+  abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
 m_register_info_sp->Finalize(GetTarget().GetArchitecture());
 return;
   }
@@ -618,6 +621,8 @@
   }
 
   // At this point, we can finalize our register info.
+  if (abi_sp)
+abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
   m_register_info_sp->Finalize(GetTarget().GetArchitecture());
 }
 
@@ -4704,8 +4709,12 @@
   uint32_t reg_num_remote = 0;
   uint32_t reg_num_local = 0;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-reg_num_remote, reg_num_local))
+reg_num_remote, reg_num_local)) {
+ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use);
+if (abi_sp)
+  abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
 this->m_register_info_sp->Finalize(arch_to_use);
+  }
 
   return m_register_info_sp->GetNumRegisters() > 0;
 }
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -70,7 +70,8 @@
   const lldb_private::RegisterInfo *
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
-protected:
+// TODO
+//protected:
   // Classes that inherit from DynamicRegisterInfo can see and modify these
   typedef std::vector reg_collection;
   typedef std::vector set_collection;
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -32,6 +32,7 @@
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
   void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+  void PreFinalizeDynamicRegisterInfo(DynamicRegisterInfo &info) override;
 
   using lldb_private::MCBasedABI::MCBasedABI;
 };
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -13,6 +13,8 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Target/Process.h"
 
+#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
+
 LLDB_PLUGIN_DEFINE(ABIAArch64)
 
 void ABIAArch64::Initialize() {
@@ -78,3 +80,45 @@
   if (!strcmp(info.name, "sp") && !info.alt_name)
 info.alt_name = "x31";
 }
+
+static uint32_t tmp_value_re

[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add 32-bit pseudo-regs if missing [WIP]

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

(so far with ugly hacks, to get some initial ideas on how to proceed with this)


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

https://reviews.llvm.org/D109876

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


[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add 32-bit pseudo-regs if missing [WIP]

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

@labath, I think the biggest problem here is that `DynamicRegisterInfo` is 
defined only inside source tree. I'm not sure if I should continue with a 
forward declaration like this or aim to move `DynamicRegisterInfo` into public 
headers. if the former, should I move it into `lldb_private` namespace?


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

https://reviews.llvm.org/D109876

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


[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add 32-bit pseudo-regs if missing [WIP]

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 372907.
mgorny added a comment.

Use public API to determine next regnums.


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

https://reviews.llvm.org/D109876

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -423,3 +423,7 @@
["x30 = 0x4847464544434241"])
 self.match("register read flags",
["cpsr = 0x74737271"])
+
+# test partial registers
+self.match("register read w0",
+   ["w0 = 0x04030201"])
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -453,6 +453,7 @@
   if (GetGDBServerRegisterInfo(arch_to_use))
 return;
 
+  ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use);
   char packet[128];
   uint32_t reg_offset = LLDB_INVALID_INDEX32;
   uint32_t reg_num = 0;
@@ -582,7 +583,7 @@
 // We have to make a temporary ABI here, and not use the GetABI because
 // this code gets called in DidAttach, when the target architecture
 // (and consequently the ABI we'll get from the process) may be wrong.
-if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
+if (abi_sp)
   abi_sp->AugmentRegisterInfo(reg_info);
 
 m_register_info_sp->AddRegister(reg_info, set_name);
@@ -595,6 +596,8 @@
   }
 
   if (m_register_info_sp->GetNumRegisters() > 0) {
+if (abi_sp)
+  abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
 m_register_info_sp->Finalize(GetTarget().GetArchitecture());
 return;
   }
@@ -618,6 +621,8 @@
   }
 
   // At this point, we can finalize our register info.
+  if (abi_sp)
+abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
   m_register_info_sp->Finalize(GetTarget().GetArchitecture());
 }
 
@@ -4704,8 +4709,12 @@
   uint32_t reg_num_remote = 0;
   uint32_t reg_num_local = 0;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-reg_num_remote, reg_num_local))
+reg_num_remote, reg_num_local)) {
+ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use);
+if (abi_sp)
+  abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
 this->m_register_info_sp->Finalize(arch_to_use);
+  }
 
   return m_register_info_sp->GetNumRegisters() > 0;
 }
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -32,6 +32,7 @@
   uint32_t GetGenericNum(llvm::StringRef name) override;
 
   void AugmentRegisterInfo(lldb_private::RegisterInfo &info) override;
+  void PreFinalizeDynamicRegisterInfo(DynamicRegisterInfo &info) override;
 
   using lldb_private::MCBasedABI::MCBasedABI;
 };
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -13,6 +13,8 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Target/Process.h"
 
+#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
+
 LLDB_PLUGIN_DEFINE(ABIAArch64)
 
 void ABIAArch64::Initialize() {
@@ -78,3 +80,46 @@
   if (!strcmp(info.name, "sp") && !info.alt_name)
 info.alt_name = "x31";
 }
+
+static uint32_t tmp_value_regs[32][2];
+
+void ABIAArch64::PreFinalizeDynamicRegisterInfo(DynamicRegisterInfo &info) {
+  uint32_t next_regnum_process = 0;
+  uint32_t next_regnum_lldb = info.GetNumRegisters();
+  for (uint32_t i = 0; i < next_regnum_lldb; i++) {
+lldb_private::RegisterInfo *reginfo = info.GetRegisterInfoAtIndex(i);
+assert(reginfo);
+next_regnum_process = std::max(next_regnum_process, reginfo->kinds[lldb::eRegisterKindProcessPlugin]);
+  }
+  next_regnum_process++;
+
+  lldb_private::ConstString group{"partial registers"};
+
+  // Create wN aliases for xN registers if missing.
+  for (int i = 0; i < 32; i++) {
+std::string r64_name = llvm::formatv("x{0}", i);
+std::string r32_name = llvm::formatv("w{0}", i);
+const lldb_private::RegisterInfo* r64 = info.GetRegisterInfo(r64_name);
+const 

[Lldb-commits] [PATCH] D109879: [lldb] [DynamicRegisterInfo] Update RegisterInfo with copy of value_regs/invalidate_regs

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
mgorny requested review of this revision.

Update the value_regs and invalidate_regs pointers in RegisterInfo
to use the copy made by DynamicRegisterInfo.  This permits passing
temporaries as value_regs and invalidate_regs to
DynamicregisterInfo::AddRegister().


https://reviews.llvm.org/D109879

Files:
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp


Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -402,12 +402,22 @@
   assert(reg_info.name);
   uint32_t i;
   if (reg_info.value_regs) {
-for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
+reg_num_collection ®s = m_value_regs_map[reg_num];
+for (i = 0;; ++i) {
+  regs.push_back(reg_info.value_regs[i]);
+  if (reg_info.value_regs[i] == LLDB_INVALID_REGNUM)
+break;
+}
+reg_info.value_regs = regs.data();
   }
   if (reg_info.invalidate_regs) {
-for (i = 0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
+reg_num_collection ®s = m_invalidate_regs_map[reg_num];
+for (i = 0;; ++i) {
+  regs.push_back(reg_info.invalidate_regs[i]);
+  if (reg_info.invalidate_regs[i] == LLDB_INVALID_REGNUM)
+break;
+}
+reg_info.invalidate_regs = regs.data();
   }
   if (reg_info.dynamic_size_dwarf_expr_bytes) {
 for (i = 0; i < reg_info.dynamic_size_dwarf_len; ++i)


Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -402,12 +402,22 @@
   assert(reg_info.name);
   uint32_t i;
   if (reg_info.value_regs) {
-for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
+reg_num_collection ®s = m_value_regs_map[reg_num];
+for (i = 0;; ++i) {
+  regs.push_back(reg_info.value_regs[i]);
+  if (reg_info.value_regs[i] == LLDB_INVALID_REGNUM)
+break;
+}
+reg_info.value_regs = regs.data();
   }
   if (reg_info.invalidate_regs) {
-for (i = 0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
+reg_num_collection ®s = m_invalidate_regs_map[reg_num];
+for (i = 0;; ++i) {
+  regs.push_back(reg_info.invalidate_regs[i]);
+  if (reg_info.invalidate_regs[i] == LLDB_INVALID_REGNUM)
+break;
+}
+reg_info.invalidate_regs = regs.data();
   }
   if (reg_info.dynamic_size_dwarf_expr_bytes) {
 for (i = 0; i < reg_info.dynamic_size_dwarf_len; ++i)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109834: [lldb/win] Improve check-lldb-shell with LLVM_ENABLE_DIA_SDK=NO

2021-09-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Hmm... is the (non native) SymbolFilePDB plugin actually capable of doing 
anything without the DIA SDK. If it can't set breakpoints, then I would guess 
the answer is: not much. Maybe we could automatically select the "Native" 
plugin in this case, just like we do on non-windows hosts?

It would actually be very interesting to know why the 
`NativePDB/stack_unwinding01.cpp` test fails without it, even though it forces 
the use of the native plugin.


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

https://reviews.llvm.org/D109834

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


[Lldb-commits] [PATCH] D109879: [lldb] [DynamicRegisterInfo] Update RegisterInfo with copy of value_regs/invalidate_regs

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Now, a fun fact: ProcessGDBRemote has already been passing temporaries. We 
probably didn't notice it's broken simply because lldb-server didn't send 
value_regs.


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

https://reviews.llvm.org/D109879

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


[Lldb-commits] [PATCH] D109879: [lldb] [DynamicRegisterInfo] Update RegisterInfo with copy of value_regs/invalidate_regs

2021-09-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

So, does this fix like an existing test or something? Maybe you could write a 
unit test for it?


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

https://reviews.llvm.org/D109879

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


[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add 32-bit pseudo-regs if missing [WIP]

2021-09-16 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I think we could move the DynamicRegisterInfo class into non-plugin code, but I 
need to give it more thought.

In the mean time (and maybe before that), I'd like to understand why do you 
need to mess with the process plugin register numbers in this class. It doesn't 
seem like a good idea for that class to be assuming anything about how those 
numbers are allocated and used..


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

https://reviews.llvm.org/D109876

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


[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add 32-bit pseudo-regs if missing [WIP]

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D109876#3003630 , @labath wrote:

> In the mean time (and maybe before that), I'd like to understand why do you 
> need to mess with the process plugin register numbers in this class. It 
> doesn't seem like a good idea for that class to be assuming anything about 
> how those numbers are allocated and used..

For some reason, I have assumed that I need to allocate some unique numbers for 
the new registers. Thinking about it, I'm going to try if things work if I just 
put `LLDB_INVALID_REGNUM` there.


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

https://reviews.llvm.org/D109876

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


[Lldb-commits] [PATCH] D109879: [lldb] [DynamicRegisterInfo] Update RegisterInfo with copy of value_regs/invalidate_regs

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 372919.
mgorny added a comment.

Now with a trivial unit test.


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

https://reviews.llvm.org/D109879

Files:
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
  lldb/unittests/Process/Utility/CMakeLists.txt
  lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp


Index: lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
===
--- /dev/null
+++ lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
@@ -0,0 +1,44 @@
+//===-- DynamicRegisterInfoTest.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
+
+using namespace lldb_private;
+
+TEST(DynamicRegisterInfoTest, regs_copy) {
+  DynamicRegisterInfo info;
+
+  uint32_t value_regs[] = {1, LLDB_INVALID_REGNUM};
+  uint32_t invalidate_regs[] = {2, 3, LLDB_INVALID_REGNUM};
+
+  struct RegisterInfo new_reg {
+"foo", nullptr, 8, 0, lldb::eEncodingUint, lldb::eFormatUnsigned,
+{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 0, 0},
+value_regs, invalidate_regs, nullptr, 0
+  };
+
+  ConstString group{"group"};
+  info.AddRegister(new_reg, group);
+
+  // AddRegister() should have created a copy of these two arrays,
+  // so local changes should not affect returned RegisterInfo.
+  value_regs[0] = 4;
+  invalidate_regs[0] = 5;
+  invalidate_regs[1] = 6;
+
+  const RegisterInfo *added_reg = info.GetRegisterInfoAtIndex(0);
+  ASSERT_NE(added_reg, nullptr);
+  ASSERT_EQ(added_reg->value_regs[0], 1U);
+  ASSERT_EQ(added_reg->value_regs[1], LLDB_INVALID_REGNUM);
+  ASSERT_EQ(added_reg->invalidate_regs[0], 2U);
+  ASSERT_EQ(added_reg->invalidate_regs[1], 3U);
+  ASSERT_EQ(added_reg->invalidate_regs[2], LLDB_INVALID_REGNUM);
+}
Index: lldb/unittests/Process/Utility/CMakeLists.txt
===
--- lldb/unittests/Process/Utility/CMakeLists.txt
+++ lldb/unittests/Process/Utility/CMakeLists.txt
@@ -15,9 +15,10 @@
   ${NETBSD_SOURCES})
 
 add_lldb_unittest(ProcessUtilityTests
-  RegisterContextTest.cpp
+  DynamicRegisterInfoTest.cpp
   LinuxProcMapsTest.cpp
   MemoryTagManagerAArch64MTETest.cpp
+  RegisterContextTest.cpp
   ${PLATFORM_SOURCES}
 
   LINK_LIBS
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -402,12 +402,22 @@
   assert(reg_info.name);
   uint32_t i;
   if (reg_info.value_regs) {
-for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
+reg_num_collection ®s = m_value_regs_map[reg_num];
+for (i = 0;; ++i) {
+  regs.push_back(reg_info.value_regs[i]);
+  if (reg_info.value_regs[i] == LLDB_INVALID_REGNUM)
+break;
+}
+reg_info.value_regs = regs.data();
   }
   if (reg_info.invalidate_regs) {
-for (i = 0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
-  m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
+reg_num_collection ®s = m_invalidate_regs_map[reg_num];
+for (i = 0;; ++i) {
+  regs.push_back(reg_info.invalidate_regs[i]);
+  if (reg_info.invalidate_regs[i] == LLDB_INVALID_REGNUM)
+break;
+}
+reg_info.invalidate_regs = regs.data();
   }
   if (reg_info.dynamic_size_dwarf_expr_bytes) {
 for (i = 0; i < reg_info.dynamic_size_dwarf_len; ++i)


Index: lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
===
--- /dev/null
+++ lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
@@ -0,0 +1,44 @@
+//===-- DynamicRegisterInfoTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
+
+using namespace lldb_private;
+
+TEST(DynamicRegisterInfoTest, regs_copy) {
+  DynamicRegisterInfo info;
+
+  uint32_t value_regs[] = {1, LLDB_INVALID_REGNUM};
+  uint32_t invalidate_regs[] = {2, 3, LLDB_INVALID_REGNUM};
+
+  struct RegisterInfo new_reg {

[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add 32-bit pseudo-regs if missing [WIP]

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Ok, I definitely need some 'process plugin' IDs to handle invalidate_regs 
between pseudo-registers.


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

https://reviews.llvm.org/D109876

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


[Lldb-commits] [lldb] a2c319f - [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-16 Thread Mark de Wever via lldb-commits

Author: Alfonso Gregory
Date: 2021-09-16T18:29:57+02:00
New Revision: a2c319fdc6b35ae6d8578459f07c89042775e5ec

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

LOG: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR 
throughout the project

This way, we do not need to set LLVM_CMAKE_PATH to LLVM_CMAKE_DIR when (NOT 
LLVM_CONFIG_FOUND)

Reviewed By: #libc, ldionne

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/lib/Basic/CMakeLists.txt
compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
flang/CMakeLists.txt
libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
libunwind/CMakeLists.txt
lld/CMakeLists.txt
lld/Common/CMakeLists.txt
lldb/cmake/modules/LLDBStandalone.cmake
lldb/source/CMakeLists.txt
llvm/CMakeLists.txt
llvm/include/llvm/Support/CMakeLists.txt
runtimes/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 95cdbd8f6663a..29ceef8a4bd38 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -48,11 +48,11 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
 list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
 list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
 list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
-list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
+list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_DIR)
 
-# Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
+# Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes.
 # CMake assumes slashes as PATH.
-file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH)
+file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_DIR} LLVM_CMAKE_DIR)
   endif()
 
 
@@ -63,7 +63,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
 mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
   endif()
 
-  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
+  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
   list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
@@ -75,11 +75,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
 set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
 set(INCLUDE_DIR ${LLVM_INCLUDE_DIR})
 set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
-# The LLVM_CMAKE_PATH variable is set when doing non-standalone builds and
-# used in this project, so we need to make sure we set this value.
-# FIXME: LLVM_CMAKE_DIR comes from LLVMConfig.cmake.  We should rename
-# LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project.
-set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR})
   endif()
 
   set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")

diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index c550e8cae03f3..d440f3b33dc9f 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -8,7 +8,7 @@ find_first_existing_vc_file("${CLANG_SOURCE_DIR}" clang_vc)
 # The VC revision include that we want to generate.
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
 
-set(generate_vcs_version_script 
"${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script 
"${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(llvm_vc AND LLVM_APPEND_VC_REV)
   set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})

diff  --git a/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake 
b/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
index 1080a4d0a795b..42ede171e41e5 100644
--- a/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
@@ -13,13 +13,13 @@ macro(compiler_rt_mock_llvm_cmake_config)
 endmacro()
 
 macro(compiler_rt_mock_llvm_cmake_config_set_cmake_path)
-  # Point `LLVM_CMAKE_PATH` at the source tree in the monorepo.
-  set(LLVM_CMAKE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
-  if (NOT EXISTS "${LLVM_CMAKE_PATH}")
-message(FATAL_ERROR "LLVM_CMAKE_PATH (${LLVM_CMAKE_PATH}) does not exist")
+  # Point `LLVM_CMAKE_DIR` at the source tree in the monorepo.
+  set(LLVM_CMAKE_DIR "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  if (NOT EXISTS "${LLVM_CMAKE_DIR}")
+message(FATAL_ERROR "LLVM_CMAKE_DIR (${LLVM_CMAKE_DIR}) does not exist")
   endif()
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
-  message(STATUS "LLVM_CMAKE_PATH: \"${LLVM_CMAKE_PATH}\"")
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
+  message(STATUS "LLVM_CMAKE_DIR: \"${LLVM_CMAKE_DIR}\"")
 endmacro()
 
 function(compiler_rt_mock_llvm_cmake_config_set_target_triple)
@@ -71,5 +71,5 @@ endfunction()
 
 macro(compiler_rt_mock_llvm_cmake_

[Lldb-commits] [PATCH] D109797: Fix rendezvous for rebase_exec=true case

2021-09-16 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay updated this revision to Diff 372982.
emrekultursay added a comment.

Added m_initial_modules_added=true into LoadAllCurrentModules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109797

Files:
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp


Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===
--- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -442,14 +442,18 @@
 if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress(
 &m_process->GetTarget()) == m_interpreter_base &&
 module_sp != m_interpreter_module.lock()) {
-  // If this is a duplicate instance of ld.so, unload it.  We may end 
up
-  // with it if we load it via a different path than before (symlink
-  // vs real path).
-  // TODO: remove this once we either fix library matching or avoid
-  // loading the interpreter when setting the rendezvous breakpoint.
-  UnloadSections(module_sp);
-  loaded_modules.Remove(module_sp);
-  continue;
+  if (m_interpreter_module.lock() == nullptr) {
+m_interpreter_module = module_sp;
+  } else {
+// If this is a duplicate instance of ld.so, unload it.  We may end
+// up with it if we load it via a different path than before
+// (symlink vs real path).
+// TODO: remove this once we either fix library matching or avoid
+// loading the interpreter when setting the rendezvous breakpoint.
+UnloadSections(module_sp);
+loaded_modules.Remove(module_sp);
+continue;
+  }
 }
 
 loaded_modules.AppendIfNeeded(module_sp);
@@ -620,6 +624,7 @@
   }
 
   m_process->GetTarget().ModulesDidLoad(module_list);
+  m_initial_modules_added = true;
 }
 
 addr_t DynamicLoaderPOSIXDYLD::ComputeLoadOffset() {


Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===
--- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -442,14 +442,18 @@
 if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress(
 &m_process->GetTarget()) == m_interpreter_base &&
 module_sp != m_interpreter_module.lock()) {
-  // If this is a duplicate instance of ld.so, unload it.  We may end up
-  // with it if we load it via a different path than before (symlink
-  // vs real path).
-  // TODO: remove this once we either fix library matching or avoid
-  // loading the interpreter when setting the rendezvous breakpoint.
-  UnloadSections(module_sp);
-  loaded_modules.Remove(module_sp);
-  continue;
+  if (m_interpreter_module.lock() == nullptr) {
+m_interpreter_module = module_sp;
+  } else {
+// If this is a duplicate instance of ld.so, unload it.  We may end
+// up with it if we load it via a different path than before
+// (symlink vs real path).
+// TODO: remove this once we either fix library matching or avoid
+// loading the interpreter when setting the rendezvous breakpoint.
+UnloadSections(module_sp);
+loaded_modules.Remove(module_sp);
+continue;
+  }
 }
 
 loaded_modules.AppendIfNeeded(module_sp);
@@ -620,6 +624,7 @@
   }
 
   m_process->GetTarget().ModulesDidLoad(module_list);
+  m_initial_modules_added = true;
 }
 
 addr_t DynamicLoaderPOSIXDYLD::ComputeLoadOffset() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109797: Fix rendezvous for rebase_exec=true case

2021-09-16 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay added a comment.

In D109797#3003265 , @labath wrote:

> Since the meaning of `m_initial_modules_added` is basically "should I do a 
> full scan through the linked list" and LoadAllCurrentModules (called from 
> DidAttach) does a full scan, it seems to me the real bug is that this 
> function does not set `m_initial_modules_added = true`. Would that fix your 
> issue?

Yes, it does fix my bug, thanks for the suggestion. Would you like me to remove 
the lines 445-447 that I added, or keep them as a secondary protection (since 
`module_sp != m_interpreter_module.lock()` condition doesn't seem to be strong 
enough).

In D109797#3003265 , @labath wrote:

> Also, what makes Android 28 special? Is it the presence/absence of a dynamic 
> linker symlink? I'm wondering if we could reproduce (test) this more 
> generally by ensuring we launch a binary through a symlink (or not).

On Android, `GetExecutableModule()` returns `GetModuleAtIndex(0)`. For Android 
27/29, this returns `app_process64` (correct), but for Android 28 it returns 
`[vdso]`, which is incorrect. This causes `ResolveExecutableModule()` to fall 
through due to `module_spec` (app_process64) not matching `module_sp` ([vdso]). 
This causes `target.SetExecutableModule` to be called, which triggers 
`ClearModules`. Since all modules are cleared, we cannot get the load address 
of the `.dynamic` section when we check whether we should rebase (i.e., 
`addr.GetLoadAddress(&target)` returns invalid address), thus 
`rebase_exec=true`.  The rest is in CL description.

To test this, we would need a binary that (1) doesn't have `eTypeExecutable` in 
any of its modules (2) has a module other than the executable module at 
location 0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109797

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


[Lldb-commits] [PATCH] D109899: [lldb] [gdb-remote] Recognize aarch64v type from gdbserver

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
Herald added a subscriber: kristof.beyls.
mgorny requested review of this revision.

https://reviews.llvm.org/D109899

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -423,3 +423,9 @@
["x30 = 0x4847464544434241"])
 self.match("register read flags",
["cpsr = 0x74737271"])
+
+# test vector registers
+self.match("register read v0",
+   ["v0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 
0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.match("register read v31",
+   ["v31 = {0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7 0xa8 0xa9 0xaa 
0xab 0xac 0xad 0xae 0xaf 0xb0}"])
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4524,6 +4524,9 @@
   } else if (gdb_type == "i387_ext" || gdb_type == "float") {
 reg_info.format = eFormatFloat;
 reg_info.encoding = eEncodingIEEE754;
+  } else if (gdb_type == "aarch64v") {
+reg_info.format = eFormatVectorOfUInt8;
+reg_info.encoding = eEncodingVector;
   }
 }
 


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -423,3 +423,9 @@
["x30 = 0x4847464544434241"])
 self.match("register read flags",
["cpsr = 0x74737271"])
+
+# test vector registers
+self.match("register read v0",
+   ["v0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.match("register read v31",
+   ["v31 = {0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae 0xaf 0xb0}"])
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4524,6 +4524,9 @@
   } else if (gdb_type == "i387_ext" || gdb_type == "float") {
 reg_info.format = eFormatFloat;
 reg_info.encoding = eEncodingIEEE754;
+  } else if (gdb_type == "aarch64v") {
+reg_info.format = eFormatVectorOfUInt8;
+reg_info.encoding = eEncodingVector;
   }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c96d457 - [lldb] Remove SBExecutionContext::reset (NFC)

2021-09-16 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-09-16T11:00:12-07:00
New Revision: c96d45700f6d3cb2b8d1972bb8de03522b3ff8d7

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

LOG: [lldb] Remove SBExecutionContext::reset (NFC)

This is a protected function that's not implemented.

Added: 


Modified: 
lldb/include/lldb/API/SBExecutionContext.h

Removed: 




diff  --git a/lldb/include/lldb/API/SBExecutionContext.h 
b/lldb/include/lldb/API/SBExecutionContext.h
index 06ece6fbc0fad..70fc83e84e4e5 100644
--- a/lldb/include/lldb/API/SBExecutionContext.h
+++ b/lldb/include/lldb/API/SBExecutionContext.h
@@ -50,8 +50,6 @@ class LLDB_API SBExecutionContext {
   SBFrame GetFrame() const;
 
 protected:
-  void reset(lldb::ExecutionContextRefSP &event_sp);
-
   lldb_private::ExecutionContextRef *get() const;
 
 private:



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


[Lldb-commits] [PATCH] D109879: [lldb] [DynamicRegisterInfo] Update RegisterInfo with copy of value_regs/invalidate_regs

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny abandoned this revision.
mgorny added a comment.

Ok, I see now that I was wrong. `DynamicRegisterInfo::Finalize()` already does 
that. I've finally managed to figure out what this scary code does ;-).


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

https://reviews.llvm.org/D109879

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


[Lldb-commits] [PATCH] D109795: [MachCore] Report arm64 thread exception state

2021-09-16 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 373014.
vsk added a comment.

- Limit testing to arm64/arm64e only.
- Set a stop reason for crashing threads only (and not for threads waiting on a 
syscall to finish).
- Use @jasonmolenda's multi-threaded test case; make sure we only select the 
crashing thread.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109795

Files:
  lldb/include/lldb/Target/AppleArm64ExceptionClass.def
  lldb/include/lldb/Target/AppleArm64ExceptionClass.h
  lldb/include/lldb/module.modulemap
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
  lldb/test/API/macosx/corefile-exception-reason/Makefile
  lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
  lldb/test/API/macosx/corefile-exception-reason/main.cpp

Index: lldb/test/API/macosx/corefile-exception-reason/main.cpp
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/main.cpp
@@ -0,0 +1,24 @@
+#include 
+#include 
+#include 
+#include 
+
+void *sleep_worker(void *in) {
+  sleep(30);
+  sleep(30);
+  return nullptr;
+}
+
+void *crash_worker(void *in) {
+  sleep(1);
+  volatile int *p = nullptr; // break here
+  return (void *)*p;
+}
+
+int main() {
+  std::vector threads;
+  threads.push_back(std::move(std::thread(crash_worker, nullptr)));
+  for (int i = 0; i < 15; i++)
+threads.push_back(std::move(std::thread(sleep_worker, nullptr)));
+  sleep(10);
+}
Index: lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
@@ -0,0 +1,43 @@
+"""Test that lldb can report the exception reason for threads in a corefile."""
+
+import os
+import re
+import subprocess
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCorefileExceptionReason(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfOutOfTreeDebugserver  # newer debugserver required for these qMemoryRegionInfo types
+@no_debug_info_test
+@skipUnlessDarwin
+@skipIf(archs=['i386','x86_64']) # exception codes not yet supported for Intel macs
+def test(self):
+
+corefile = self.getBuildArtifact("process.core")
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+self.runCmd("continue")
+
+self.runCmd("process save-core -s stack " + corefile)
+process.Kill()
+self.dbg.DeleteTarget(target)
+
+# Now load the corefile
+target = self.dbg.CreateTarget('')
+process = target.LoadCore(corefile)
+thread = process.GetSelectedThread()
+self.assertTrue(process.GetSelectedThread().IsValid())
+if self.TraceOn():
+self.runCmd("image list")
+self.runCmd("bt")
+self.runCmd("fr v")
+
+self.assertTrue(thread.GetStopDescription(256) == "ESR_EC_DABORT_EL0 (fault address: 0x0)")
Index: lldb/test/API/macosx/corefile-exception-reason/Makefile
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES = main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
@@ -9,7 +9,9 @@
 #include "ThreadMachCore.h"
 
 #include "lldb/Breakpoint/Watchpoint.h"
+#include "lldb/Host/SafeMachO.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/AppleArm64ExceptionClass.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
@@ -17,6 +19,7 @@
 #include "lldb/Target/Unwind.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -88,10 +91,55 @@
   return reg_ctx_sp;
 }
 
+static bool IsCrashExceptionClass(AppleArm64ExceptionClass EC) {
+  switch (EC) {
+  case AppleArm64ExceptionClass::ESR_EC_UNCATEGORIZED:
+  case AppleArm64ExceptionClass::ESR_EC_SVC_32:
+  case AppleArm64ExceptionClass::ESR_EC_SVC_64:
+// In the ARM exception model, a process takes an exception when asking the
+// kernel to service a system call. Don't treat this like a crash.
+return false;
+  default:
+return true;
+  }
+}
+
 bool ThreadMachCore::CalculateStopInfo() {
   ProcessSP process_sp(GetProces

[Lldb-commits] [PATCH] D109795: [MachCore] Report arm64 thread exception state

2021-09-16 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 373016.
vsk added a comment.

- Add missing skipIf(arch=no_match(['arm64', 'arm64e'])) change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109795

Files:
  lldb/include/lldb/Target/AppleArm64ExceptionClass.def
  lldb/include/lldb/Target/AppleArm64ExceptionClass.h
  lldb/include/lldb/module.modulemap
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
  lldb/test/API/macosx/corefile-exception-reason/Makefile
  lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
  lldb/test/API/macosx/corefile-exception-reason/main.cpp

Index: lldb/test/API/macosx/corefile-exception-reason/main.cpp
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/main.cpp
@@ -0,0 +1,24 @@
+#include 
+#include 
+#include 
+#include 
+
+void *sleep_worker(void *in) {
+  sleep(30);
+  sleep(30);
+  return nullptr;
+}
+
+void *crash_worker(void *in) {
+  sleep(1);
+  volatile int *p = nullptr; // break here
+  return (void *)*p;
+}
+
+int main() {
+  std::vector threads;
+  threads.push_back(std::move(std::thread(crash_worker, nullptr)));
+  for (int i = 0; i < 15; i++)
+threads.push_back(std::move(std::thread(sleep_worker, nullptr)));
+  sleep(10);
+}
Index: lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
@@ -0,0 +1,43 @@
+"""Test that lldb can report the exception reason for threads in a corefile."""
+
+import os
+import re
+import subprocess
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCorefileExceptionReason(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfOutOfTreeDebugserver  # newer debugserver required for these qMemoryRegionInfo types
+@no_debug_info_test
+@skipUnlessDarwin
+@skipIf(archs=no_match(['arm64','arm64e']))
+def test(self):
+
+corefile = self.getBuildArtifact("process.core")
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+self.runCmd("continue")
+
+self.runCmd("process save-core -s stack " + corefile)
+process.Kill()
+self.dbg.DeleteTarget(target)
+
+# Now load the corefile
+target = self.dbg.CreateTarget('')
+process = target.LoadCore(corefile)
+thread = process.GetSelectedThread()
+self.assertTrue(process.GetSelectedThread().IsValid())
+if self.TraceOn():
+self.runCmd("image list")
+self.runCmd("bt")
+self.runCmd("fr v")
+
+self.assertTrue(thread.GetStopDescription(256) == "ESR_EC_DABORT_EL0 (fault address: 0x0)")
Index: lldb/test/API/macosx/corefile-exception-reason/Makefile
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES = main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
@@ -9,7 +9,9 @@
 #include "ThreadMachCore.h"
 
 #include "lldb/Breakpoint/Watchpoint.h"
+#include "lldb/Host/SafeMachO.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/AppleArm64ExceptionClass.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
@@ -17,6 +19,7 @@
 #include "lldb/Target/Unwind.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -88,10 +91,55 @@
   return reg_ctx_sp;
 }
 
+static bool IsCrashExceptionClass(AppleArm64ExceptionClass EC) {
+  switch (EC) {
+  case AppleArm64ExceptionClass::ESR_EC_UNCATEGORIZED:
+  case AppleArm64ExceptionClass::ESR_EC_SVC_32:
+  case AppleArm64ExceptionClass::ESR_EC_SVC_64:
+// In the ARM exception model, a process takes an exception when asking the
+// kernel to service a system call. Don't treat this like a crash.
+return false;
+  default:
+return true;
+  }
+}
+
 bool ThreadMachCore::CalculateStopInfo() {
   ProcessSP process_sp(GetProcess());
   if (process_sp) {
-SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, SIGSTOP));
+StopInfoSP stop_info;
+RegisterContextSP reg_ctx_sp = GetRegisterContext();
+
+if (reg_ctx_sp) {

[Lldb-commits] [PATCH] D109906: [lldb] [test] Add unittest for DynamicRegisterInfo::Finalize()

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
mgorny requested review of this revision.

https://reviews.llvm.org/D109906

Files:
  lldb/unittests/Process/Utility/CMakeLists.txt
  lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp

Index: lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
===
--- /dev/null
+++ lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
@@ -0,0 +1,91 @@
+//===-- DynamicRegisterInfoTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
+
+#include "lldb/Utility/ArchSpec.h"
+
+using namespace lldb_private;
+
+TEST(DynamicRegisterInfoTest, finalize_regs) {
+  DynamicRegisterInfo info;
+  ConstString group{"group"};
+
+  uint32_t regnums[3] = {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM};
+
+  // Add regular registers
+  struct RegisterInfo new_reg {
+"b1", nullptr, 8, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
+lldb::eFormatUnsigned,
+{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 0, 0},
+nullptr, nullptr, nullptr, 0
+  };
+  info.AddRegister(new_reg, group);
+  new_reg.name = "b2";
+  new_reg.kinds[lldb::eRegisterKindProcessPlugin]++;
+  new_reg.kinds[lldb::eRegisterKindLLDB]++;
+  info.AddRegister(new_reg, group);
+
+  // Add a few sub-registers
+  new_reg.name = "s1";
+  new_reg.byte_size = 4;
+  new_reg.kinds[lldb::eRegisterKindProcessPlugin]++;
+  new_reg.kinds[lldb::eRegisterKindLLDB]++;
+  regnums[0] = 0;
+  new_reg.value_regs = regnums;
+  info.AddRegister(new_reg, group);
+
+  new_reg.name = "s2";
+  new_reg.kinds[lldb::eRegisterKindProcessPlugin]++;
+  new_reg.kinds[lldb::eRegisterKindLLDB]++;
+  regnums[0] = 1;
+  info.AddRegister(new_reg, group);
+
+  // Add a register with weird invalidation
+  new_reg.name = "x";
+  new_reg.kinds[lldb::eRegisterKindProcessPlugin]++;
+  new_reg.kinds[lldb::eRegisterKindLLDB]++;
+  new_reg.value_regs = nullptr;
+  regnums[0] = 1;
+  regnums[1] = 0;
+  new_reg.invalidate_regs = regnums;
+  info.AddRegister(new_reg, group);
+
+  info.Finalize(lldb_private::ArchSpec());
+
+  const RegisterInfo *added_reg = info.GetRegisterInfoAtIndex(0);
+  ASSERT_NE(added_reg, nullptr);
+  EXPECT_EQ(added_reg->byte_offset, 0U);
+
+  added_reg = info.GetRegisterInfoAtIndex(1);
+  ASSERT_NE(added_reg, nullptr);
+  EXPECT_EQ(added_reg->byte_offset, 8U);
+
+  added_reg = info.GetRegisterInfoAtIndex(2);
+  ASSERT_NE(added_reg, nullptr);
+  EXPECT_EQ(added_reg->byte_offset, 0U);
+  EXPECT_EQ(added_reg->value_regs[0], 0U);
+  EXPECT_EQ(added_reg->value_regs[1], LLDB_INVALID_REGNUM);
+
+  added_reg = info.GetRegisterInfoAtIndex(3);
+  ASSERT_NE(added_reg, nullptr);
+  EXPECT_EQ(added_reg->byte_offset, 8U);
+  EXPECT_EQ(added_reg->value_regs[0], 1U);
+  EXPECT_EQ(added_reg->value_regs[1], LLDB_INVALID_REGNUM);
+
+  added_reg = info.GetRegisterInfoAtIndex(4);
+  ASSERT_NE(added_reg, nullptr);
+  EXPECT_EQ(added_reg->byte_offset, 16U);
+  EXPECT_EQ(added_reg->invalidate_regs[0], 0U);
+  EXPECT_EQ(added_reg->invalidate_regs[1], 1U);
+  EXPECT_EQ(added_reg->invalidate_regs[2], LLDB_INVALID_REGNUM);
+}
Index: lldb/unittests/Process/Utility/CMakeLists.txt
===
--- lldb/unittests/Process/Utility/CMakeLists.txt
+++ lldb/unittests/Process/Utility/CMakeLists.txt
@@ -15,9 +15,10 @@
   ${NETBSD_SOURCES})
 
 add_lldb_unittest(ProcessUtilityTests
-  RegisterContextTest.cpp
+  DynamicRegisterInfoTest.cpp
   LinuxProcMapsTest.cpp
   MemoryTagManagerAArch64MTETest.cpp
+  RegisterContextTest.cpp
   ${PLATFORM_SOURCES}
 
   LINK_LIBS
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add pseudo-regs if missing [WIP]

2021-09-16 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 373024.
mgorny retitled this revision from "[lldb] [ABI/AArch64] Add 32-bit pseudo-regs 
if missing [WIP]" to "[lldb] [ABI/AArch64] Add pseudo-regs if missing [WIP]".
mgorny edited the summary of this revision.
mgorny added a comment.

Cover FPU registers.


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

https://reviews.llvm.org/D109876

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -380,6 +380,7 @@
 return "".join(reg_data)
 
 def writeRegisters(self, reg_hex):
+reg_data[:] = [reg_hex]
 return "OK"
 
 def haltReason(self):
@@ -429,3 +430,43 @@
["v0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
 self.match("register read v31",
["v31 = {0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae 0xaf 0xb0}"])
+
+# test partial registers
+self.match("register read w0",
+   ["w0 = 0x04030201"])
+self.runCmd("register write w0 0xfffefdfc")
+self.match("register read x0",
+   ["x0 = 0x08070605fffefdfc"])
+
+self.match("register read w1",
+   ["w1 = 0x14131211"])
+self.runCmd("register write w1 0xefeeedec")
+self.match("register read x1",
+   ["x1 = 0x18171615efeeedec"])
+
+self.match("register read w30",
+   ["w30 = 0x44434241"])
+self.runCmd("register write w30 0xdfdedddc")
+self.match("register read x30",
+   ["x30 = 0x48474645dfdedddc"])
+
+self.match("register read w31",
+   ["w31 = 0x54535251"])
+self.runCmd("register write w31 0xcfcecdcc")
+self.match("register read x31",
+   ["sp = 0x58575655cfcecdcc"])
+
+# test FPU registers (overlapping with vector registers)
+self.runCmd("register write d0 16")
+self.match("register read v0",
+   ["v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.runCmd("register write v31 '{0x00 0x00 0x00 0x00 0x00 0x00 0x50 0x40 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
+self.match("register read d31",
+   ["d31 = 64"])
+
+self.runCmd("register write s0 32")
+self.match("register read v0",
+   ["v0 = {0x00 0x00 0x00 0x42 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.runCmd("register write v31 '{0x00 0x00 0x00 0x43 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
+self.match("register read s31",
+   ["s31 = 128"])
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -453,6 +453,7 @@
   if (GetGDBServerRegisterInfo(arch_to_use))
 return;
 
+  ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use);
   char packet[128];
   uint32_t reg_offset = LLDB_INVALID_INDEX32;
   uint32_t reg_num = 0;
@@ -582,7 +583,7 @@
 // We have to make a temporary ABI here, and not use the GetABI because
 // this code gets called in DidAttach, when the target architecture
 // (and consequently the ABI we'll get from the process) may be wrong.
-if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
+if (abi_sp)
   abi_sp->AugmentRegisterInfo(reg_info);
 
 m_register_info_sp->AddRegister(reg_info, set_name);
@@ -595,6 +596,8 @@
   }
 
   if (m_register_info_sp->GetNumRegisters() > 0) {
+if (abi_sp)
+  abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
 m_register_info_sp->Finalize(GetTarget().GetArchitecture());
 return;
   }
@@ -618,6 +621,8 @@
   }
 
   // At this point, we can finalize our register info.
+  if (abi_sp)
+abi_sp->PreFinalizeDynamicRegisterInfo(*m_register_info_sp);
   m_register_info_sp->Finalize(GetTarget().GetArchitecture());
 }
 
@@ -4707,8 +4712,12 @@
   uint32_t reg_num_remote = 0;
   uint32_t reg_num_local = 0;
   if (GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, "target.xml",
-  

[Lldb-commits] [PATCH] D109908: [lldb] Show fix-it applied even if expression didn't evaluate succesfully

2021-09-16 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 created this revision.
augusto2112 added reviewers: aprantl, labath.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

If we applied a fix-it before evaluating an expression and that
expression didn't evaluate correctly, we should still tell users about
the fix-it we applied since that may be the reason why it didn't work
correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109908

Files:
  lldb/source/Commands/CommandObjectExpression.cpp


Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -421,9 +421,8 @@
   // We only tell you about the FixIt if we applied it.  The compiler errors
   // will suggest the FixIt if it parsed.
   if (!m_fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
-if (success == eExpressionCompleted)
-  error_stream.Printf("  Fix-it applied, fixed expression was: \n%s\n",
-  m_fixed_expression.c_str());
+error_stream.Printf("  Fix-it applied, fixed expression was: \n%s\n",
+m_fixed_expression.c_str());
   }
 
   if (result_valobj_sp) {


Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -421,9 +421,8 @@
   // We only tell you about the FixIt if we applied it.  The compiler errors
   // will suggest the FixIt if it parsed.
   if (!m_fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
-if (success == eExpressionCompleted)
-  error_stream.Printf("  Fix-it applied, fixed expression was: \n%s\n",
-  m_fixed_expression.c_str());
+error_stream.Printf("  Fix-it applied, fixed expression was: \n%s\n",
+m_fixed_expression.c_str());
   }
 
   if (result_valobj_sp) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 47dd1f6 - [lldb] Skip TestAppleSimulatorOSType if json parsing fails

2021-09-16 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2021-09-16T16:38:20-03:00
New Revision: 47dd1f642846d476e3d789f4aa941699dc0ed3fe

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

LOG: [lldb] Skip TestAppleSimulatorOSType if json parsing fails

xcodebuild, which is invoked by the apple_simulator_test decorator, may
may return a successful status even if it was unable to run due to the
authorization agent denying it. This causes the TestAppleSimulatorOSType
to run when it shouldn't, and throw an excpection when parsing the JSON
that lists the simulators available. Wrap the json parsing in a
try/except block and if it fails, skip the ttest.

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

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 01942344e0e10..1230af95a9a33 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -20,7 +20,16 @@ def check_simulator_ostype(self, sdk, platform_name, 
arch=platform.machine()):
 cmd = ['xcrun', 'simctl', 'list', '-j', 'devices']
 self.trace(' '.join(cmd))
 sim_devices_str = subprocess.check_output(cmd).decode("utf-8")
-sim_devices = json.loads(sim_devices_str)['devices']
+
+# xcodebuild, which is invoked by the apple_simulator_test decorator,
+# may return a successful status even if it was unable to run due to 
+# the authorization agent denying it. Try to parse the json that lists 
+# the simulators but if that fails skip the test.
+try:
+sim_devices = json.loads(sim_devices_str)['devices']
+except json.decoder.JSONDecodeError:
+self.skipTest("Could not parse JSON of simulators available")
+
 # Find an available simulator for the requested platform
 deviceUDID = None
 deviceRuntime = None



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


[Lldb-commits] [PATCH] D109336: [lldb] Skip TestAppleSimulatorOSType if json parsing fails

2021-09-16 Thread Augusto Noronha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47dd1f642846: [lldb] Skip TestAppleSimulatorOSType if json 
parsing fails (authored by augusto2112).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109336

Files:
  lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py


Index: lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
===
--- lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -20,7 +20,16 @@
 cmd = ['xcrun', 'simctl', 'list', '-j', 'devices']
 self.trace(' '.join(cmd))
 sim_devices_str = subprocess.check_output(cmd).decode("utf-8")
-sim_devices = json.loads(sim_devices_str)['devices']
+
+# xcodebuild, which is invoked by the apple_simulator_test decorator,
+# may return a successful status even if it was unable to run due to 
+# the authorization agent denying it. Try to parse the json that lists 
+# the simulators but if that fails skip the test.
+try:
+sim_devices = json.loads(sim_devices_str)['devices']
+except json.decoder.JSONDecodeError:
+self.skipTest("Could not parse JSON of simulators available")
+
 # Find an available simulator for the requested platform
 deviceUDID = None
 deviceRuntime = None


Index: lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
===
--- lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -20,7 +20,16 @@
 cmd = ['xcrun', 'simctl', 'list', '-j', 'devices']
 self.trace(' '.join(cmd))
 sim_devices_str = subprocess.check_output(cmd).decode("utf-8")
-sim_devices = json.loads(sim_devices_str)['devices']
+
+# xcodebuild, which is invoked by the apple_simulator_test decorator,
+# may return a successful status even if it was unable to run due to 
+# the authorization agent denying it. Try to parse the json that lists 
+# the simulators but if that fails skip the test.
+try:
+sim_devices = json.loads(sim_devices_str)['devices']
+except json.decoder.JSONDecodeError:
+self.skipTest("Could not parse JSON of simulators available")
+
 # Find an available simulator for the requested platform
 deviceUDID = None
 deviceRuntime = None
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109908: [lldb] Show fix-it applied even if expression didn't evaluate succesfully

2021-09-16 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: JDevlieghere.

Could you add a test for that? The usual test fixit in Clang is `.`/`->` mixup, 
e.g.

  (lldb) expr struct Foo { int i; }; Foo *f; f.i ; 
unknown_identifier_for_fatal_error
  (int) $0 = 0
Fix-it applied, fixed expression was: 
  struct Foo { int i; }; Foo *f; f->i ; unknown_identifier_for_fatal_error
  ...

I think this patch also needs to update `UserExpression::Evaluate` which, IIRC, 
is clearing the fixed expression when it fails to parse.

The direction of the patch is IMHO fine. One thing that would be nice is to see 
if we could maybe preserve the Fix-It diagnostics from the original expression. 
If we just return whatever the fixed expression fails with then it's not clear 
why the compiler actually generated a Fix-It. But that's more of a nice-to-have 
I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109908

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


[Lldb-commits] [lldb] a65f6aa - [lldb] Refactor and rename CPlusPlusLanguage::FindAlternateFunctionManglings

2021-09-16 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2021-09-16T13:13:07-07:00
New Revision: a65f6aafe2d357cd83de62832a2bdae49a2d6749

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

LOG: [lldb] Refactor and rename 
CPlusPlusLanguage::FindAlternateFunctionManglings

I have 2 goals with this change:
1. Disambiguate between CPlusPlus::FindAlternateFunctionManglings and
   IRExecutionUnit::FindBestAlternateMangledName. These are named very
   similar things, they try to do very similar things, but their
   approaches are different. This change should make it clear that one
   is generating possible alternate manglings (through some
   heuristics-based approach) and the other is finding alternate
   manglings (through searching the SymbolFile for potential matches).
2. Change GenerateAlternateFunctionManglings from a static method in
   CPlusPlusLanguage to a virtual method in Language. This will allow us
   to remove a direct use of CPlusPlusLanguage in IRExecutionUnit,
   further pushing it to be more general. This change doesn't meet this
   goal completely but allows for it to happen later.

Though this doesn't remove IRExecutionUnit's dependency on
CPlusPlusLanguage, it does bring us closer to that goal.

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

Added: 


Modified: 
lldb/include/lldb/Target/Language.h
lldb/source/Expression/IRExecutionUnit.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 2ad9677ea3f8c..41a0a5e13a0e0 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -293,6 +293,13 @@ class Language : public PluginInterface {
   static LanguageSet GetLanguagesSupportingTypeSystemsForExpressions();
   static LanguageSet GetLanguagesSupportingREPLs();
 
+  // Given a mangled function name, calculates some alternative manglings since
+  // the compiler mangling may not line up with the symbol we are expecting.
+  virtual std::vector
+  GenerateAlternateFunctionManglings(const ConstString mangled) const {
+return std::vector();
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 

diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 5c58ee6fcaea0..4306a9c2505c7 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -723,9 +723,11 @@ void IRExecutionUnit::CollectCandidateCPlusPlusNames(
   }
 }
 
-std::set alternates;
-CPlusPlusLanguage::FindAlternateFunctionManglings(name, alternates);
-CPP_names.insert(CPP_names.end(), alternates.begin(), alternates.end());
+if (auto *cpp_lang = Language::FindPlugin(lldb::eLanguageTypeC_plus_plus)) 
{
+  std::vector alternates =
+  cpp_lang->GenerateAlternateFunctionManglings(name);
+  CPP_names.insert(CPP_names.end(), alternates.begin(), alternates.end());
+}
   }
 }
 

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 0a4d4fb3a643c..c839a3d70cc10 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -424,9 +424,10 @@ class CtorDtorSubstitutor : public 
ManglingSubstitutor {
 };
 } // namespace
 
-uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
-const ConstString mangled_name, std::set &alternates) {
-  const auto start_size = alternates.size();
+std::vector CPlusPlusLanguage::GenerateAlternateFunctionManglings(
+const ConstString mangled_name) const {
+  std::vector alternates;
+
   /// Get a basic set of alternative manglings for the given symbol `name`, by
   /// making a few basic possible substitutions on basic types, storage 
duration
   /// and `const`ness for the given symbol. The output parameter `alternates`
@@ -439,7 +440,7 @@ uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
   strncmp(mangled_name.GetCString(), "_ZNK", 4)) {
 std::string fixed_scratch("_ZNK");
 fixed_scratch.append(mangled_name.GetCString() + 3);
-alternates.insert(ConstString(fixed_scratch));
+alternates.push_back(ConstString(fixed_scratch));
   }
 
   // Maybe we're looking for a static symbol but we thought it was global...
@@ -447,7 +448,7 @@ uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
   strncmp(mangled_name.GetCString(), "_ZL", 3)) {
 std::string fixed_scratch("_ZL");
 fixed_scratch.append(mangled_name.GetCString() + 2);
-   

[Lldb-commits] [PATCH] D109785: [lldb] Refactor and rename CPlusPlusLanguage::FindAlternateFunctionManglings

2021-09-16 Thread Alex Langford via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa65f6aafe2d3: [lldb] Refactor and rename 
CPlusPlusLanguage::FindAlternateFunctionManglings (authored by bulbazord).

Changed prior to commit:
  https://reviews.llvm.org/D109785?vs=372555&id=373054#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109785

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
  lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -7,6 +7,8 @@
 //===--===//
 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
 #include "Plugins/Language/CPlusPlus/CPlusPlusNameParser.h"
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/lldb-enumerations.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -185,29 +187,32 @@
   "operator<=>", context, basename));
 }
 
-static std::set FindAlternate(llvm::StringRef Name) {
-  std::set Results;
-  uint32_t Count = CPlusPlusLanguage::FindAlternateFunctionManglings(
-  ConstString(Name), Results);
-  EXPECT_EQ(Count, Results.size());
-  std::set Strings;
-  for (ConstString Str : Results)
-Strings.insert(std::string(Str.GetStringRef()));
+static std::vector GenerateAlternate(llvm::StringRef Name) {
+  std::vector Strings;
+  if (Language *CPlusPlusLang =
+  Language::FindPlugin(lldb::eLanguageTypeC_plus_plus)) {
+std::vector Results =
+CPlusPlusLang->GenerateAlternateFunctionManglings(ConstString(Name));
+for (ConstString Str : Results)
+  Strings.push_back(std::string(Str.GetStringRef()));
+  }
   return Strings;
 }
 
-TEST(CPlusPlusLanguage, FindAlternateFunctionManglings) {
+TEST(CPlusPlusLanguage, GenerateAlternateFunctionManglings) {
   using namespace testing;
 
-  EXPECT_THAT(FindAlternate("_ZN1A1fEv"),
+  SubsystemRAII lang;
+
+  EXPECT_THAT(GenerateAlternate("_ZN1A1fEv"),
   UnorderedElementsAre("_ZNK1A1fEv", "_ZLN1A1fEv"));
-  EXPECT_THAT(FindAlternate("_ZN1A1fEa"), Contains("_ZN1A1fEc"));
-  EXPECT_THAT(FindAlternate("_ZN1A1fEx"), Contains("_ZN1A1fEl"));
-  EXPECT_THAT(FindAlternate("_ZN1A1fEy"), Contains("_ZN1A1fEm"));
-  EXPECT_THAT(FindAlternate("_ZN1A1fEai"), Contains("_ZN1A1fEci"));
-  EXPECT_THAT(FindAlternate("_ZN1AC1Ev"), Contains("_ZN1AC2Ev"));
-  EXPECT_THAT(FindAlternate("_ZN1AD1Ev"), Contains("_ZN1AD2Ev"));
-  EXPECT_THAT(FindAlternate("_bogus"), IsEmpty());
+  EXPECT_THAT(GenerateAlternate("_ZN1A1fEa"), Contains("_ZN1A1fEc"));
+  EXPECT_THAT(GenerateAlternate("_ZN1A1fEx"), Contains("_ZN1A1fEl"));
+  EXPECT_THAT(GenerateAlternate("_ZN1A1fEy"), Contains("_ZN1A1fEm"));
+  EXPECT_THAT(GenerateAlternate("_ZN1A1fEai"), Contains("_ZN1A1fEci"));
+  EXPECT_THAT(GenerateAlternate("_ZN1AC1Ev"), Contains("_ZN1AC2Ev"));
+  EXPECT_THAT(GenerateAlternate("_ZN1AD1Ev"), Contains("_ZN1AD2Ev"));
+  EXPECT_THAT(GenerateAlternate("_bogus"), IsEmpty());
 }
 
 TEST(CPlusPlusLanguage, CPlusPlusNameParser) {
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -127,11 +127,8 @@
   llvm::StringRef &context,
   llvm::StringRef &identifier);
 
-  // Given a mangled function name, calculates some alternative manglings since
-  // the compiler mangling may not line up with the symbol we are expecting
-  static uint32_t
-  FindAlternateFunctionManglings(const ConstString mangled,
- std::set &candidates);
+  std::vector
+  GenerateAlternateFunctionManglings(const ConstString mangled) const override;
 
   // PluginInterface protocol
   ConstString GetPluginName() override;
Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -424,9 +424,10 @@
 };
 } // namespace
 
-uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
-const ConstString mangled_name, std::set &alternates) {
-  const auto start_size = alternates.size();
+std::vector CPlusPlusLanguage::GenerateAlternateFunctionManglings(
+const ConstString mangled_name) 

[Lldb-commits] [lldb] 7eb6774 - [MachCore] Report arm64 thread exception state

2021-09-16 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-09-16T13:35:06-07:00
New Revision: 7eb67748f9d7186419d678e807c01fc2a3811a80

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

LOG: [MachCore] Report arm64 thread exception state

A MachO userspace corefile may contain LC_THREAD commands which specify
thread exception state.

For arm64* only (for now), report a human-readable version of this state
as the thread stop reason, instead of 'SIGSTOP'.

As a follow-up, similar functionality can be implemented for x86 cores
by translating the trapno/err exception registers.

rdar://82898146

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

Added: 
lldb/include/lldb/Target/AppleArm64ExceptionClass.def
lldb/include/lldb/Target/AppleArm64ExceptionClass.h
lldb/test/API/macosx/corefile-exception-reason/Makefile

lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
lldb/test/API/macosx/corefile-exception-reason/main.cpp

Modified: 
lldb/include/lldb/module.modulemap
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.def 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
new file mode 100644
index 0..9a938c3b302c8
--- /dev/null
+++ b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
@@ -0,0 +1,50 @@
+/*===-- AppleArm64ExceptionClass.def ---*- C++ -*-=== 
*\
+|*
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+|* See https://llvm.org/LICENSE.txt for license information.
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+|*
+\*===--===*/
+
+// Defines ESR exception classes for Apple arm64* targets.
+// These largely map 1:1 to the exception classes defined in ARM's architecture
+// reference manual, but there are some Apple-specific additions.
+
+#ifndef APPLE_ARM64_EXCEPTION_CLASS
+#error "APPLE_ARM64_EXCEPTION_CLASS(Name, Code) not defined."
+#endif
+
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_UNCATEGORIZED, 0x00)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WFI_WFE, 0x01)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP15_TRAP, 0x03)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP15_TRAP, 0x04)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP14_TRAP, 0x05)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_LDC_STC_CP14_TRAP, 0x06)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_TRAP_SIMD_FP, 0x07)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PTRAUTH_INSTR_TRAP, 0x09)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP14_TRAP, 0x0c)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_ILLEGAL_INSTR_SET, 0x0e)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_32, 0x11)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_64, 0x15)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MSR_TRAP, 0x18)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PAC_FAIL, 0x1C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL0, 0x20)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL1, 0x21)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PC_ALIGN, 0x22)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL0, 0x24)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL1, 0x25)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SP_ALIGN, 0x26)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_32, 0x28)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_64, 0x2C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SERROR_INTERRUPT, 0x2F)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL0, 0x30)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL1, 0x31)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL0, 0x32)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL1, 0x33)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL0, 0x34)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL1, 0x35)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_AARCH32, 0x38)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BRK_AARCH64, 0x3C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PRIV, 0x3F)
+
+#undef APPLE_ARM64_EXCEPTION_CLASS

diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.h 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
new file mode 100644
index 0..95f58ee081abf
--- /dev/null
+++ b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
@@ -0,0 +1,50 @@
+//===-- AppleArm64ExceptionClass.h --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
+#define LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
+
+#include 
+
+namespace lldb_private {
+
+enum c

[Lldb-commits] [PATCH] D109795: [MachCore] Report arm64 thread exception state

2021-09-16 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7eb67748f9d7: [MachCore] Report arm64 thread exception state 
(authored by vsk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109795

Files:
  lldb/include/lldb/Target/AppleArm64ExceptionClass.def
  lldb/include/lldb/Target/AppleArm64ExceptionClass.h
  lldb/include/lldb/module.modulemap
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
  lldb/test/API/macosx/corefile-exception-reason/Makefile
  lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
  lldb/test/API/macosx/corefile-exception-reason/main.cpp

Index: lldb/test/API/macosx/corefile-exception-reason/main.cpp
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/main.cpp
@@ -0,0 +1,24 @@
+#include 
+#include 
+#include 
+#include 
+
+void *sleep_worker(void *in) {
+  sleep(30);
+  sleep(30);
+  return nullptr;
+}
+
+void *crash_worker(void *in) {
+  sleep(1);
+  volatile int *p = nullptr; // break here
+  return (void *)*p;
+}
+
+int main() {
+  std::vector threads;
+  threads.push_back(std::move(std::thread(crash_worker, nullptr)));
+  for (int i = 0; i < 15; i++)
+threads.push_back(std::move(std::thread(sleep_worker, nullptr)));
+  sleep(10);
+}
Index: lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
@@ -0,0 +1,43 @@
+"""Test that lldb can report the exception reason for threads in a corefile."""
+
+import os
+import re
+import subprocess
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCorefileExceptionReason(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfOutOfTreeDebugserver  # newer debugserver required for these qMemoryRegionInfo types
+@no_debug_info_test
+@skipUnlessDarwin
+@skipIf(archs=no_match(['arm64','arm64e']))
+def test(self):
+
+corefile = self.getBuildArtifact("process.core")
+self.build()
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+self.runCmd("continue")
+
+self.runCmd("process save-core -s stack " + corefile)
+process.Kill()
+self.dbg.DeleteTarget(target)
+
+# Now load the corefile
+target = self.dbg.CreateTarget('')
+process = target.LoadCore(corefile)
+thread = process.GetSelectedThread()
+self.assertTrue(process.GetSelectedThread().IsValid())
+if self.TraceOn():
+self.runCmd("image list")
+self.runCmd("bt")
+self.runCmd("fr v")
+
+self.assertTrue(thread.GetStopDescription(256) == "ESR_EC_DABORT_EL0 (fault address: 0x0)")
Index: lldb/test/API/macosx/corefile-exception-reason/Makefile
===
--- /dev/null
+++ lldb/test/API/macosx/corefile-exception-reason/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES = main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
@@ -9,7 +9,9 @@
 #include "ThreadMachCore.h"
 
 #include "lldb/Breakpoint/Watchpoint.h"
+#include "lldb/Host/SafeMachO.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/AppleArm64ExceptionClass.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
@@ -17,6 +19,7 @@
 #include "lldb/Target/Unwind.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -88,10 +91,55 @@
   return reg_ctx_sp;
 }
 
+static bool IsCrashExceptionClass(AppleArm64ExceptionClass EC) {
+  switch (EC) {
+  case AppleArm64ExceptionClass::ESR_EC_UNCATEGORIZED:
+  case AppleArm64ExceptionClass::ESR_EC_SVC_32:
+  case AppleArm64ExceptionClass::ESR_EC_SVC_64:
+// In the ARM exception model, a process takes an exception when asking the
+// kernel to service a system call. Don't treat this like a crash.
+return false;
+  default:
+return true;
+  }
+}
+
 bool ThreadMachCore::CalculateStopInfo() {
   ProcessSP process_sp(GetProcess());
   if (process_sp) {
-SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, SIGSTOP));
+StopI

[Lldb-commits] [lldb] 79e48f3 - Revert "[MachCore] Report arm64 thread exception state"

2021-09-16 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-09-16T13:43:35-07:00
New Revision: 79e48f3c7c8ca205048f584b7658ef001a677c6d

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

LOG: Revert "[MachCore] Report arm64 thread exception state"

This reverts commit 7eb67748f9d7186419d678e807c01fc2a3811a80. It causes
TestMachCore.MachCoreTestCase to fail.

Added: 


Modified: 
lldb/include/lldb/module.modulemap
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp

Removed: 
lldb/include/lldb/Target/AppleArm64ExceptionClass.def
lldb/include/lldb/Target/AppleArm64ExceptionClass.h
lldb/test/API/macosx/corefile-exception-reason/Makefile

lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
lldb/test/API/macosx/corefile-exception-reason/main.cpp



diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.def 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
deleted file mode 100644
index 9a938c3b302c8..0
--- a/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
+++ /dev/null
@@ -1,50 +0,0 @@
-/*===-- AppleArm64ExceptionClass.def ---*- C++ -*-=== 
*\
-|*
-|* Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-|* See https://llvm.org/LICENSE.txt for license information.
-|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-|*
-\*===--===*/
-
-// Defines ESR exception classes for Apple arm64* targets.
-// These largely map 1:1 to the exception classes defined in ARM's architecture
-// reference manual, but there are some Apple-specific additions.
-
-#ifndef APPLE_ARM64_EXCEPTION_CLASS
-#error "APPLE_ARM64_EXCEPTION_CLASS(Name, Code) not defined."
-#endif
-
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_UNCATEGORIZED, 0x00)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WFI_WFE, 0x01)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP15_TRAP, 0x03)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP15_TRAP, 0x04)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP14_TRAP, 0x05)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_LDC_STC_CP14_TRAP, 0x06)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_TRAP_SIMD_FP, 0x07)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PTRAUTH_INSTR_TRAP, 0x09)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP14_TRAP, 0x0c)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_ILLEGAL_INSTR_SET, 0x0e)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_32, 0x11)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_64, 0x15)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MSR_TRAP, 0x18)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PAC_FAIL, 0x1C)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL0, 0x20)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL1, 0x21)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PC_ALIGN, 0x22)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL0, 0x24)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL1, 0x25)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SP_ALIGN, 0x26)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_32, 0x28)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_64, 0x2C)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SERROR_INTERRUPT, 0x2F)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL0, 0x30)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL1, 0x31)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL0, 0x32)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL1, 0x33)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL0, 0x34)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL1, 0x35)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_AARCH32, 0x38)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BRK_AARCH64, 0x3C)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PRIV, 0x3F)
-
-#undef APPLE_ARM64_EXCEPTION_CLASS

diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.h 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
deleted file mode 100644
index 95f58ee081abf..0
--- a/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- AppleArm64ExceptionClass.h --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
-#define LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
-
-#include 
-
-namespace lldb_private {
-
-enum class AppleArm64ExceptionClass : unsigned {
-#define APPLE_ARM64_EXCEPTION_CLASS(Name, Code) Name = Code,
-#include "AppleArm64ExceptionClass.def"
-};
-
-/// Get the Apple ARM64 exception class encoded within \p esr.
-inline AppleArm64ExceptionClass getAppleArm64ExceptionClass(uint32_t es

[Lldb-commits] [lldb] 8fb8601 - Revert "[lldb] Skip TestAppleSimulatorOSType if json parsing fails"

2021-09-16 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2021-09-16T17:49:59-03:00
New Revision: 8fb86011026c56204e54a2806d598249c6297d08

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

LOG: Revert "[lldb] Skip TestAppleSimulatorOSType if json parsing fails"

This reverts commit 47dd1f642846d476e3d789f4aa941699dc0ed3fe.
After discussing with Jim Ingham, we agreed to leave the test as-is
so we can catch any CI problems instead of silently skipping the test.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 1230af95a9a33..01942344e0e10 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -20,16 +20,7 @@ def check_simulator_ostype(self, sdk, platform_name, 
arch=platform.machine()):
 cmd = ['xcrun', 'simctl', 'list', '-j', 'devices']
 self.trace(' '.join(cmd))
 sim_devices_str = subprocess.check_output(cmd).decode("utf-8")
-
-# xcodebuild, which is invoked by the apple_simulator_test decorator,
-# may return a successful status even if it was unable to run due to 
-# the authorization agent denying it. Try to parse the json that lists 
-# the simulators but if that fails skip the test.
-try:
-sim_devices = json.loads(sim_devices_str)['devices']
-except json.decoder.JSONDecodeError:
-self.skipTest("Could not parse JSON of simulators available")
-
+sim_devices = json.loads(sim_devices_str)['devices']
 # Find an available simulator for the requested platform
 deviceUDID = None
 deviceRuntime = None



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


[Lldb-commits] [PATCH] D109832: [lldb/win] Fix TestIRMemoryMapWindows.test when running tests in git bash

2021-09-16 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109832

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


[Lldb-commits] [PATCH] D109928: [lldb] Remove IRExecutionUnit::CollectFallbackNames

2021-09-16 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added a reviewer: clayborg.
bulbazord requested review of this revision.
Herald added a project: LLDB.

The work that IRExecutionUnit::CollectFallbackNames is basically the
work that `CPlusPlusLanguage::GetDemangledFunctionNameWithoutArguments`
does already. It's also (at time or writing) specific to C++, so it can
be folded into `IRExecutionUnit::CollectCandidateCPlusPlusNames`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109928

Files:
  lldb/include/lldb/Expression/IRExecutionUnit.h
  lldb/source/Expression/IRExecutionUnit.cpp


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -708,51 +708,27 @@
 void IRExecutionUnit::CollectCandidateCPlusPlusNames(
 std::vector &CPP_names,
 const std::vector &C_names, const SymbolContext &sc) {
-  for (const ConstString &name : C_names) {
-if (CPlusPlusLanguage::IsCPPMangledName(name.GetCString())) {
+  if (auto *cpp_lang = Language::FindPlugin(lldb::eLanguageTypeC_plus_plus)) {
+for (const ConstString &name : C_names) {
   Mangled mangled(name);
-  ConstString demangled = mangled.GetDemangledName();
-
-  if (demangled) {
-ConstString best_alternate_mangled_name =
-FindBestAlternateMangledName(demangled, sc);
-
-if (best_alternate_mangled_name) {
-  CPP_names.push_back(best_alternate_mangled_name);
+  if (cpp_lang->SymbolNameFitsToLanguage(mangled)) {
+if (ConstString demangled = mangled.GetDemangledName()) {
+  if (ConstString best_alternate_mangled_name =
+  FindBestAlternateMangledName(demangled, sc))
+CPP_names.push_back(best_alternate_mangled_name);
 }
   }
-}
 
-if (auto *cpp_lang = Language::FindPlugin(lldb::eLanguageTypeC_plus_plus)) 
{
   std::vector alternates =
   cpp_lang->GenerateAlternateFunctionManglings(name);
   CPP_names.insert(CPP_names.end(), alternates.begin(), alternates.end());
-}
-  }
-}
-
-void IRExecutionUnit::CollectFallbackNames(
-std::vector &fallback_names,
-const std::vector &C_names) {
-  // As a last-ditch fallback, try the base name for C++ names.  It's terrible,
-  // but the DWARF doesn't always encode "extern C" correctly.
 
-  for (const ConstString &name : C_names) {
-if (!CPlusPlusLanguage::IsCPPMangledName(name.GetCString()))
-  continue;
-
-Mangled mangled_name(name);
-ConstString demangled_name = mangled_name.GetDemangledName();
-if (demangled_name.IsEmpty())
-  continue;
-
-const char *demangled_cstr = demangled_name.AsCString();
-const char *lparen_loc = strchr(demangled_cstr, '(');
-if (!lparen_loc)
-  continue;
-
-llvm::StringRef base_name(demangled_cstr, lparen_loc - demangled_cstr);
-fallback_names.push_back(ConstString(base_name));
+  // As a last-ditch fallback, try the base name for C++ names.  It's
+  // terrible, but the DWARF doesn't always encode "extern C" correctly.
+  ConstString basename =
+  cpp_lang->GetDemangledFunctionNameWithoutArguments(mangled);
+  CPP_names.push_back(basename);
+}
   }
 }
 
@@ -950,14 +926,6 @@
   CollectCandidateCPlusPlusNames(candidate_CPlusPlus_names, candidate_C_names,
  m_sym_ctx);
   ret = FindInSymbols(candidate_CPlusPlus_names, m_sym_ctx, missing_weak);
-  if (ret != LLDB_INVALID_ADDRESS)
-return ret;
-
-  std::vector candidate_fallback_names;
-
-  CollectFallbackNames(candidate_fallback_names, candidate_C_names);
-  ret = FindInSymbols(candidate_fallback_names, m_sym_ctx, missing_weak);
-
   return ret;
 }
 
Index: lldb/include/lldb/Expression/IRExecutionUnit.h
===
--- lldb/include/lldb/Expression/IRExecutionUnit.h
+++ lldb/include/lldb/Expression/IRExecutionUnit.h
@@ -221,9 +221,6 @@
   const std::vector &C_names,
   const SymbolContext &sc);
 
-  void CollectFallbackNames(std::vector &fallback_names,
-const std::vector &C_names);
-
   lldb::addr_t FindInSymbols(const std::vector &names,
  const lldb_private::SymbolContext &sc,
  bool &symbol_was_missing_weak);


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -708,51 +708,27 @@
 void IRExecutionUnit::CollectCandidateCPlusPlusNames(
 std::vector &CPP_names,
 const std::vector &C_names, const SymbolContext &sc) {
-  for (const ConstString &name : C_names) {
-if (CPlusPlusLanguage::IsCPPMangledName(name.GetCString())) {
+  if (auto *cpp_lang 

[Lldb-commits] [PATCH] D109834: [lldb/win] Improve check-lldb-shell with LLVM_ENABLE_DIA_SDK=NO

2021-09-16 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

I'm trying to understand why I've never seen the problem that this patch is 
trying to address.

I wasn't aware of `LLVM_ENABLE_DIA_SDK` so I've never turned it off.  But I've 
run `check lldb` exclusively with `LLDB_USE_NATIVE_PDB_READER=TRUE` for a long 
time, so I'm surprised to hear that some tests somehow still depend on DIA.  Is 
`check-lldb-shell` not a subset of `check-lldb`?

How exactly would I reproduce the problem here?

I don't find much meaning in the term `host-breakpoints`, but maybe that's 
because I don't understand the bug.


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

https://reviews.llvm.org/D109834

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


[Lldb-commits] [PATCH] D109928: [lldb] Remove IRExecutionUnit::CollectFallbackNames

2021-09-16 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Looks fine to me. I am assuming the full test suite passes with this change in 
place?




Comment at: lldb/source/Expression/IRExecutionUnit.cpp:717
+  if (ConstString best_alternate_mangled_name =
+  FindBestAlternateMangledName(demangled, sc))
+CPP_names.push_back(best_alternate_mangled_name);

Seems like we should be passing in the "Mangled" object into 
"FindBestAlternateMangledName" in case it has extra information. For example 
constructors and destructors have many different types (in charge, not in 
charge, etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109928

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


[Lldb-commits] [PATCH] D109928: [lldb] Remove IRExecutionUnit::CollectFallbackNames

2021-09-16 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

In D109928#3005085 , @clayborg wrote:

> Looks fine to me. I am assuming the full test suite passes with this change 
> in place?

It didn't introduce any new test failures on any of my machines.




Comment at: lldb/source/Expression/IRExecutionUnit.cpp:717
+  if (ConstString best_alternate_mangled_name =
+  FindBestAlternateMangledName(demangled, sc))
+CPP_names.push_back(best_alternate_mangled_name);

clayborg wrote:
> Seems like we should be passing in the "Mangled" object into 
> "FindBestAlternateMangledName" in case it has extra information. For example 
> constructors and destructors have many different types (in charge, not in 
> charge, etc).
Yes, I agree. I plan on tackling that function next.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109928

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


[Lldb-commits] [PATCH] D109937: [lldb] Handle malformed qfThreadInfo reply

2021-09-16 Thread Ted Woodward via Phabricator via lldb-commits
ted created this revision.
ted added a reviewer: clayborg.
ted requested review of this revision.
Herald added a project: LLDB.

If the remote gdbserver's qfThreadInfo reply has a trailing comma,
GDBRemoteCommunicationClient::GetCurrentProcessAndThreadIDs will return
an empty vector of thread ids. This will cause lldb to recurse through
three functions trying to get the list of threads, until it blows its
stack and crashes.

A trailing comma is a malformed response, but it shouldn't cause lldb to
crash. This patch will return the tids received before the malformed
response.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109937

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


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2906,8 +2906,13 @@
   if (ch == 'm') {
 do {
   auto pid_tid = response.GetPidTid(LLDB_INVALID_PROCESS_ID);
-  if (!pid_tid)
-return {};
+  if (!pid_tid) {
+// if ids is empty, this is an error
+if (ids.size() == 0)
+  return {};
+// if ids is not empty, bail out from here and process ids
+break;
+  }
 
   ids.push_back(pid_tid.getValue());
   ch = response.GetChar(); // Skip the command separator


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2906,8 +2906,13 @@
   if (ch == 'm') {
 do {
   auto pid_tid = response.GetPidTid(LLDB_INVALID_PROCESS_ID);
-  if (!pid_tid)
-return {};
+  if (!pid_tid) {
+// if ids is empty, this is an error
+if (ids.size() == 0)
+  return {};
+// if ids is not empty, bail out from here and process ids
+break;
+  }
 
   ids.push_back(pid_tid.getValue());
   ch = response.GetChar(); // Skip the command separator
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D109937: [lldb] Handle malformed qfThreadInfo reply

2021-09-16 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

We should make a test for this.




Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp:2909-2917
+  if (!pid_tid) {
+// if ids is empty, this is an error
+if (ids.size() == 0)
+  return {};
+// if ids is not empty, bail out from here and process ids
+break;
+  }

Might be nice to make sure we got LLDB_INVALID_PROCESS_ID back, as it might not 
always be zero?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109937

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