0

I want to debug a user module using kgdb . The code :

#include<linux/init.h>
#include<linux/module.h>
#include<linux/kernel.h>
int r_day,rday1=10;

static int hello_init(void)

{

    printk(KERN_ALERT "Hello World");
    return 0;

}

static void hello_exit(void)

{

    printk(KERN_ALERT "Goodbye World");

}


module_init(hello_init);

module_exit(hello_exit);

The makefile:

_CFLAGS=-g

obj-m := hello-kernel.o

hello-kernel-objs := hello.o

I have my kernel compiled with proper debugging symbols (CONFIG_DEBUG_INFO=y). But still when I check my sections in my module all the segments have address as 0x0000000000000000. Please help.

  • `_CFLAGS = -g -DDEBUG`? – SD. Jan 12 '17 at 10:44
  • @SD, `-DDEBUG` is redundant, `-g` is supplied as well. I suppose @Vinay has to remove that line completely from *Makefile*. – 0andriy Jan 12 '17 at 12:41
  • I take it that you are using this: https://www.linux.com/learn/kernel-newbie-corner-kernel-and-module-debugging-gdb - did you try "(gdb) add-symbol-file" as described there? And please elaborate on "all the segments have address as 0x0000000000000000". – michaeljt Jan 12 '17 at 16:05
  • Hello, I want to debug my modules from a remote computer using kgdb (source code level debugging of modules ). But I am not able to generate debug symbols for my modules when I compile them. How I know this , is when I go to /sys/module//sections and check the different sections of my modules all have the same address i.e. 0x0000...000 . – Vinay Varahabhotla Jan 13 '17 at 06:34
  • Please tell me how can I add symbols to my modules so that I can add my symbols file to gdb via add-symbols command . – Vinay Varahabhotla Jan 13 '17 at 06:35
  • Presently when I am adding symbols the symbols file is getting added but when I try to put breakpoint in my fucntions I get the message (not in present context ) . – Vinay Varahabhotla Jan 13 '17 at 06:36
  • Did you check the files in sections as user or as root? On my Ubuntu system (at random, module "drm"), if I read them as user I also get 0x0, but as root I get a value. – michaeljt Jan 13 '17 at 15:44

0 Answers0