OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 29, 2024 4:33 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [Help] Debugging UEFI application with GDB in VS Code?
PostPosted: Thu Jun 08, 2023 12:38 pm 
Offline

Joined: Thu Jun 08, 2023 12:32 pm
Posts: 1
I'm making a basic UEFI bootloader (filename: BootX64.efi), which loads a ELF64 kernel, both written in C on Arch Linux x86_64 and built with clang and lld. I am testing it with qemu-system-x86_64 with [ur=https://archlinux.org/packages/extra/any/edk2-ovmfl]OVMF[/url] as firmware. You can find the source code, along with a Makefile, here: https://github.com/CousinOfThor/uefi-elf. I would like to debug it in VS Code with GDB, but I am not able to do so: I run QEMU with the flags -gdb tcp::1234 -S, as you can see in the Makefile, and I am able to connect to it running gdb BootX64.efi, then, inside GDB, I run target remote localhost:1234, and I can continue the execution. Now, onto VS Code: the best I was able to come up with is this launch.json configuration:

Code:
{
     "version": "0.2.0",
     "configurations": [
         {
             "name": "Attach",
             "type": "gdb",
             "request": "attach",
             "executable": "./BootX64.efi",
             "target": "localhost:1234",
             "cwd": "${workspaceRoot}",
             "remote": true,
          }   
      ]
}


I can connect to QEMU, because I see it start running the bootloader as soon as I press F5 to start debugging, but I can't step through the code. I enabled the debug info on clang with the option -ggdb, both for the bootloader and the kernel, but GDB says it can not read the BootX64.pdb produced by clang while compiling the bootloader, nor I can step through the code of the ELF64 kernel.

How is it possible to do this? Any help is appreciated, thanks.


Top
 Profile  
 
 Post subject: Re: [Help] Debugging UEFI application with GDB in VS Code?
PostPosted: Thu Jun 15, 2023 12:12 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
This question was asked and answered elsewhere. (In short: use LLDB instead, because it recognizes the PDB file.)


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: FrankRay78 and 19 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