ccs debug kernel

ccs kernel debug

Some time, we need to debug kernel for locate key message. So need to single step to debug kernel code. Below method that provided you to debug kernel code.

1 understand below file

  1. system.map
  2. vmlinux

    2 Kernel ccs debug step:

  3. Congigure CONFIG_DEBUG_INFO=y, once you configure the info, you need to check the .config file.
        diff --git a/ti_config_fragments/boot_opt.cfg b/ti_config_fragments/boot_opt.cfg
        index 02b3c6b..693eaea 100644
        --- a/ti_config_fragments/boot_opt.cfg
        +++ b/ti_config_fragments/boot_opt.cfg
        @@ -53,7 +53,7 @@ CONFIG_DEBUG_FS=n
         CONFIG_KPROBES=n
         
         # Remove debug info from kernel to reduce size
        -CONFIG_DEBUG_INFO=n
        +CONFIG_DEBUG_INFO=y
         
         # Change kernel compression to LZO which has faster decompression
         # times compared to gzip.
  1. Make file add configure for debug:ccflags-y := -DDEBUG -O0
  2. Debug single file:CFLAGS_omap_hwmod.o += -O0
  3. load symbol: vmlinux

3 example

    diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
    index 3466e05..6c48b8c0 100644
    --- a/arch/arm/mach-omap2/Makefile
    +++ b/arch/arm/mach-omap2/Makefile
    @@ -10,6 +10,8 @@ obj-y := id.o io.o control.o mux.o devices.o fb.o serial.o timer.o pm.o \
             common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
             omap_device.o sram.o drm.o
     
    +CFLAGS_omap_hwmod.o += -O0
    +CFLAGS_io.o += -O0
     hwmod-common                           = omap_hwmod.o omap_hwmod_reset.o \
                                              omap_hwmod_common_data.o
     clock-common                           = clock.o
    diff --git a/arch/arm/mach-omap2/clockdomains7xx_data.c b/arch/arm/mach-omap2/clockdomains7xx_data.c
    index dd37efa..8f0252c 100644
    --- a/arch/arm/mach-omap2/clockdomains7xx_data.c
    +++ b/arch/arm/mach-omap2/clockdomains7xx_data.c
    @@ -352,7 +352,7 @@ static struct clockdomain iva_7xx_clkdm = {
            .dep_bit          = DRA7XX_IVA_STATDEP_SHIFT,
            .wkdep_srcs       = iva_wkup_sleep_deps,
            .sleepdep_srcs    = iva_wkup_sleep_deps,
    -       .flags            = CLKDM_CAN_HWSUP_SWSUP,
    +       .flags            = CLKDM_CAN_FORCE_WAKEUP,
     };
     
     static struct clockdomain coreaon_7xx_clkdm = {
    @@ -736,5 +736,6 @@ void __init dra7xx_clockdomains_init(void)
     {
            clkdm_register_platform_funcs(&omap4_clkdm_operations);
            clkdm_register_clkdms(clockdomains_dra7xx);
    +       printk(KERN_DEBUG ">>>>> fredy; clkdoms register \n");
            clkdm_complete_init();
     }
    diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
    index 24e05ad..bf578ea 100644
    --- a/arch/arm/mach-omap2/omap_hwmod.c
    +++ b/arch/arm/mach-omap2/omap_hwmod.c
    @@ -3346,6 +3346,10 @@ struct omap_hwmod *omap_hwmod_lookup(const char *name)
      * caller of omap_hwmod_for_each().  @fn is called with
      * omap_hwmod_for_each() held.
      */
    +char nameoftempoh[20][20];
    +int idxtempoh =0;
    +int actualidx=0;
    +
     int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
                            void *data)
     {
    @@ -3356,7 +3360,11 @@ int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
                    return -EINVAL;
     
            list_for_each_entry(temp_oh, &omap_hwmod_list, node) {
    +               strcpy(nameoftempoh[idxtempoh],temp_oh->name);
                    ret = (*fn)(temp_oh, data);
    +               idxtempoh=(idxtempoh+1)%20;
    +               actualidx++;
    +
                    if (ret)
                            break;
            }
    @@ -3471,8 +3479,13 @@ static int __init omap_hwmod_setup_all(void)
            omaphwmod_dur = read_fast_counter();
            omap_hwmod_build_ti_hwmod_list();
            _ensure_mpu_hwmod_is_setup(NULL);
    +       idxtempoh=0;
    +    actualidx=0;
     
            omap_hwmod_for_each(_init, NULL);
    +       idxtempoh=0;
    +    actualidx=0;
    +
            omap_hwmod_for_each(_setup, NULL);
            omaphwmod_dur = read_fast_counter() - omaphwmod_dur;
     
    diff --git a/arch/arm/mach-omap2/powerdomains7xx_data.c b/arch/arm/mach-omap2/powerdomains7xx_data.c
    index 7fb8714..4d630f9 100644
    --- a/arch/arm/mach-omap2/powerdomains7xx_data.c
    +++ b/arch/arm/mach-omap2/powerdomains7xx_data.c
    @@ -36,7 +36,7 @@ static struct powerdomain iva_7xx_pwrdm = {
            .name             = "iva_pwrdm",
            .prcm_offs        = DRA7XX_PRM_IVA_INST,
            .prcm_partition   = DRA7XX_PRM_PARTITION,
    -       .pwrsts           = PWRSTS_OFF_ON,
    +       .pwrsts           = PWRSTS_ON,
            .banks            = 4,
            .pwrsts_mem_on  = {
                    [0] = PWRSTS_ON,        /* hwa_mem */
    @@ -394,7 +394,7 @@ void __init dra7xx_powerdomains_init(void)
     {
            pwrdm_register_platform_funcs(&omap4_pwrdm_operations);
            pwrdm_register_pwrdms(powerdomains_dra7xx);
    -
    +       printk(KERN_DEBUG ">>>>> fredy; pwrdoms register \n");
            if (soc_is_dra76x())
                    pwrdm_register_pwrdms(powerdomains_dra76x);
            else if (soc_is_dra74x())
    diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
    index af9e9af..9524d76 100644
    --- a/drivers/clk/Makefile
    +++ b/drivers/clk/Makefile
    @@ -14,7 +14,7 @@ obj-$(CONFIG_COMMON_CLK)      += clk-gpio.o
     ifeq ($(CONFIG_OF), y)
     obj-$(CONFIG_COMMON_CLK)       += clk-conf.o
     endif
    -
    +ccflags-y := -DDEBUG -O0
     # hardware specific clock types
     # please keep this section sorted lexicographically by file/directory path name
     obj-$(CONFIG_MACH_ASM9260)             += clk-asm9260.o
    diff --git a/init/Makefile b/init/Makefile
    index 7bc47ee..564e6e1 100644
    --- a/init/Makefile
    +++ b/init/Makefile
    @@ -1,7 +1,6 @@
     #
     # Makefile for the linux kernel.
     #
    -
     obj-y                          := main.o version.o mounts.o
     ifneq ($(CONFIG_BLK_DEV_INITRD),y)
     obj-y                          += noinitramfs.o
    @@ -13,7 +12,7 @@ obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
     ifneq ($(CONFIG_ARCH_INIT_TASK),y)
     obj-y                          += init_task.o
     endif
    -
    +ccflags-y := -DDEBUG -O0
     mounts-y                       := do_mounts.o
     mounts-$(CONFIG_BLK_DEV_RAM)   += do_mounts_rd.o
     mounts-$(CONFIG_BLK_DEV_INITRD)        += do_mounts_initrd.o
    diff --git a/init/main.c b/init/main.c
    index 649c622..1dd93ed 100644
    --- a/init/main.c
    +++ b/init/main.c
    @@ -503,7 +503,7 @@ static void __init mm_init(void)
            ioremap_huge_init();
            mm_init_dur = read_fast_counter() - mm_init_dur;
     }
    -
    +volatile int done=1;
     asmlinkage __visible void __init start_kernel(void)
     {
            char *command_line;
    @@ -511,6 +511,10 @@ asmlinkage __visible void __init start_kernel(void)
            u32 start_time_pmu;
            u32 setup_arch_time_pmu;
            u32 setup_arch_time_32k;
    +       while (done==1)
    +       {
    +                asm("NOP");
    +       }
     
            start_time_pmu = ARM_CCNT_Read();
     
    @@ -723,7 +727,7 @@ static void __init do_ctors(void)
     #endif
     }
     
    -bool initcall_debug;
    +bool initcall_debug = 1;
     core_param(initcall_debug, initcall_debug, bool, 0644);
     
     #ifdef CONFIG_KALLSYMS
    @@ -777,10 +781,14 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn)
            return false;
     }
     #else
    +static char blacklist_buf[128] = "\0";
    +
     static int __init initcall_blacklist(char *str)
     {
    -       pr_warn("initcall_blacklist requires CONFIG_KALLSYMS\n");
    +       snprintf(blacklist_buf, 127, "%s", str);
    +       pr_debug("blacklisted initcall %s\n", blacklist_buf);
            return 0;
    +
     }
     
     static bool __init_or_module initcall_blacklisted(initcall_t fn)
    @@ -796,13 +804,13 @@ static int __init_or_module do_one_initcall_debug(initcall_t fn)
            unsigned long long duration;
            int ret;
     
    -       printk(KERN_DEBUG "calling  %pF @ %i\n", fn, task_pid_nr(current));
    +       printk(KERN_INFO "calling  %pF @ %i\n", fn, task_pid_nr(current));
            calltime = ktime_get();
            ret = fn();
            rettime = ktime_get();
            delta = ktime_sub(rettime, calltime);
            duration = (unsigned long long) ktime_to_ns(delta) >> 10;
    -       printk(KERN_DEBUG "initcall %pF returned %d after %lld usecs\n",
    +       printk(KERN_INFO "initcall %pF returned %d after %lld usecs\n",
                     fn, ret, duration);
     
            return ret;
    @@ -813,7 +821,13 @@ int __init_or_module do_one_initcall(initcall_t fn)
            int count = preempt_count();
            int ret;
            char msgbuf[64];
    +       char fn_name[128] = "\0";
     
    +       snprintf(fn_name, 127, "%pf", fn);
    +       if (!strcmp(fn_name, blacklist_buf)) {
    +               pr_debug("function %pf returning without executing\n", fn);
    +               return -EPERM;
    +       }
            if (initcall_blacklisted(fn))
                    return -EPERM;
     
    diff --git a/ti_config_fragments/boot_opt.cfg b/ti_config_fragments/boot_opt.cfg
    index 02b3c6b..693eaea 100644
    --- a/ti_config_fragments/boot_opt.cfg
    +++ b/ti_config_fragments/boot_opt.cfg
    @@ -53,7 +53,7 @@ CONFIG_DEBUG_FS=n
     CONFIG_KPROBES=n
     
     # Remove debug info from kernel to reduce size
    -CONFIG_DEBUG_INFO=n
    +CONFIG_DEBUG_INFO=y
     
     # Change kernel compression to LZO which has faster decompression
     # times compared to gzip.

转载于:https://www.cnblogs.com/widic/p/10942438.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: ccs debug assertion failed是指在CCS(Code Composer Studio)调试过程中出现了断言失败的错误。断言是一种程序员在代码中使用的调试工具,用于检查程序中的假设条件是否为真。如果断言失败,说明程序中存在错误或者假设条件不成立。 在CCS中,断言失败通常会导致程序崩溃或者出现异常行为。要解决这个问题,需要检查程序中的断言语句,找出导致断言失败的原因,并进行修复。可以使用调试工具来定位问题,或者添加日志输出来帮助排查问题。 ### 回答2: CCS Debug Assertion Failed是一种出现在代码编写和测试过程中的错误提示,它指出在调试期间找到了断言失败的触发条件。具体而言,当程序运行到某一个位置,而该位置的前提条件没有被满足,那么CCS会提示Debug Assertion Failed的错误信息,表示程序无法继续正常运行。 这种错误信息通常出现在C++或C语言的编程环境中,而其中的断言语句通常包含在assert函数里面。assert函数起到一个程序调试的作用,在程序开发的过程中,assert函数可以将一些错误发现出来,让程序员在开发过程中及早发现问题并解决它们。 出现CCS Debug Assertion Failed的原因可能有很多,其主要原因是程序中存在错误逻辑或运算错误。一些常见的导致assertion failed错误出现的情况包括指针问题、数组越界、内存泄漏、参数错误等等。 为了解决CCS Debug Assertion Failed的问题,程序员可以通过以下几种方法进行修复。首先,程序员需要仔细检查程序代码,查找并解决逻辑错误和运算错误;其次,程序前期需要做好各种边界值处理,避免数组越界、指针错误等问题;最后,程序员可以通过调用并使用一些常用的调试工具或代码健壮性检查工具来解决问题。 总之,CCS Debug Assertion Failed错误提示往往是由于程序逻辑错误导致的,要解决该问题,程序员需要对程序进行详细的检查和分析,并采取适当的措施来解决问题,以确保程序的稳定性和健壮性。 ### 回答3: CCS Debug Assertion Failed是在使用Code Composer Studio (CCS)进行调试时常见的错误。在调试过程中,CCS发现了一些代码错误或者内存操作错误,导致程序无法正确地运行,从而引发了该错误。 在调试过程中,CCS会检测代码中一些常见的问题,例如数组越界、指针操作错误、内存泄漏等等。当CCS发现这些错误时,会触发Debug Assertion Failed错误。这些错误通常伴随着错误代码和具体的错误描述,方便程序员查找并解决问题。 要解决CCS Debug Assertion Failed错误,首先应该查看错误代码和错误描述,找到可能引起该错误的代码行。然后,需要仔细分析代码,了解错误产生的原因,修改代码并重新编译。如果错误很难发现,可以使用CCS提供的调试工具进行调试和跟踪,寻找问题的根源。 除了代码错误外,CCS Debug Assertion Failed错误还可能是由于硬件或软件环境问题引起的。例如,如果程序运行出错,可能是由于某些外部设备连接错误或者驱动程序不正确导致的。这种情况下,需要检查硬件和驱动程序是否正确配置,并重新测试程序。 总之,CCS Debug Assertion Failed错误是一种常见的错误,但是可以通过仔细分析代码和逐步排查问题来解决。程序员需要对代码和环境进行仔细的检查和分析,才能找到并修复问题,确保程序正常运行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值