Debugging an i386 userspace on an amd64 target

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ameame
Posts: 3
Joined: Mon Aug 12, 2019 7:48 pm

Debugging an i386 userspace on an amd64 target

Post by ameame »

I recently ported my x86 kernel to support x64 and I'm having a problem debugging applications in gdb+qemu. Before I would load the kernel into gdb, pause execution then load the userland application and execute it. Now because of architecture mixing gdb can't change the debug architecture to 32-bit and it can't backtrace or display local variables correctly.

Is there at least a better way to debug applications than this?
Last edited by ameame on Mon Aug 12, 2019 9:31 pm, edited 2 times in total.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Debugging an i386 userspace on an amd64 target

Post by MichaelPetch »

Are you the fellow who asked the core dump question on Stackoverflow recently?
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Debugging an i386 userspace on an amd64 target

Post by MichaelPetch »

If you ported your OS to 64-bit then why would it be running 32-bit code? Do you switch tom 32-bit compatibility mode to execute 32-bit userland (ring 3) code?
ameame
Posts: 3
Joined: Mon Aug 12, 2019 7:48 pm

Re: Debugging an i386 userspace on an amd64 target

Post by ameame »

MichaelPetch wrote:Are you the fellow who asked the core dump question on Stackoverflow recently?
Nah, never posted to stackoverflow before.
MichaelPetch wrote:If you ported your OS to 64-bit then why would it be running 32-bit code? Do you switch tom 32-bit compatibility mode to execute 32-bit userland code?
Oops, that was a mistake. I mean't ported my kernel to 64-bit. My processes run in compatibility mode.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Debugging an i386 userspace on an amd64 target

Post by MichaelPetch »

Sounds like you are running into this issue that started becoming a problem as of 2.9 of QEMU: https://bugs.launchpad.net/qemu/+bug/1686170 . Any chance you could build 2.8.1 of QEMU and try?
Last edited by MichaelPetch on Tue Aug 13, 2019 10:06 am, edited 1 time in total.
ameame
Posts: 3
Joined: Mon Aug 12, 2019 7:48 pm

Re: Debugging an i386 userspace on an amd64 target

Post by ameame »

MichaelPetch wrote:Sounds like you are running into this issue that started becoming an issue as of 2.9 of QEMU: https://bugs.launchpad.net/qemu/+bug/1686170 . Any chance you could build 2.8.1 of QEMU and try?
Thanks, it worked! I did have to do the disconnect trick and patch in some files so it's compatible with my glibc though.
Post Reply