2010-02-22 14:40:31

by Hui Zhu

[permalink] [raw]
Subject: [PATCH 0/2] markup_oops.pl and GDB: Let GDB can handle kernel oops stack message

Hi,

I make a patch in http://lkml.org/lkml/2010/1/3/28 to let kernel show
special stack message and convert it to core file when kernel die.
But it need change too much part and other thing make a lot of people
didn't like it.

So I make a patch for markup_oops.pl to make it can convert the oops
message to GDB command.
And make a patch for GDB to add a new target empty which level is same
with corelow target. It can save the memory and reg operation command's
value and send it to GDB as the inferior's value. Then GDB can parse the
oops message directly.

The oops didn't show all the stack message, because it just show
"kstack_depth_to_print" values. To show all the stack value, you need
add kernel commandline "kstack=4096". Because this part have check:
if (kstack_end(stack))
break;
So set kstack_depth_to_print to big number will not affect anything.

For example:
Add "kstack=4096" to kernel commandline. Get the oops message and save
it to a file.

cat ~/tmp/amd64 | perl ./scripts/markup_oops.pl -g -c x86_64- -m
~/tmp/e.ko ~/tmp/vmlinux > ./gc
This line parse the oops message from ~/tmp/amd64 to file ./gc.

gdb -x ./gc
add symbol table from file
"../common_pc_64.glibc_std.standard/export/dist/e.ko" at
.text_addr = 0xffffffffa001b000
#0 init_module () at /home/teawater/study/kernel/stack2core/example/e.c:10
10 buf[0] = 3;
(gdb) bt
#0 init_module () at /home/teawater/study/kernel/stack2core/example/e.c:10
#1 0xffffffff8020903b in do_one_initcall (fn=0xffffffffa001b000
<init_module>)
at
/home/teawater/kernel/common_pc_64.glibc_std.standard/build/linux/init/main.c:737
#2 0xffffffff80261e55 in sys_init_module (umod=0x6905b0, len=50382,
uargs=<value optimized out>)
at
/home/teawater/kernel/common_pc_64.glibc_std.standard/build/linux/kernel/module.c:2385
#3 0xffffffff8020bb0b in ?? ()
at
/home/teawater/kernel/common_pc_64.glibc_std.standard/build/linux/arch/x86/kernel/entry_64.S:359
(gdb) frame 3
#3 0xffffffff8020bb0b in ?? ()
at
/home/teawater/kernel/common_pc_64.glibc_std.standard/build/linux/arch/x86/kernel/entry_64.S:359
359 call *sys_call_table(,%rax,8) # XXX: rip relative
(gdb) frame 2
#2 0xffffffff80261e55 in sys_init_module (umod=0x6905b0, len=50382,
uargs=<value optimized out>)
at
/home/teawater/kernel/common_pc_64.glibc_std.standard/build/linux/kernel/module.c:2385
2385 ret = do_one_initcall(mod->init);
(gdb) list
2380 blocking_notifier_call_chain(&module_notify_list,
2381 MODULE_STATE_COMING, mod);
2382
2383 /* Start the module */
2384 if (mod->init != NULL)
2385 ret = do_one_initcall(mod->init);
2386 if (ret < 0) {
2387 /* Init routine failed: abort. Try to protect us from
2388 buggy refcounters. */
2389 mod->state = MODULE_STATE_GOING;
(gdb) p mod
$1 = (struct module *) 0xffffffffa001b340

Thanks,
Hui


2010-02-24 21:16:21

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 0/2] markup_oops.pl and GDB: Let GDB can handle kernel oops stack message

On Mon, 22 Feb 2010 22:40:16 +0800 Hui Zhu <[email protected]> wrote:

> So I make a patch for markup_oops.pl to make it can convert the oops
> message to GDB command.
> And make a patch for GDB to add a new target empty which level is same
> with corelow target. It can save the memory and reg operation command's
> value and send it to GDB as the inferior's value. Then GDB can parse the
> oops message directly.

How useful is the kernel patch when one is using an unpatched gdb?

2010-02-25 06:10:46

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH 0/2] markup_oops.pl and GDB: Let GDB can handle kernel oops stack message

On Thu, Feb 25, 2010 at 05:15, Andrew Morton <[email protected]> wrote:
> On Mon, 22 Feb 2010 22:40:16 +0800 Hui Zhu <[email protected]> wrote:
>
>> So I make a patch for markup_oops.pl to make it can convert the oops
>> message to GDB command.
>> And make a patch for GDB to add a new target empty which level is same
>> with corelow target. It can save the memory and reg operation command's
>> value and send it to GDB as the inferior's value. Then GDB can parse the
>> oops message directly.
>
> How useful is the kernel patch when one is using an unpatched gdb?
>

For that status, I have 2 ways to handle it:
1. Change the "target empty" to other target, like "target remote
localhost:1234".
Then the remote target displace the empty target. It can be use.

2. In http://lkml.org/lkml/2010/1/3/28, there is a program called
s2c, it can convert some special message to a core file. Then gdb can
parse core file.
If you think we need it, I can make it input the gdb commands.

Thanks,
Hui