All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cliff Wickman <cpw@sgi.com>
To: jidong xiao <jidong.xiao@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to generate a Kerntypes file?
Date: Fri, 23 Jan 2009 07:45:18 -0600	[thread overview]
Message-ID: <20090123134518.GA23513@sgi.com> (raw)
In-Reply-To: <4104961b0901222237h7fac5b1vf1b3b7f9d06d550c@mail.gmail.com>

On Fri, Jan 23, 2009 at 02:37:12PM +0800, jidong xiao wrote:
> On Thu, Jan 22, 2009 at 9:31 PM, Cliff Wickman <cpw@sgi.com> wrote:
> > Hi Jason,
> >
> > On Thu, Jan 22, 2009 at 06:59:34PM +0800, jidong xiao wrote:
> >> Hi,All,
> >>
> >> Sometimes when I install a kernel I saw there is a Kerntypes file
> >> installed under /boot directory, but sometimes no, I remember when I
> >> install a sles9 kernel, there must be a Kerntypes file installed, but
> >> most of other kernels doesn't include such a Kerntypes file. This file
> >> is very useful for me to do some analysis, so I hope I can generate it
> >> every time I build a kernel. Do I need a patch for this or there are
> >> already some patches I can take use of?Thanks.
> >
> > You had a init/kerntypes.c in sles9 and sles10. It included a lot
> > of basic kernel types.  It was compiled with -g to make the kerntypes.
> > I presume that you used the LKCD project's lcrash with the kerntypes.
> >
> Hi, Cliff,
> 
> Thanks for your guides.
> 
> Well yes I am intending to use lcrash to load the kernel debug information.
> 
> I noticed that recently kdb is going to be able to print out kernel
> structures, and now I want to test that feature, I started my
> experiments by reading the instructions inside
> kdb/modules/kdbm_debugtypes.c which is saying:
> 
>  * Usage:
>  *  in order for the insmod kdbm_debugtypes.ko to succeed in loading types
>  *  you must first use  lcrash -t kerntypes.xxxx -o debug_info
>  *  and echo debug_info > /proc/kdb/debug_info_name
> 
> so I have to generate kerntypes file. I looked into init/kerntypes.c,
> it seems there is nothing but just includes some header files, like
> below:
> 
>      16 #include <linux/compile.h>
>      17 #include <linux/module.h>
>      18 #include <linux/mm.h>
>      19 #include <linux/vmalloc.h>
>      20 #include <linux/config.h>
>      21 #include <linux/utsname.h>
>      22 #include <linux/kernel_stat.h>
>      23 #include <linux/dump.h>
>      24
>      25 #include <asm/kerntypes.h>
> 
> We can see here are 9 files are included, does this mean the resulted
> Kerntypes file only provides kernel structures that are defined within
> these 9 files?
Yes
> If I want to print out more kernel structures I need to
> change this file so as to include more header files?

Yes, in theory. But not so easily done, as you can't throw in any and every
header and get a clean compile.
 
> In addition, if I want to generate Kerntypes file via building a
> mainline kernel(rather than SLES kernel), the only thing I need to do
> is:
> 1. add this init/kerntypes.c and include/asm/kerntypes.h into kernel
> source code.
> 2. change the Makefile accordingly.
> 
> After that I just compile the kernel as usual and I should be able to
> get the Kerntypes file(which is actually nothing but just
> init/kerntypes.o), right?

You wouldn't use init/kerntypes.c
In your .config file set CONFIG_DEBUG_INFO=y
That will cause the whole kernel to be compiled with -g.
Then:   dwarfextract -Pp vmlinux kerntypes
You can append the structures from any modules:
 dwarfextract kerntypes -c xxx.ko,yyy.ko,zzz.ko kerntypes.with.modules

> 
> Regards
> Jason
> 
> > If you download lkcd (lkcd.svn.sourceforge.net) you also build a
> > tool called dwarfextract.  It is able to pull all the structure
> > definitions out of a -g (CONFIG_DEBUG_INFO) kernel and any selected
> > modules.  That is useful with the lcrash command.
BTW  there are recent additions to dwarfextract. you might want to
     re-download lkcd.

-Cliff
-- 
Cliff Wickman
Silicon Graphics, Inc.
cpw@sgi.com
(651) 683-3824

  reply	other threads:[~2009-01-23 13:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-22 10:59 How to generate a Kerntypes file? jidong xiao
2009-01-22 13:31 ` Cliff Wickman
2009-01-23  6:37   ` jidong xiao
2009-01-23 13:45     ` Cliff Wickman [this message]
2009-01-24  9:07       ` jidong xiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090123134518.GA23513@sgi.com \
    --to=cpw@sgi.com \
    --cc=jidong.xiao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.