This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC 3/7] Add basic Linux kernel support
- From: Philipp Rudo <prudo at linux dot vnet dot ibm dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: gdb-patches at sourceware dot org, peter dot griffin at linaro dot org, yao dot qi at arm dot com, arnez at linux dot vnet dot ibm dot com
- Date: Thu, 9 Feb 2017 16:08:51 +0100
- Subject: Re: [RFC 3/7] Add basic Linux kernel support
- Authentication-results: sourceware.org; auth=none
- References: <20170112113217.48852-1-prudo@linux.vnet.ibm.com> <20170112113217.48852-4-prudo@linux.vnet.ibm.com> <20170207105403.GA1630@E107787-LIN> <86wpczo6o9.fsf@gmail.com>
Hi Yao
wow. Thats wonderful. Now we know we can go this way for testing.
One minor thing I noticed in your code (which is actually my mistake)
> struct mm_struct
> {};
>
> struct mm_struct init_mm;
You don't need those two when you are only interested in thread
handling. The mm_struct and init_mm are needed for address translation
and actually belong in the commit with module handling ...
Fixed it for v3.
Thanks a lot
Philipp
On Thu, 09 Feb 2017 13:05:58 +0000
Yao Qi <qiyaoltc@gmail.com> wrote:
> Yao Qi <qiyaoltc@gmail.com> writes:
>
> > I am playing your first three patches on x86_64 with some hacks.
> > I write a small program with the same linux kernel "signature", and
> > want GDB treat it as a linux kernel.
> >
>
> I make some progress on writing such small test case,
> see the code below. I hacked lk_try_push_target not to do the
> sanity check, and not to call lk_try_push_target in
> lk_observer_inferior_created, so that I can push this target layer
> when I want.
>
> (gdb) break stop^M
> Breakpoint 2 at 0x400711:
> file /home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.base/linux-kernel.c,
> line 104.^M (gdb) continue^M Continuing.^M
> ^M
> Breakpoint 2, stop ()
> at /home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.base/linux-kernel.c:104^M
> 104 {}^M (gdb) PASS: gdb.base/linux-kernel.exp: continue to
> breakpoint: stop
>
> at this point, the list of tasks are set up, switch to linux-kernel
> target layer,
>
> target linux-kernel^M
> [New process 8001]^M
> (gdb) PASS: gdb.base/linux-kernel.exp: target linux-kernel
> maintenance print target-stack^M
> The current target stack is:^M
> - linux-kernel (linux kernel support)^M
> - native (Native process)^M
> - exec (Local exec file)^M
> - None (None)^M
>
> It works! In this way, we can test that GDB can successfully parse
> the these data structures in Linux kernel without Linux kernel image
> at all.
>
> Then, we can generate a coredump,
>
> (gdb) generate-core-file
> Saved corefile core.9614
>
> Remove the hack in lk_observer_inferior_created, so that GDB can
> automatically push linux-kernel target layer,
>
> $ ./gdb ./testsuite/outputs/gdb.base/linux-kernel/linux-kernel ./core.9614
> [New LWP 9614]
> [New process 9614]
> Core was generated by
> `/scratch/yao/gdb/build-git/x86_64/gdb/testsuite/outputs/gdb.base/linux-kernel/li'.
> Program terminated with signal SIGTRAP, Trace/breakpoint trap. #0
> stop ()
> at /home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.base/linux-kernel.c:104
> 104 {} [Current thread is 1 (PID: 9614*, 0x602010)] (gdb)
> maintenance print target-stack The current target stack is:
> - linux-kernel (linux kernel support)
> - core (Local core dump file)
> - exec (Local exec file)
> - None (None)
>
> The next step would be extending the test case to a multi-threaded
> program, so that we can create task lists for these threads, and
> generate coredump which is similar to the kernel coredump.
>