Eclipse debugger cannot find source

Hi all, @zach @Dave @kennethlimcp

I am using Eclipse CDT IDE for debugging Spark Core firmware, when i executed the deugger, The build & download processes are successful witout error, After that, it will always throw out me a error :

No source available for "0x800010e" 

can you all give me some suggestions for it ? i stucked this for one day.

Hope your suggestions , Thx,
Chris.

Hi @yuanetking,

I’m less familiar with the eclipse firmware setup, but here are some general tips:

  • Make sure you’re building in debug mode and not release mode, and that all the libs you are using are in debug mode, etc.

Here is a thread that might help:

Thanks,
David

It’s a problem of hardware pc and sp pointer. Have you a Startup tab in your debug configuration? Can you post it?

Hi @Dave

How to setup the debug mode ? I have added the USE_SWD_JTAG definition in main.cpp file:

> //added by Chris
> #define USE_SWD_JTAG

> #ifndef USE_SWD_JTAG
> #define SWD_JTAG_DISABLE
> #endif

I added -g option to all the makefiles (core-firmware, core-common, core-communication) as below:

>    # C++ specific flags
>    CPPFLAGS = -fno-exceptions -fno-rtti -g -O0

Hi, @monnoliv

The latest error will be :


I am using the Zylin embbeded debugging plugin, which command are set as following:

target remote localhost:3333
monitor reset
monitor halt
load
disconnect
target remote localhost:3333
monitor reset
monitor halt

The console infomation from gdb will be :

source .gdbinit
.gdbinit: No such file or directory.
target remote localhost:3333
Remote debugging using localhost:3333
hci_event_handler (pRetParams=pRetParams@entry=0x20004f78, from=from@entry=0x0, fromlen=fromlen@entry=0x0) at …/CC3000_Host_Driver/evnt_handler.c:250
250 volatile system_tick_t now = GetSystem1MsTick();
monitor reset
monitor halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x0800b4e0 msp: 0x20004fd8
load
Loading section .isr_vector, size 0x10c lma 0x8005000
Loading section .text, size 0x13224 lma 0x8005110
Loading section .init_array, size 0x58 lma 0x8018334
Loading section .data, size 0x470 lma 0x801838c
Start address 0x8005110, load size 79864
Transfer rate: 11 KB/sec, 9983 bytes/write.
disconnect
Ending remote debugging.
target remote localhost:3333
Remote debugging using localhost:3333
0x08005110 in strcmp ()
monitor reset
monitor halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x0800b4e0 msp: 0x20004fd8
Note: automatically using hardware breakpoints for read-only addresses.

target remote localhost:3333
monitor reset
monitor halt
load
disconnect
target remote localhost:3333
monitor reset
monitor halt

I don’t undersrtand why you connect than disconnect than reconnect.
Normally after the load command, you issue a break main than continue:
load -> load your firmware
break main -> put a breakpoint at main
continue -> go!

But between load and break main I had also to issue two commands to position the PC and SP register.
I don’t have my configuration right now but try like this first.

Hi @monnoliv, Thanks your reply…

I am fresher for linux gdb and embeded dev, the code is just following this link : http://vedder.se/2012/12/debugging-the-stm32f4-using-openocd-gdb-and-eclipse/

below is the result which followed your suggestions:

load ./build/core-firmware.elf
break main
continue

After running the debug configuration, the result will as below:

A dialog will came out after clicked the finish-button of debug session, it show:

Error: Target request failed: The program is not being run.

I don’t think that it is necessary to write:
load "filename"
since you had to put this file as a parameter when you lauch gdb. I simply put:
load
But ok, I don’t think it is the issue. I don’t have my config right now and I don’t remember the command to set the SP and PC register to an absolute value.
But the values of my commands are for the CC3200, not for the stm32. Then in the mean time you have to know where the program in the stm32 start (to set the PC) and where the stack start (to set the SP). I’ll put my configuration asap

Here is my configuration:

#*****************************************************************************
# Load the binary
#*****************************************************************************
monitor soft_reset_halt
load

#*****************************************************************************
# Initialize the SP and PC values from the application's
# vector table
#*****************************************************************************
set $sp = g_pfnVectors[0]
set $pc = g_pfnVectors[1]

#*****************************************************************************
# Set break point at main and run to main
#*****************************************************************************
break main
continue

Hi, @monnoliv

Its failed, as below, Seems, we need to add “target remote localhost:3333” at least, else the target wont be executed. Did you code run in eclipse for Spark successfully ? I really confused for gdb, it stuck me several days . Is there anybody debug it successfully in eclipse ?

Result of your suggesution:

monitor soft_reset_halt
"monitor" command not supported by this target.
load ./build/core-firmware.elf
You can't do that when your target is `exec'
set $sp = g_pfnVectors[0]
No registers.
set $pc = g_pfnVectors[1]
No registers.
break main
Breakpoint 1 at 0x800609c: file ../src/main.cpp, line 162.
continue
The program is not being run.

Below is adding the “target remote localhost:3333” :

monitor soft_reset_halt
"monitor" command not supported by this target.
target remote localhost:3333
Remote debugging using localhost:3333
hci_event_handler (pRetParams=pRetParams@entry=0x20004f38, from=from@entry=0x0, fromlen=fromlen@entry=0x0) at ../CC3000_Host_Driver/evnt_handler.c:247
247			if (tSLInformation.usEventOrDataReceived == 0)
load ./build/core-firmware.elf
Loading section .isr_vector, size 0x10c lma 0x8005000
Loading section .text, size 0x16e14 lma 0x8005110
Loading section .init_array, size 0x58 lma 0x801bf24
Loading section .data, size 0x478 lma 0x801bf7c
Start address 0x8005110, load size 95216
Transfer rate: 11 KB/sec, 10579 bytes/write.
set $sp = g_pfnVectors[0]
cannot subscript something of type `<data variable, no debug info>'
set $pc = g_pfnVectors[1]
cannot subscript something of type `<data variable, no debug info>'
break main
Breakpoint 1 at 0x800609c: file ../src/main.cpp, line 162.
continue
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Program received signal SIGINT, Interrupt.
0x080005d6 in ?? ()

Program received signal SIGINT, Interrupt.
0x080005d6 in ?? ()

Program received signal SIGINT, Interrupt.
0x080005d6 in ?? ()

Hi, @zachary

Can you help me to clarify how to add the debug information in Spark ?

I added the options “-g -O0” in makefile of core-firmware:

> ifeq ("$(USE_SWD_JTAG)","y") 
> CFLAGS += -DUSE_SWD_JTAG   -g -O0 
> endif

> ifeq ("$(DEBUG_BUILD)","y") 
> CFLAGS += -DDEBUG_BUILD
> else
> CFLAGS += -DRELEASE_BUILD
> endif

> # C++ specific flags    
> CPPFLAGS += -fno-rtti -fno-exceptions -g -O0

Looks like you’re on the right track @yuanetking.

On the command line I build with

USE_SWD_JTAG=y make clean all

to use D3, D4, D5, D6, & D7 as JTAG instead of GPIO.

To include use of the calls to the DEBUG and other similar macros, I call

DEBUG_BUILD=y make clean all

And define in my app a debug_output_ function as declared in core-common-lib/SPARK_Firmware_Driver/inc/debug.h with this signature:

void debug_output_(const char *) __attribute__ ((weak));

which typically prints the debug messages to Serial or Serial1.

To prevent optimization, you should change -Os to -O0 in the places where it already exists in the makefiles:

The -g flags are already there, so no need to add them.

Overall, the answer is: the debug info is already there, but optimization might be happening, and otherwise you need to make sure you have access to JTAG or some other form of debugging that works for you.

Cheers!

1 Like

Of course you need to add target “remote localhost:3333”, sorry
But you have to add it before anything else since it is the connexion to the JTAG server (OpenOCD or whatever), also you can’t use my symbols (g_pfnVectors, I’ve writting my config as an example) since you have other symbols, the right

target remote localhost:3333
monitor soft_reset_halt
load
set $sp = g_pfnVectors[0]
set $pc = g_pfnVectors[1]
break main
continue

In Eclipse you don’t have to add load since Eclipse do it for you (if Load Executable checked). Here is a screenshot of my config (from my memory since I’m not in front of my home Eclipse):

Note that you MUST replace my g_pfnVectors symbol by yours (try also without this). Normally you can find this vertor table in the initialisation routine (startupcode).
This is a special config for the CC3200 with OpenOCD but it works :slight_smile:
Keep working, I had also several difficulties to fall in “main” when I started debugging :slight_smile:

Ok ,Thanks your sugguestions @monnoliv, I will try it later . Here , I need to add debug infomation first according to @zachary , :smile:

Seems now the complied object out of Flash after adding the debug infomation when compile process, its show as below, I think this will be a common issue, when people debugging ? But not found the exactly same issue in this forum…

failed in compiling core-communication-lib project:

c:/users/chris/install/dev/stm32_toolchain/netbean/gnu tools arm embedded/4.8 2014q2/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: core-firmware.elf section `.text' will not fit in region `FLASH'
c:/users/chris/install/dev/stm32_toolchain/netbean/gnu tools arm embedded/4.8 2014q2/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 7852 bytes
collect2.exe: error: ld returned 1 exit status
make: *** [core-firmware.elf] Error 1

B.T.W, There is another issue cames before upon issue, R7 register be occured , i added optoins “-O0 -fomit-frame-pointer” then fixed it .

../lib/tropicssl/library/bignum.c: In function 'mpi_mul_hlp':
../lib/tropicssl/library/bignum.c:890:1: error: r7 cannot be used in asm here
 }
 ^
make[1]: *** [obj/lib/tropicssl/library/bignum.o] Error 1
make: *** [check_external_deps] Error 2

Hi, @monnoliv, @zachary,

Its really good news for me that the debugger seems work now , the breakpoint can jump into the application, and i can click the code running step by step. what i did just follow:

1: added @monnoliv 's given: the keyword “break main and continue”.

2: added @zachary 's given : the option a -O0 to the makefile both including the core-firemware & core-common project.

But still have some confusions ,And do this points will impact to debug in future ?

1: I havennt add the USE_SWD_JTAG=y and DEBUG_BUILD=y to the source code.

2: The -O0 option cannot be added into core-communication project(compile will fail) ,since the out of Falsh problem as upon Post of mine.

3: Not add the function “g_pfnVectors”.

Thx, Really appreciate your help, Cheers! :sunny:.

1 Like

Happy to know that it works now :slight_smile:
For the point 3. It is not always necessary to add. This depends of the hardware, for yours apparently it’s not necessary

2 Likes

Haha, :slight_smile: , That functoin is toooo deep for me , Could you please recomments some websites or books to me for the related technology ? whatever that i can build my own embedded things, seems , i need to STUDY…

THX
Chris.

Don’t worry about 1 or 2. :+1:

The assignments in 1 are not for source code, they are typed on the command line. If JTAG debugging is working for you, then you already have what you need.

Regarding 2, it’s OK if the communication lib gets optimized. You don’t need to debug that anyway. :slight_smile:

2 Likes