OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:54 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: How do you debug the Intel assembly?
PostPosted: Sun Oct 03, 2021 1:26 pm 
Offline

Joined: Sat Oct 02, 2021 10:28 pm
Posts: 11
Hello, everyone. I am an OS development beginner. Debugging is a very useful approach to help us find mistakes. I know how to debug the C language in the kernel. But kernel not only includes C language but also including a lot of assembly language. The interesting things are I can use the gdb to debug the C language parts of the kernel, instead of assembly. When I put the breakpoint in assembly, the gdb wouldn't go there, so that I can't see any debug information in it. I make sure I added the -g option in nasm and GCC. The more detail you can see in my makefile. My OS project is https://github.com/xubenji/DolphinOS.
You can download the project and enter the DolphinOS directory to run it.
Running this project in qemu with debug model is:
root@benji:~/make s
Then open gdb, make sure attached the symbol file: kelf.
: symbol-file kelf
You end up connecting to the qemu with this instruction:
target remote localhost:1234
When you set the breakpoint in handler_ASM.asm, io_ASM.asm and switch_ASM.asm, you will find that the gdb wouldn't go to those files. It is pretty strange. Do you know how to solve this problem? I appreciate you very much.


Top
 Profile  
 
 Post subject: Re: How do you debug the Intel assembly?
PostPosted: Sun Oct 03, 2021 3:28 pm 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
Try using Bochs. It has an amazing integrated ASM debugger. Note that AFAIK Bochs can't display symbol information (although you might be able to load one in, I'm not sure), but it still is great.

Try looking at the Bochs wiki page.

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: How do you debug the Intel assembly?
PostPosted: Sun Oct 03, 2021 6:54 pm 
Offline

Joined: Sat Oct 02, 2021 10:28 pm
Posts: 11
nexos wrote:
Try using Bochs. It has an amazing integrated ASM debugger. Note that AFAIK Bochs can't display symbol information (although you might be able to load one in, I'm not sure), but it still is great.

Try looking at the Bochs wiki page.

Thanks for your response. Now I use the VScode to conduct the gdb running in the Linux server. Building this framework would take me a long time. Do you know how the Bochs and gdb co-work with each other? Do you know how to set the Bochs and gdb?


Top
 Profile  
 
 Post subject: Re: How do you debug the Intel assembly?
PostPosted: Mon Oct 04, 2021 2:01 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
You can set breakpoints at individual addresses in gdb with the command
Code:
break *0x1234
.


Top
 Profile  
 
 Post subject: Re: How do you debug the Intel assembly?
PostPosted: Mon Oct 04, 2021 10:15 am 
Offline

Joined: Sat Oct 02, 2021 10:28 pm
Posts: 11
iansjack wrote:
You can set breakpoints at individual addresses in gdb with the command
Code:
break *0x1234
.

Yes, but the problem is that I don’t know the address. Hahahahaha


Top
 Profile  
 
 Post subject: Re: How do you debug the Intel assembly?
PostPosted: Mon Oct 04, 2021 10:22 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Then produce a linker map file. Or use objdump to inspect your executable.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot] and 53 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group