Skip to content

powerpc-darwin does not have ppc_debug_state (unlike i386/arm): is anything suitable as a fallback? #25234

@barracuda156

Description

@barracuda156

@trufae This is a follow-up to #25144

It is desirable to replace a hack which was used earlier to make radare2 compile on powerpc with a proper fix, adding implementation for it. PowerPC has most of the stuff which is used in xnu_threads. However, it does not have ppc_debug_state_t, apparently.
The code uses *_debug state for i386 and arm here:

#if __arm64 || __aarch64 || __arm64__ || __aarch64__ || __arm64e__
union {
arm_debug_state32_t drx32;
arm_debug_state64_t drx64;
} debug;
#elif __arm__ || __arm || __armv7__
union {
arm_debug_state_t drx;
} debug;
#elif __x86_64__ || __i386__
x86_debug_state_t drx;
#endif

Corresponding .c file has commented out chunk with it:
#elif __POWERPC__
/* not supported */
# ifndef PPC_DEBUG_STATE32
# define PPC_DEBUG_STATE32 1
# endif
//ppc_debug_state_t *regs;
//thread->flavor = PPC_DEBUG_STATE32;
//thread->count = R_MIN (thread->count, sizeof (regs->uds.ds32));
return false;
#else

However that won’t really work in that form, AFAICT.

Compare:
i386 has debug_state: https://github.com/alexey-lysiuk/macos-sdk/blob/78bd32056afc9a4720580f82d4ac839e7e831b6e/MacOSX10.6.sdk/usr/include/mach/i386/thread_status.h#L109-L111
powerpc does not: https://github.com/alexey-lysiuk/macos-sdk/blob/78bd32056afc9a4720580f82d4ac839e7e831b6e/MacOSX10.6.sdk/usr/include/mach/ppc/thread_status.h#L44-L50
Likewise, LLVM docs do not mention it for powerpc: https://llvm.org/doxygen/BinaryFormat_2MachO_8h_source.html

So the question is whether something can be done about that, using what exists on powerpc, or we are out of luck here, and just keep it disabled indefinitely?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions