Skip to content

Commit ce7c828

Browse files
authored
[lldb][AArch64] Do not crash if NT_ARM_TLS is missing (#106478)
[D156118](https://reviews.llvm.org/D156118) states that this note is always present, but it is better to check it explicitly, as otherwise `lldb` may crash when trying to read registers.
1 parent d2b8969 commit ce7c828

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,11 @@ RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64(
254254
if (m_opt_regsets.AllSet(eRegsetMaskMTE))
255255
AddRegSetMTE();
256256

257-
// The TLS set always contains tpidr but only has tpidr2 when SME is
258-
// present.
259-
AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE));
257+
if (m_opt_regsets.AllSet(eRegsetMaskTLS)) {
258+
// The TLS set always contains tpidr but only has tpidr2 when SME is
259+
// present.
260+
AddRegSetTLS(m_opt_regsets.AllSet(eRegsetMaskSSVE));
261+
}
260262

261263
if (m_opt_regsets.AnySet(eRegsetMaskSSVE))
262264
AddRegSetSME(m_opt_regsets.AnySet(eRegsetMaskZT));
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Check that lldb does not crash if a core file does not contain an NT_ARM_TLS
2+
## note while there are notes for other dynamic register sets.
3+
4+
# RUN: yaml2obj %s -o %t
5+
# RUN: %lldb -c %t -o "re r -a" | FileCheck %s
6+
7+
# CHECK: Pointer Authentication Registers:
8+
# CHECK-NEXT: data_mask =
9+
# CHECK-NEXT: code_mask =
10+
# CHECK-NOT: Thread Local Storage Registers:
11+
12+
--- !ELF
13+
FileHeader:
14+
Class: ELFCLASS64
15+
Data: ELFDATA2LSB
16+
Type: ET_CORE
17+
Machine: EM_AARCH64
18+
ProgramHeaders:
19+
- Type: PT_NOTE
20+
FirstSec: .note
21+
LastSec: .note
22+
Sections:
23+
- Name: .note
24+
Type: SHT_NOTE
25+
Notes:
26+
- Name: CORE
27+
Desc: 0b00000000000000000000000b00000000000000000000000000000000000000389300001b930000389300001b930000000000000000000000000000000000000000000000000000e02e0000000000000000000000000000119100000000000000000000000000005ee100000000000000000000000000002f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400162e2ffff00005801400000000000200162e2ffff0000240140000000000000000000000000000100000000000000
28+
Type: NT_PRSTATUS
29+
- Name: LINUX
30+
Desc: 0000000000007f000000000000007f00
31+
Type: NT_ARM_PAC_MASK
32+
...
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config.suffixes = ['.yaml']

0 commit comments

Comments
 (0)