mode processor mode switch

Ruslan Kabatsayev
Wed Jan 15 21:51:00 GMT 2020

Hello Jirka,

On Tue, 14 Jan 2020 at 14:59, Jirka Koutný <> wrote:
> Hello,
> I have a 32-bit elf executable which at some point switches to long mode
> (kernel is 64-bit). Is there a way to tell gdb about the .code32/64
> directives? Because expectedly the switch messes up disassembly and
> stepping.

Actually this shouldn't mess up stepping (at least `stepi` command):
on x86 and compatibles it's done via the TF bit in EFLAGS, which
causes trap on single instruction execution happen by hardware means.
But yes, disassembly and `nexti` are messed up indeed.

There's that command "set architecture", that I'd suppose should
manage this, but so far I've been unable to convince GDB to switch to
i386:x86-64 or any other related option when running a 32-bit binary.
And this command is poorly documented, so I'm not sure how exactly it
works and whether it's supposed to affect disassembly.

So, bottom line: it seems there's no such functionality in current GDB.

Meanwhile, you might want to try another debugger, EDB (which is
GUI-based though, and only works well on Linux), which was written to
explicitly support such unusual behavior of debuggees by checking the
value of the CS register at each trap (this part was implemented by

> Thank you
> Jirka


More information about the Gdb mailing list