Linux MIPS Architecture development
 help / color / mirror / Atom feed
* remote GDB debugging and the __init macro of init.h
@ 2000-10-27 15:24 Steve Kranz
  2000-10-27 15:50 ` Kevin D. Kissell
  2000-10-28  1:54 ` Keith Owens
  0 siblings, 2 replies; 7+ messages in thread
From: Steve Kranz @ 2000-10-27 15:24 UTC (permalink / raw)
  To: linux-mips, linux-mips

Note:

  I had to make a change to allow remote MIPS kernel
  debugging (GDB). The change I found necessary was in the
  file:

    include/linux/init.h     (2.4.0-test9)

  As you can see from the snippet below the change
  involves conditionally defining the "__init" macro as
  a function of whether remote debugging is enabled or
  not. Am I missing something, or does this seem like a
  reasonable change?

===========
Was this...
===========
/*
 * Mark functions and data as being only used at initialization
 * or exit time.
 */
#define __init  __attribute__ ((__section__ (".text.init")))

==================================
I changed my local copy to this...
==================================
/*
 * Mark functions and data as being only used at initialization
 * or exit time.
 */
#ifdef CONFIG_REMOTE_DEBUG
// Note: While running the mips-linux-elf-gdb (GNU gdb 5.0), RidgeRun
Inc
// noticed that gdb could not correctly derive the true address of any
symbol
// declared with the __init pragma. This prevented being able to
correctly
// set breakpoints on any of those functions. So, if we are building
// with the GDB remote debugger in mind, then null out the __init
// definition making those functions look like a normal functions
// since this seems to satisfy things for remote kernel debugging.
// Incidentally, for reference, the GDB being used at the time of this
writing
// was configured as "--host=i686-pc-linux-gnu --target=mips-linux-elf".

// and the mips-linux-gcc crosscompiler being used is egcs-2.90.29
980515
// (egcs-1.0.3 release) with binutils version 2.8.1. (These tools
running on
// a x86 host producing code for target CONFIG_CPU_R5000).
#define __init
#else
#define __init  __attribute__ ((__section__ (".text.init")))
#endif


Steve Kranz
skranz@ridgerun.com
Senior Kernel Developer
RidgeRun Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remote GDB debugging and the __init macro of init.h
  2000-10-27 15:24 remote GDB debugging and the __init macro of init.h Steve Kranz
@ 2000-10-27 15:50 ` Kevin D. Kissell
  2000-10-27 15:50   ` Kevin D. Kissell
                     ` (2 more replies)
  2000-10-28  1:54 ` Keith Owens
  1 sibling, 3 replies; 7+ messages in thread
From: Kevin D. Kissell @ 2000-10-27 15:50 UTC (permalink / raw)
  To: Steve Kranz, linux-mips, linux-mips

What you've done should solve the problem, but note
that it has the side effect of preventing the text and data
sections in question from getting freed up at the end
of initialization.  I probably should have done so myself
last year when I was struggling with debugging some init 
code using kgdb, but instead I simply got used to finding 
the address in the symbol table and setting the breakpoints 
by hex address instead of by symbol.

The real fix would be to  teach gdb to treat symbols
in the init section as valid targets.

            Kevin K.

----- Original Message ----- 
From: "Steve Kranz" <skranz@ridgerun.com>
To: <linux-mips@oss.sgi.com>; <linux-mips@fnet.fr>
Sent: Friday, October 27, 2000 5:24 PM
Subject: remote GDB debugging and the __init macro of init.h


> Note:
> 
>   I had to make a change to allow remote MIPS kernel
>   debugging (GDB). The change I found necessary was in the
>   file:
> 
>     include/linux/init.h     (2.4.0-test9)
> 
>   As you can see from the snippet below the change
>   involves conditionally defining the "__init" macro as
>   a function of whether remote debugging is enabled or
>   not. Am I missing something, or does this seem like a
>   reasonable change?
> 
> ===========
> Was this...
> ===========
> /*
>  * Mark functions and data as being only used at initialization
>  * or exit time.
>  */
> #define __init  __attribute__ ((__section__ (".text.init")))
> 
> ==================================
> I changed my local copy to this...
> ==================================
> /*
>  * Mark functions and data as being only used at initialization
>  * or exit time.
>  */
> #ifdef CONFIG_REMOTE_DEBUG
> // Note: While running the mips-linux-elf-gdb (GNU gdb 5.0), RidgeRun
> Inc
> // noticed that gdb could not correctly derive the true address of any
> symbol
> // declared with the __init pragma. This prevented being able to
> correctly
> // set breakpoints on any of those functions. So, if we are building
> // with the GDB remote debugger in mind, then null out the __init
> // definition making those functions look like a normal functions
> // since this seems to satisfy things for remote kernel debugging.
> // Incidentally, for reference, the GDB being used at the time of this
> writing
> // was configured as "--host=i686-pc-linux-gnu --target=mips-linux-elf".
> 
> // and the mips-linux-gcc crosscompiler being used is egcs-2.90.29
> 980515
> // (egcs-1.0.3 release) with binutils version 2.8.1. (These tools
> running on
> // a x86 host producing code for target CONFIG_CPU_R5000).
> #define __init
> #else
> #define __init  __attribute__ ((__section__ (".text.init")))
> #endif
> 
> 
> Steve Kranz
> skranz@ridgerun.com
> Senior Kernel Developer
> RidgeRun Inc.
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remote GDB debugging and the __init macro of init.h
  2000-10-27 15:50 ` Kevin D. Kissell
@ 2000-10-27 15:50   ` Kevin D. Kissell
  2000-10-28  1:53   ` Ralf Baechle
  2000-10-30 17:53   ` Jun Sun
  2 siblings, 0 replies; 7+ messages in thread
From: Kevin D. Kissell @ 2000-10-27 15:50 UTC (permalink / raw)
  To: Steve Kranz, linux-mips, linux-mips

What you've done should solve the problem, but note
that it has the side effect of preventing the text and data
sections in question from getting freed up at the end
of initialization.  I probably should have done so myself
last year when I was struggling with debugging some init 
code using kgdb, but instead I simply got used to finding 
the address in the symbol table and setting the breakpoints 
by hex address instead of by symbol.

The real fix would be to  teach gdb to treat symbols
in the init section as valid targets.

            Kevin K.

----- Original Message ----- 
From: "Steve Kranz" <skranz@ridgerun.com>
To: <linux-mips@oss.sgi.com>; <linux-mips@fnet.fr>
Sent: Friday, October 27, 2000 5:24 PM
Subject: remote GDB debugging and the __init macro of init.h


> Note:
> 
>   I had to make a change to allow remote MIPS kernel
>   debugging (GDB). The change I found necessary was in the
>   file:
> 
>     include/linux/init.h     (2.4.0-test9)
> 
>   As you can see from the snippet below the change
>   involves conditionally defining the "__init" macro as
>   a function of whether remote debugging is enabled or
>   not. Am I missing something, or does this seem like a
>   reasonable change?
> 
> ===========
> Was this...
> ===========
> /*
>  * Mark functions and data as being only used at initialization
>  * or exit time.
>  */
> #define __init  __attribute__ ((__section__ (".text.init")))
> 
> ==================================
> I changed my local copy to this...
> ==================================
> /*
>  * Mark functions and data as being only used at initialization
>  * or exit time.
>  */
> #ifdef CONFIG_REMOTE_DEBUG
> // Note: While running the mips-linux-elf-gdb (GNU gdb 5.0), RidgeRun
> Inc
> // noticed that gdb could not correctly derive the true address of any
> symbol
> // declared with the __init pragma. This prevented being able to
> correctly
> // set breakpoints on any of those functions. So, if we are building
> // with the GDB remote debugger in mind, then null out the __init
> // definition making those functions look like a normal functions
> // since this seems to satisfy things for remote kernel debugging.
> // Incidentally, for reference, the GDB being used at the time of this
> writing
> // was configured as "--host=i686-pc-linux-gnu --target=mips-linux-elf".
> 
> // and the mips-linux-gcc crosscompiler being used is egcs-2.90.29
> 980515
> // (egcs-1.0.3 release) with binutils version 2.8.1. (These tools
> running on
> // a x86 host producing code for target CONFIG_CPU_R5000).
> #define __init
> #else
> #define __init  __attribute__ ((__section__ (".text.init")))
> #endif
> 
> 
> Steve Kranz
> skranz@ridgerun.com
> Senior Kernel Developer
> RidgeRun Inc.
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remote GDB debugging and the __init macro of init.h
  2000-10-27 15:50 ` Kevin D. Kissell
  2000-10-27 15:50   ` Kevin D. Kissell
@ 2000-10-28  1:53   ` Ralf Baechle
  2000-10-30 17:53   ` Jun Sun
  2 siblings, 0 replies; 7+ messages in thread
From: Ralf Baechle @ 2000-10-28  1:53 UTC (permalink / raw)
  To: Kevin D. Kissell; +Cc: Steve Kranz, linux-mips, linux-mips

On Fri, Oct 27, 2000 at 05:50:50PM +0200, Kevin D. Kissell wrote:

> What you've done should solve the problem, but note
> that it has the side effect of preventing the text and data
> sections in question from getting freed up at the end
> of initialization.  I probably should have done so myself
> last year when I was struggling with debugging some init 
> code using kgdb, but instead I simply got used to finding 
> the address in the symbol table and setting the breakpoints 
> by hex address instead of by symbol.
> 
> The real fix would be to  teach gdb to treat symbols
> in the init section as valid targets.

Did somebody look into porting KDB?

  Ralf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remote GDB debugging and the __init macro of init.h
  2000-10-27 15:24 remote GDB debugging and the __init macro of init.h Steve Kranz
  2000-10-27 15:50 ` Kevin D. Kissell
@ 2000-10-28  1:54 ` Keith Owens
  1 sibling, 0 replies; 7+ messages in thread
From: Keith Owens @ 2000-10-28  1:54 UTC (permalink / raw)
  To: Steve Kranz; +Cc: linux-mips, linux-mips

On Fri, 27 Oct 2000 09:24:17 -0600, 
Steve Kranz <skranz@ridgerun.com> wrote:
>  I had to make a change to allow remote MIPS kernel
>  debugging (GDB). The change I found necessary was in the
>  file:
>
>    include/linux/init.h     (2.4.0-test9)
>
>  As you can see from the snippet below the change
>  involves conditionally defining the "__init" macro as
>  a function of whether remote debugging is enabled or
>  not. Am I missing something, or does this seem like a
>  reasonable change?

It would be better to teach kgdb that the kernel has symbols in
sections other than .text.  Even with your patch, you do not get all
the symbols, there is also code in sections .setup.init, .initcall.init
and .exitcall.exit, with similar sections for data.  You cannot remove
.initcall.init without destroying the kernel initialization procedure.

Recent versions of kgdb for ix86 use a modified version of gdb that
knows about multiple sections for modules.  I do not know if they have
the same functionality for the kernel.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remote GDB debugging and the __init macro of init.h
  2000-10-27 15:50 ` Kevin D. Kissell
  2000-10-27 15:50   ` Kevin D. Kissell
  2000-10-28  1:53   ` Ralf Baechle
@ 2000-10-30 17:53   ` Jun Sun
  2000-10-31  4:12     ` Ralf Baechle
  2 siblings, 1 reply; 7+ messages in thread
From: Jun Sun @ 2000-10-30 17:53 UTC (permalink / raw)
  To: Kevin D. Kissell; +Cc: Steve Kranz, linux-mips, linux-mips

"Kevin D. Kissell" wrote:
> 
> What you've done should solve the problem, but note
> that it has the side effect of preventing the text and data
> sections in question from getting freed up at the end
> of initialization.  I probably should have done so myself
> last year when I was struggling with debugging some init
> code using kgdb, but instead I simply got used to finding
> the address in the symbol table and setting the breakpoints
> by hex address instead of by symbol.
> 

Kevin,

A dumb question - how do you set breakpoint at specified address?  I was
trying to do that with "b 0xabcdabcd" or "b @0xabcdabcd", none of them
worked.

Jun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remote GDB debugging and the __init macro of init.h
  2000-10-30 17:53   ` Jun Sun
@ 2000-10-31  4:12     ` Ralf Baechle
  0 siblings, 0 replies; 7+ messages in thread
From: Ralf Baechle @ 2000-10-31  4:12 UTC (permalink / raw)
  To: Jun Sun; +Cc: Kevin D. Kissell, Steve Kranz, linux-mips, linux-mips

On Mon, Oct 30, 2000 at 09:53:59AM -0800, Jun Sun wrote:

> > What you've done should solve the problem, but note
> > that it has the side effect of preventing the text and data
> > sections in question from getting freed up at the end
> > of initialization.  I probably should have done so myself
> > last year when I was struggling with debugging some init
> > code using kgdb, but instead I simply got used to finding
> > the address in the symbol table and setting the breakpoints
> > by hex address instead of by symbol.
> 
> A dumb question - how do you set breakpoint at specified address?  I was
> trying to do that with "b 0xabcdabcd" or "b @0xabcdabcd", none of them
> worked.

b *0xabcdabcd

Try ``help break'' :-)

  Ralf

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-10-31  4:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-10-27 15:24 remote GDB debugging and the __init macro of init.h Steve Kranz
2000-10-27 15:50 ` Kevin D. Kissell
2000-10-27 15:50   ` Kevin D. Kissell
2000-10-28  1:53   ` Ralf Baechle
2000-10-30 17:53   ` Jun Sun
2000-10-31  4:12     ` Ralf Baechle
2000-10-28  1:54 ` Keith Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox