Subject: Break point not hit while debugging linux kernel with kgdb

Hi,

I tried to debug the linux kernel with kgdb (over serial port). I have
configured the host and target machines and I am able to connect, step
in the kernel code. In gdb I gave "break usb_register_dev" and "break
usb_deregister_dev" and continued the execution (continue in gdb).
Once the desktop is up, I connected a USB device (first tried with USB
keyboard). Break point was not hit. I tried some more functions and
break points are never hit. What should I do for it? Am I missing
something?

Thanks,
Prasanna Kumar T S M


2012-06-09 18:23:42

by Anil Nair

[permalink] [raw]
Subject: Re: Break point not hit while debugging linux kernel with kgdb

Hi Prasanna,

On Mon, May 28, 2012 at 3:46 PM, prasannatsmkumar
<[email protected]> wrote:
> Hi,
>
> I tried to debug the linux kernel with kgdb (over serial port).

The Maintainers would never recommend the use of a debugger, it
results in poorly fixed patches.

> I have
> configured the host and target machines and I am able to connect, step
> in the kernel code. In gdb I gave "break usb_register_dev" and "break
> usb_deregister_dev" and continued the execution (continue in gdb).
> Once the desktop is up, I connected a USB device (first tried with USB
> keyboard). Break point was not hit. I tried some more functions and
> break points are never hit. What should I do for it? Am I missing
> something?

You have to use gdbserver for connecting target and host systems i
guess. You may find many tutorials about it on the internet.


--
Regards,
Anil Nair

2012-06-09 18:49:52

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: Break point not hit while debugging linux kernel with kgdb

Hello.

On 06/09/2012 10:23 PM, Anil Nair wrote:

>> Hi,

>> I tried to debug the linux kernel with kgdb (over serial port).

> The Maintainers would never recommend the use of a debugger, it
> results in poorly fixed patches.

Yeah, KGDB was accepted into kernel exactly for more "poorly fixed patches"
to appear. :-)

>> I have
>> configured the host and target machines and I am able to connect, step
>> in the kernel code. In gdb I gave "break usb_register_dev" and "break
>> usb_deregister_dev" and continued the execution (continue in gdb).
>> Once the desktop is up, I connected a USB device (first tried with USB
>> keyboard). Break point was not hit. I tried some more functions and
>> break points are never hit. What should I do for it? Am I missing
>> something?

> You have to use gdbserver

gdbserver is only good for debugging the applications.

WBR, Sergei

2012-06-10 04:30:16

by Anil Nair

[permalink] [raw]
Subject: Re: Break point not hit while debugging linux kernel with kgdb

Hello Sergei,

On Sun, Jun 10, 2012 at 12:18 AM, Sergei Shtylyov <[email protected]> wrote:

> ? Yeah, KGDB was accepted into kernel exactly for more "poorly fixed
> patches" to appear. :-)

I was under the impression that maintainers would never recommend
kgdb, so never learned to use it.
If you could guide me and Prasanna on how to use kgdb that would be
helpful :). If you were saying it sarcastically, then i failed to
understand it . :P.

>> You have to use gdbserver
> ? gdbserver is only good for debugging the applications.

I never knew that..!.

--
Regards,
Anil Nair

Subject: Re: Break point not hit while debugging linux kernel with kgdb

On Sun, Jun 10, 2012 at 10:00 AM, Anil Nair <[email protected]> wrote:
> Hello Sergei,
>
> On Sun, Jun 10, 2012 at 12:18 AM, Sergei Shtylyov <[email protected]> wrote:
>
>> ? Yeah, KGDB was accepted into kernel exactly for more "poorly fixed
>> patches" to appear. :-)
>
> I was under the impression that maintainers would never recommend
> kgdb, so never learned to use it.
> If you could guide me and Prasanna on how to use kgdb that would be
> helpful :). If you were saying it sarcastically, then i failed to
> understand it . :P.
>
>>> You have to use gdbserver
>> ? gdbserver is only good for debugging the applications.
>
> I never knew that..!.
>
> --
> Regards,
> Anil Nair

In one of the machines I am facing a scenario:
I recompiled Ubuntu linux kernel (with the default config taken from
/boot) and the newly compiled kernel does not boot. After detecting
the hard disk (SCSI device) it panics. I am able to see only a part of
the kernel stack trace due to low resolution so I am in a situation
where I cannot do anything further. In this situation kgdb seems to be
the only way.

Note: The case I mentioned in my first mail is different from this case.

2012-06-11 03:38:07

by Anil Nair

[permalink] [raw]
Subject: Re: Break point not hit while debugging linux kernel with kgdb

Hello Prasanna,

On Sun, Jun 10, 2012 at 10:20 AM, prasannatsmkumar
<[email protected]> wrote:
> In one of the machines I am facing a scenario:
> I recompiled Ubuntu linux kernel (with the default config taken from
> /boot) and the newly compiled kernel does not boot. After detecting
> the hard disk (SCSI device) it panics.

Did you compile the kernel using standard step? Which Ubuntu version
you are trying to install your customized kernel? What is the kernel
version you are trying to compile? For ubuntu distribution standard
steps are given at their site for compiling customized kernel, i
followed those steps and was able to compile and install customized
kernel. Here is the link for it,

https://help.ubuntu.com/community/Kernel/Compile

>I am able to see only a part of
> the kernel stack trace due to low resolution so I am in a situation
> where I cannot do anything further. In this situation kgdb seems to be
> the only way.

Also, i think so the kernel is in panic due to the reason that it
couldn't find initial ram disk. Did you create an initial ram disk
while compiling and installing the kernel? I came through the same
situation that is why i am asking?
are you using mkinitramfs command for creating ramdisk? trying using
update-initrd command, google for it i forgot its usage.! :). After
creating ramdisk move it to the /boot directory and update the grub
using the update-grub command.


I hope this may solve you problem. :)

--
Regards,
Anil Nair

Subject: Re: Break point not hit while debugging linux kernel with kgdb

On Mon, Jun 11, 2012 at 9:07 AM, Anil Nair <[email protected]> wrote:
> Hello Prasanna,
>
> On Sun, Jun 10, 2012 at 10:20 AM, prasannatsmkumar
> <[email protected]> wrote:
>> In one of the machines I am facing a scenario:
>> I recompiled Ubuntu linux kernel (with the default config taken from
>> /boot) and the newly compiled kernel does not boot. After detecting
>> the hard disk (SCSI device) it panics.
>
> Did you compile the kernel using standard step? Which Ubuntu version
> you are trying to install your customized kernel? What is the kernel
> version you are trying to compile? For ubuntu distribution standard
> steps are given at their site for compiling customized kernel, i
> followed those steps and was able to compile and install customized
> kernel. Here is the link for it,
>
> https://help.ubuntu.com/community/Kernel/Compile
>
>>I am able to see only a part of
>> the kernel stack trace due to low resolution so I am in a situation
>> where I cannot do anything further. In this situation kgdb seems to be
>> the only way.
>
> Also, i think so the kernel is in panic due to the reason that it
> couldn't find initial ram disk. Did you create an initial ram disk
> while compiling and installing the kernel? I came through the same
> situation that is why i am asking?
> are you using mkinitramfs command for creating ramdisk? trying using
> update-initrd command, google for it i forgot its usage.! :). After
> creating ramdisk move it to the /boot directory and update the grub
> using the update-grub command.
>
>
> I hope this may solve you problem. :)
>
> --
> Regards,
> Anil Nair

I am using Ubuntu 12.04 64bit. I downloaded the source code of kernel
available in Ubuntu 12.04 and recompiling it. I recompiled and
installed the kernel in couple of machines (one ASUS laptop and
another ASUS desktop) and in those machines it is working fine. I
recompiled the same kernel in one old machine (the same way I did for
other machines) and installed it. Initial ram disk is also created but
I am not able to boot. Everything is set up correctly to my knowledge.

Thanks,
Prasanna Kumar

2012-06-11 17:17:42

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: Break point not hit while debugging linux kernel with kgdb

Hello.

On 10-06-2012 8:30, Anil Nair wrote:

> On Sun, Jun 10, 2012 at 12:18 AM, Sergei Shtylyov<[email protected]> wrote:

>> Yeah, KGDB was accepted into kernel exactly for more "poorly fixed
>> patches" to appear. :-)

> I was under the impression that maintainers would never recommend
> kgdb, so never learned to use it.
> If you could guide me and Prasanna on how to use kgdb that would be
> helpful :).

For the starters, Prasanna should ask his KGDB question in the right
mailing list, [email protected].

> If you were saying it sarcastically, then i failed to
> understand it . :P.

Yes, there was sarcasm. If KGDB was only providing for "poorly fixed
patches", it would have been hardly included in the kernel.

>>> You have to use gdbserver

>> gdbserver is only good for debugging the applications.

> I never knew that..!.

Besides, there's not much difference between remotely debugging
applications via gdbserver and remotely debugging kernel via KGDB.

WBR, Sergei