Re: mode processor mode switch

Pedro Alves <[email protected]> Thu, 16 Jan 2020 18:52:15 +0000
Newsgroups gmane.comp.gdb.devel,gmane.comp.gdb.general
Message-ID <[email protected]>
On 1/16/20 2:51 PM, Luis Machado wrote:
> Hi,
>=20
> On 1/14/20 8:58 AM, Jirka Koutn=C3=BD 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.
>>
>> Thank you
>> Jirka
>>
>=20
> Unfortunately i don't think there is a good way to achieve this with the =
current implementation.
>=20
> You could teach GDB about the quirks in the architecture, but it sounds b=
etter to have a more general solution.
>=20
> I'm working on making this more flexible though, since i have a need to m=
ake the architecture information per-thread, at least the target descriptio=
n with the registers and types.
>=20

For x86-64 in particular, I think the ideal solution would be for
the remote target to always report the widest mode it supports,
which would be 64-bit, and then do the 32-bit/16-bit modes
presentation all on the gdb side (i.e., user-visible 32-bit on
top of 64-bit description).  Mode switching would not change the remote
target description.  This is unlike the current architecture where a
remote server reports a 32-bit description for a 32-bit process even
if the remote server is actually running on a 64-bit machine.

Thanks,
Pedro Alves