Page MenuHomePhabricator

lldb - problem with some PTRACE_* constants in NativeProcessLinux.cpp file
ClosedPublic

Authored by pawelo on Jul 2 2014, 1:46 PM.

Details

Reviewers
tfiala
Summary

Today this is the only problem that I'm facing trying to cross-compile lldb for AArch64 using Linaro's toolchain.

  • PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS, PTRACE_SETFPREGS are not defined for AArch64
  • These things can be defined different ways for other architectures, e.g. for x86_64 Linux, asm/ptrace-abi.h defines them as preprocessor constants while sys/ptrace.h defines them in enum along with corresponding PT_* preprocessor constants
  • NativeProcessLinux.cpp includes sys/ptrace.h
  • To avoid accidental redefinition of enums with preprocessor constants, I'm proposing this patch which first checks for PT_* preprocessor constants then checks for PTRACE_* constants then when it still can not find them, it defines preprocessor constants.
  • Similar approach was already used for PTRACE_GETREGSET and PTRACE_SETREGSET constants; in this case however it was easier, since enum values in sys/ptrace.h and preprocessor constants shared all exactly the same names (e.g. there's no additional PT_GETREGSET name defined).

Diff Detail

Event Timeline

pawelo updated this revision to Diff 11033.Jul 2 2014, 1:46 PM
pawelo retitled this revision from to lldb - problem with some PTRACE_* constants in NativeProcessLinux.cpp file.
pawelo updated this object.
pawelo edited the test plan for this revision. (Show Details)
pawelo set the repository for this revision to rL LLVM.
pawelo added a subscriber: Unknown Object (MLST).
tfiala added a reviewer: tfiala.EditedJul 2 2014, 2:31 PM
tfiala added a subscriber: tfiala.

Initially I was going to adjust the patch to pull out the PTRACE_* #if checks entirely (and just leave the #if PT_* checks), but I'll leave them in for now based on this:

These things can be defined different ways for other architectures, e.g. for x86_64 Linux, asm/ptrace-abi.h defines them as preprocessor constants while sys/ptrace.h defines them in enum along with corresponding PT_* preprocessor constants

I'll have a deeper look at this after I get it running on a cross compiler and x86/x86_64/ARM/ARM64. We may want to go ahead and just define these using known-to-be-correct values for the target but define them ourselves with non-colliding LLDB constants (for example, see the UnixSignals* hierarchy, which defines the values directly rather than pulling in system header values that are only correct for the compiler host or cross-compiler headers).

tfiala accepted this revision.Jul 2 2014, 2:39 PM
tfiala edited edge metadata.

LGTM. Tests pass on Linux x86_64. MacOSX builds.

This revision is now accepted and ready to land.Jul 2 2014, 2:39 PM
tfiala closed this revision.Jul 2 2014, 2:42 PM

svn commit
Sending source/Plugins/Process/Linux/NativeProcessLinux.cpp
Transmitting file data .
Committed revision 212225.