SRobertJames
SRobertJames

Reputation: 9263

gdb script: How can a script determine if it is invoked under `gdb` or `gdb-multiarch`?

I'd like to define a command which does X under gdb-multiarch, but prints out a helpful message when run under normal gdb. How can my script determine which of the two its run under?

Why? When I start gdb-multiarch, I can bind to a qemu-arm session. When I try that in gdb, I get bizarre errors. It's easy to forget and run gdb (and not -multiarch), and I want to my bind-to-qemu tell me "This must be run under gdb-multiarch".

Upvotes: 0

Views: 216

Answers (1)

Employed Russian
Employed Russian

Reputation: 213955

Your question presumes that there is some difference between gdb and gdb-multiarch, but there doesn't have be any such difference.

Presumably on the OS you are using the gdb and gdb-multiarch are configured differently, with gdb only supporting native architecture, while gdb-multiarch supports cross-architecture debugging.

Presumably what you actually want to detect is that the target-architecture you need (arm ?) is / isn't supported by the current binary.

In the bind-to-qemu user-defined function, you can try to set architecture arm.

If that errors out, the rest of bind-to-qemu should not execute.

Upvotes: 2

Related Questions