-
Notifications
You must be signed in to change notification settings - Fork 61
Description
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).