Skip to content

[lldb] Have disassembler show load addresses when using a core file #115453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ class InstructionLLVMC : public lldb_private::Instruction {
lldb::addr_t pc = m_address.GetFileAddress();
m_using_file_addr = true;

const bool data_from_file = disasm->m_data_from_file;
bool use_hex_immediates = true;
Disassembler::HexImmediateStyle hex_style = Disassembler::eHexStyleC;

Expand All @@ -593,12 +592,10 @@ class InstructionLLVMC : public lldb_private::Instruction {
use_hex_immediates = target->GetUseHexImmediates();
hex_style = target->GetHexImmediateStyle();

if (!data_from_file) {
const lldb::addr_t load_addr = m_address.GetLoadAddress(target);
if (load_addr != LLDB_INVALID_ADDRESS) {
pc = load_addr;
m_using_file_addr = false;
}
const lldb::addr_t load_addr = m_address.GetLoadAddress(target);
if (load_addr != LLDB_INVALID_ADDRESS) {
pc = load_addr;
m_using_file_addr = false;
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions lldb/test/Shell/Commands/command-disassemble-process.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# CHECK: (lldb) disassemble
# CHECK-NEXT: command-disassemble-process.exe`main:
# CHECK-NEXT: 0x4002 <+0>: addb %al, (%rcx)
# CHECK-NEXT: 0x4002 <+0>: jmp 0x4004 ; <+2>
# CHECK-NEXT: -> 0x4004 <+2>: addb %al, (%rdx)
# CHECK-NEXT: 0x4006 <+4>: addb %al, (%rbx)
# CHECK-NEXT: 0x4008 <+6>: addb %al, (%rsi)
Expand All @@ -32,7 +32,7 @@
# CHECK-NEXT: 0x400a: addb %al, (%rdi)
# CHECK-NEXT: (lldb) disassemble --frame
# CHECK-NEXT: command-disassemble-process.exe`main:
# CHECK-NEXT: 0x4002 <+0>: addb %al, (%rcx)
# CHECK-NEXT: 0x4002 <+0>: jmp 0x4004 ; <+2>
# CHECK-NEXT: -> 0x4004 <+2>: addb %al, (%rdx)
# CHECK-NEXT: 0x4006 <+4>: addb %al, (%rbx)
# CHECK-NEXT: 0x4008 <+6>: addb %al, (%rsi)
Expand All @@ -44,13 +44,13 @@
# CHECK-NEXT: 0x400a: addb %al, (%rdi)
# CHECK-NEXT: (lldb) disassemble --address 0x4004
# CHECK-NEXT: command-disassemble-process.exe`main:
# CHECK-NEXT: 0x4002 <+0>: addb %al, (%rcx)
# CHECK-NEXT: 0x4002 <+0>: jmp 0x4004 ; <+2>
# CHECK-NEXT: -> 0x4004 <+2>: addb %al, (%rdx)
# CHECK-NEXT: 0x4006 <+4>: addb %al, (%rbx)
# CHECK-NEXT: 0x4008 <+6>: addb %al, (%rsi)
# CHECK-NEXT: (lldb) disassemble --count 7
# CHECK-NEXT: command-disassemble-process.exe`main:
# CHECK-NEXT: 0x4002 <+0>: addb %al, (%rcx)
# CHECK-NEXT: 0x4002 <+0>: jmp 0x4004 ; <+2>
# CHECK-NEXT: -> 0x4004 <+2>: addb %al, (%rdx)
# CHECK-NEXT: 0x4006 <+4>: addb %al, (%rbx)
# CHECK-NEXT: 0x4008 <+6>: addb %al, (%rsi)
Expand Down Expand Up @@ -81,32 +81,32 @@ Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x0000000000004000
Address: 0x0000000000000000
AddressAlign: 0x0000000000001000
Content: 00000001000200030006000700080009000A000B000E000F00100011001200130016001700180019001A001B001E001F00200021002200230026002700280029002A002B002E002F
Content: 0000EB00000200030006000700080009000A000B000E000F00100011001200130016001700180019001A001B001E001F00200021002200230026002700280029002A002B002E002F
Size: 0x10000
- Name: .note.gnu.build-id
Type: SHT_NOTE
Flags: [ SHF_ALLOC ]
Address: 0x0000000000005000
Address: 0x0000000000001000
AddressAlign: 0x0000000000001000
Content: 040000000800000003000000474E5500DEADBEEFBAADF00D
Symbols:
- Name: main
Type: STT_FUNC
Section: .text
Value: 0x0000000000004002
Value: 0x0000000000000002
Size: [[MAIN_SIZE]]
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x4000
VAddr: 0x0000
Align: 0x1000
FirstSec: .text
LastSec: .text
- Type: PT_LOAD
Flags: [ PF_W, PF_R ]
VAddr: 0x5000
VAddr: 0x1000
Align: 0x1000
FirstSec: .note.gnu.build-id
LastSec: .note.gnu.build-id
Expand Down
10 changes: 5 additions & 5 deletions lldb/test/Shell/Commands/command-disassemble.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# CHECK-NEXT: error: Cannot disassemble around the current PC without a selected frame: no currently running process.
# CHECK-NEXT: (lldb) disassemble --start-address 0x0
# CHECK-NEXT: command-disassemble.s.tmp`foo:
# CHECK-NEXT: command-disassemble.s.tmp[0x0] <+0>: int $0x10
# CHECK-NEXT: command-disassemble.s.tmp[0x0] <+0>: jmp 0x2 ; <+2>
# CHECK-NEXT: command-disassemble.s.tmp[0x2] <+2>: int $0x11
# CHECK-NEXT: command-disassemble.s.tmp[0x4] <+4>: int $0x12
# CHECK-NEXT: command-disassemble.s.tmp[0x6] <+6>: int $0x13
Expand All @@ -41,7 +41,7 @@
# CHECK-NEXT: error: End address before start address.
# CHECK-NEXT: (lldb) disassemble --address 0x0
# CHECK-NEXT: command-disassemble.s.tmp`foo:
# CHECK-NEXT: command-disassemble.s.tmp[0x0] <+0>: int $0x10
# CHECK-NEXT: command-disassemble.s.tmp[0x0] <+0>: jmp 0x2 ; <+2>
# CHECK-NEXT: command-disassemble.s.tmp[0x2] <+2>: int $0x11
# CHECK-NEXT: command-disassemble.s.tmp[0x4] <+4>: int $0x12
# CHECK-NEXT: command-disassemble.s.tmp[0x6] <+6>: int $0x13
Expand All @@ -63,7 +63,7 @@
# CHECK: command-disassemble.s.tmp[0x203e] <+8190>: int $0x2a
# CHECK-NEXT: (lldb) disassemble --start-address 0x0 --count 7
# CHECK-NEXT: command-disassemble.s.tmp`foo:
# CHECK-NEXT: command-disassemble.s.tmp[0x0] <+0>: int $0x10
# CHECK-NEXT: command-disassemble.s.tmp[0x0] <+0>: jmp 0x2 ; <+2>
# CHECK-NEXT: command-disassemble.s.tmp[0x2] <+2>: int $0x11
# CHECK-NEXT: command-disassemble.s.tmp[0x4] <+4>: int $0x12
# CHECK-NEXT: command-disassemble.s.tmp[0x6] <+6>: int $0x13
Expand Down Expand Up @@ -101,8 +101,8 @@

.text
foo:
int $0x10
int $0x11
jmp 1f
1: int $0x11
int $0x12
int $0x13
int $0x14
Expand Down
Loading