Page MenuHomePhabricator

Make the aarch64 lldb-server capable of debugging arm32 applications

Authored by tberghammer on Dec 15 2015, 8:52 AM.



Make the aarch64 lldb-server capable of debugging arm32 applications

After this change an arm32 lldb-server can debug arm32 inferiors both on arm32 and on aarch64 devices and an aarch64 lldb-server can debug both arm32 and aarch64 inferiors on aarch64 devices.

Diff Detail


Event Timeline

tberghammer retitled this revision from to Make the aarch64 lldb-server capable of debugging arm32 applications.
tberghammer updated this object.
tberghammer added reviewers: omjavaid, ovyalov.
tberghammer added a subscriber: lldb-commits.
ovyalov accepted this revision.Dec 15 2015, 2:10 PM
ovyalov edited edge metadata.
ovyalov added inline comments.
973 ↗(On Diff #42862)


1016 ↗(On Diff #42862)

Could you wrap aarch64 code into a static function in NativeRegisterContextLinux_arm64 so it can be reused both here and in NativeRegisterContextLinux_arm64::DoReadGPR?

1018 ↗(On Diff #42862)

It seems, error isn't used.

153 ↗(On Diff #42862)

Please add logging here including target_arch.GetMachine() value.

This revision is now accepted and ready to land.Dec 15 2015, 2:10 PM
tberghammer edited edge metadata.
tberghammer marked 2 inline comments as done.

Note: This change is blocked by D15529. If that one will get rejected then we have to move some of the 32 <-> 64 architecture matching code into LLDB.

1016 ↗(On Diff #42862)

I don't want to call NativeRegisterContextLinux_arm64::DoReadGPR because conceptually a function on NativeRegisterContextLinux_arm64 should read out arm64 resisters while this one reads out arm32 registers. I changed to code to use NativeRegisterContextLinux::ReadRegisterSet what simplifies it quite a bit.

tberghammer marked an inline comment as done.Dec 16 2015, 4:16 AM
omjavaid edited edge metadata.Dec 16 2015, 11:08 PM

I am wondering whats the reason of replacing arm ptrace calls with aarch64 specific calls that use iovec parameters.

If arm calls can work then may be dont use aarch64 specific calls at all. If they dont work kindly make relevant changes to NativeRegisterContextLinux_arm::WriteHardwareDebugRegs and NativeRegisterContextLinux_arm::ReadHardwareDebugInfo().
I guess these functions will throw same errors in case calls propagated using aarch64 lib interface and not backward compaitible with arm specific interface.

I don't fully understand how the ptrace API works in the aarch64 Linux kernel but based on my experiments the arm specific ptrace calls aren't working (returning -EIO for a reason unknown to me at the moment). Because of this, the current watchpoint implementation ins't working when aarch64 lldb-server is debugging an arm32 inferior. I also tried to change the implementation to use ReadRegisterSet(NT_ARM_HW_WATCH) but it wasn't working either most likely because NT_ARM_HW_WATCH isn't listed as a register set in

I will keep investigating how can we set arm watchpoints from an aarch64 kernel but I would appreciate any suggestion if you have one.

@omjavaid: What is your opinion about submitting this patch in its current form with knowing that setting watchpoints from a 64bit lldb-server into 32bit inferior will fail?

I think this patch is a step in the good direction to make a 64bit lldb-server capable of debugging a 32bit inferior. Considering how few arm/aarch64 (android) devices are supporting watchpoints I don't think we should block on that issue.


I think we should submit this patch as tberghammer explained.

This revision was automatically updated to reflect the committed changes.