Re: Using ubuntu24.4 system qemu-system-aarch64 +gdb-multiarch to debug the kernel, setting breakpoints cannot be stopped

jie ren <[email protected]>
Newsgroups gmane.comp.emulators.qemu,gmane.comp.gdb.devel,gmane.comp.emulators.qemu.user
Message-ID <CAAsTPeZLGopejmcGHKgFciRhO-Aa2sjesryjNUTy0gq_5sEpdA@mail.gmail.com>
Thank you very much. Adding kaslr successfully solved the problem.

Ilya Leoshkevich <[email protected]> 于2024年9月24日周二 00:34写道:

> On Mon, 2024-09-23 at 22:36 +0800, jie ren wrote:
> > Hi, I have a question for help
> >     I recently  Using ubuntu24.4 system qemu-system-aarch64 +gdb-
> > multiarch to debug the kernel, setting breakpoints cannot be stopped.
> >    system information:
> >         ubuntu version: 22.04
> >         Debug kernel version:  5.0.0
> >         qemu version:
> > · qemu-system-aarch64 --version
> > · QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.2)
> > · Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project
> > developers
> >
> >
> >
> > gdb version:
> > · gdb-multiarch --version
> > · GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
> > · Copyright (C) 2024 Free Software Foundation, Inc.
> > · License GPLv3+: GNU GPL version 3 or later
> > <http://gnu.org/licenses/gpl.html>
> > · This is free software: you are free to change and redistribute it.
> > · There is NO WARRANTY, to the extent permitted by law.
> >
> > Steps to reproduce:
> >     1. Boot the system using qemu:
> > 1. qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine
> > type=virt -m 1024 -smp 4 -kernel arch/arm64/boot/Image --append
> > "noinitrd root=/dev/vda rw console=ttyAMA0 loglevel=8" -nographic -
> > drive if=none,file=rootfs_ext4.img,id=hd0 -device virtio-blk-
> > device,drive=hd0 --fsdev
> > local,id=kmod_dev,path=$PWD/kmodules,security_model=none -device
> > virtio-9p-device,fsdev=kmod_dev,mount_tag=kmod_mount -S -s
> >
> >
> > Use gdb-multiarch to connect and debug:
> >
> >
> > gdb-multiarch vmlinux
> > (gdb) target remote localhost:1234
> > Remote debugging using localhost:1234
> > 0x0000000040000000 in ?? ()
> > (gdb) b start_kernel
> > Breakpoint 1 at 0xffff2000126704ec: file init/main.c, line 538.
> > (gdb) c
> > Continuing.
>
> I would try using the "nokaslr" kernel option:
>
> $ qemu-system-aarch64 -kernel ./Image.custom -M virt -cpu cortex-a57 -
> append "console=ttyAMA0 nokaslr" -s -S -nographic
>
> $ gdb-multiarch -ex 'target remote :1234' vmlinux
>
> Remote debugging using :1234
> 0x0000000040000000 in ?? ()
> (gdb) b start_kernel
> Breakpoint 1 at 0xffff8000811e0968: file init/main.c, line 905.
> (gdb) c
> Continuing.
>
> Breakpoint 1, start_kernel () at init/main.c:905
> 905             char *command_line;
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.