Skip to content

kgdb: allow forcing kgdb mode when using agent-proxy #144

@xairy

Description

@xairy

I'm trying to use gef to debug the Android kernel on a Pixel device via KGDB over serial. Pixel devices expose a single UART port that can be used for both displaying the kernel log and for communication between GDB and the KGDB module in the kernel.

To allow using the same port for both purposes, I rely on the agent-proxy tool. agent-proxy splits a single communication channel over a serial device into two TCP communication channels. Thus, when running agent-proxy 5550^5551 0 /dev/ttyUSB0,115200, I can get the kernel log via nc 127.0.0.1 5550 and then also connect GDB via target remote 127.0.0.1:5551.

The problem I'm facing is that gef's check for the kgdb mode (done via is_kgdb() + is_over_serial()) expects the selected_inferior() to be a /dev/tty* device. Which is not technically the case here: I'm running target remote in GDB, it's the agent-proxy that is connected to the serial device.

I suspect it would be quite hard to automatically differentiate between a generic remote connection and a connection specifically to agent-proxy.

So instead, it would be great if there was at least some way to just force the kgdb mode. Perhaps, via a gef set-mode kgdb command or something like that (and gef status could also display is_kgdb() -> True (forced) to make the forcing apparent).

On a side note, is_over_serial() could also be changed to allow /dev/ttyUSB* serial devices.

And is_kgdb() could also be change to allow arm64, but this could be done later (I managed to get quite a few gef commands working with an arm64 kernel in kgdb mode, but this required a few more gef changes; I'll file separate issues/PRs for these at some point).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions