[RFC,1/3] config: provide a fragment to enable gdb for qemu

Message ID 20181213122910.24193-2-anders.roxell@linaro.org
State New
Headers show
Series
  • Make allmodconfig boot in qemu-arm64
Related show

Commit Message

Anders Roxell Dec. 13, 2018, 12:29 p.m.
Adding a fragment to make it easier to know what options is needed to
build a kernel to get the that you can debug in qemu.

First you need to start qemu with flags '-s -S' and then connect with
gdb like below:
$ gdb \
 ./obj-dir/vmlinux -iex 'add-auto-load-safe-path \
 ./obj-dir' -ex 'target remote localhost:1234'

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>

---
 kernel/configs/qemu-gdb.config | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 kernel/configs/qemu-gdb.config

-- 
2.19.2

Comments

Mark Brown Dec. 13, 2018, 12:40 p.m. | #1
On Thu, Dec 13, 2018 at 01:29:08PM +0100, Anders Roxell wrote:
> Adding a fragment to make it easier to know what options is needed to

> build a kernel to get the that you can debug in qemu.


> @@ -0,0 +1,7 @@

> +# Enable debug info for gdb

> +# CONFIG_COMPILE_TEST is not set

> +CONFIG_DEBUG_INFO=y

> +CONFIG_GDB_SCRIPTS=y


Is this specifically for qemu or is this just good for debugging with
GDB in general (eg, via JTAG)?
Anders Roxell Dec. 18, 2018, 8:45 a.m. | #2
On Thu, 13 Dec 2018 at 13:40, Mark Brown <broonie@kernel.org> wrote:
>

> On Thu, Dec 13, 2018 at 01:29:08PM +0100, Anders Roxell wrote:

> > Adding a fragment to make it easier to know what options is needed to

> > build a kernel to get the that you can debug in qemu.

>

> > @@ -0,0 +1,7 @@

> > +# Enable debug info for gdb

> > +# CONFIG_COMPILE_TEST is not set

> > +CONFIG_DEBUG_INFO=y

> > +CONFIG_GDB_SCRIPTS=y

>

> Is this specifically for qemu or is this just good for debugging with

> GDB in general (eg, via JTAG)?


I haven't tried, and I don't have a JTAG so I could test it =/

Cheers,
Anders
Arnd Bergmann Dec. 18, 2018, 9:07 a.m. | #3
On Tue, Dec 18, 2018 at 9:45 AM Anders Roxell <anders.roxell@linaro.org> wrote:
>

> On Thu, 13 Dec 2018 at 13:40, Mark Brown <broonie@kernel.org> wrote:

> >

> > On Thu, Dec 13, 2018 at 01:29:08PM +0100, Anders Roxell wrote:

> > > Adding a fragment to make it easier to know what options is needed to

> > > build a kernel to get the that you can debug in qemu.

> >

> > > @@ -0,0 +1,7 @@

> > > +# Enable debug info for gdb

> > > +# CONFIG_COMPILE_TEST is not set

> > > +CONFIG_DEBUG_INFO=y

> > > +CONFIG_GDB_SCRIPTS=y

> >

> > Is this specifically for qemu or is this just good for debugging with

> > GDB in general (eg, via JTAG)?

>

> I haven't tried, and I don't have a JTAG so I could test it =/


The DEBUG_INFO=y and (as a dependency for that) CONFIG_COMPILE_TEST
are definitely needed for all GDB operation. I would assume that
the scripts also work with any other gdb environment, but haven't tried either.

For CONFIG_RANDOMIZE_BASE, I'm not actually sure if that helps or
not. I think I originally suggested to Anders to turn that off when he
was analyzing a bug, but I don't know if it helped or if it works just
as well without that.

        Arnd
Mark Brown Dec. 18, 2018, 1:29 p.m. | #4
On Tue, Dec 18, 2018 at 10:07:21AM +0100, Arnd Bergmann wrote:
> On Tue, Dec 18, 2018 at 9:45 AM Anders Roxell <anders.roxell@linaro.org> wrote:

> > On Thu, 13 Dec 2018 at 13:40, Mark Brown <broonie@kernel.org> wrote:


> > > Is this specifically for qemu or is this just good for debugging with

> > > GDB in general (eg, via JTAG)?


> > I haven't tried, and I don't have a JTAG so I could test it =/


> The DEBUG_INFO=y and (as a dependency for that) CONFIG_COMPILE_TEST

> are definitely needed for all GDB operation. I would assume that

> the scripts also work with any other gdb environment, but haven't tried either.


I'm fairly sure the requirements are identical, though it has been quite
some time since I tried and I don't have relevant hardware any more so
can't confirm.

> For CONFIG_RANDOMIZE_BASE, I'm not actually sure if that helps or

> not. I think I originally suggested to Anders to turn that off when he

> was analyzing a bug, but I don't know if it helped or if it works just

> as well without that.


Yeah, I'd think it'd be helpful to turn that off.

Patch

diff --git a/kernel/configs/qemu-gdb.config b/kernel/configs/qemu-gdb.config
new file mode 100644
index 000000000000..30465905ff93
--- /dev/null
+++ b/kernel/configs/qemu-gdb.config
@@ -0,0 +1,7 @@ 
+# Enable debug info for gdb
+# CONFIG_COMPILE_TEST is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_GDB_SCRIPTS=y
+
+# Easier to debug
+# CONFIG_RANDOMIZE_BASE is not set