Re: mode processor mode switch
Ruslan Kabatsayev <[email protected]> Thu, 16 Jan 2020 00:50:28 +0300
| Newsgroups | gmane.comp.gdb.devel,gmane.comp.gdb.general |
|---|---|
| Message-ID | <CAHEcG96Ff1bMkLuqOJzWgJPmnm_oagUgHN+RoXHFbmhsgSahfw@mail.gmail.com> |
Hello Jirka, On Tue, 14 Jan 2020 at 14:59, Jirka Koutn=C3=BD <[email protected]> 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 me). > > Thank you > Jirka Regards, Ruslan