Upon startup, MCUXpresso debugger breaks into a wrong code file (not at the start of “main”)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Upon startup, MCUXpresso debugger breaks into a wrong code file (not at the start of “main”)

599 Views
Eugene723
Contributor II

I began initial testing with just a blinking LED and debugger flawlessly braked at the start of “main”. Here is what GDB log stated:

 

447,255 (gdb)

447,316 96-list-thread-groups i1

447,318 97-stack-select-frame --thread 1 0

447,318 96^done,threads=[{id="1",target-id="Thread 1",details=" ",frame={level="0",addr="0x000002fa",func="main",args=[],file="../src/main.c",fullname="<path>\\src\\main.c",line="40",arch="armv7"},state="stopped"}]

447,319 (gdb)

447,319 97^done

 

I don’t understand much of it, but portion <addr="0x000002fa",func="main"> makes sense to me (.map file shows that “main” resides at 0x2F4)

 

I then added SD card handling code file “sdcard.c” from a different project. After this, as debug session starts, debugger breaks into line 630 in “sdcard.c”. Per GDB log:

096,610 (gdb)

096,633 97-list-thread-groups i1

096,634 98-stack-select-frame --thread 1 0

096,637 99-stack-select-frame --thread 1 0

096,647 97^done,threads=[{id="1",target-id="Thread 1",details=" ",frame={level="0",addr="0x00000324",func="ReadSDCardStatus",args=[{name="pSDC",value="0x1000fed8"},{name="cardInfo",value="0x1000feb0"},{name="readBuffer",value="0x0 <IsCardReadyForData>"}],file="../src/sdcard.c",fullname=",path>\\src\\sdcard.c",line="630",arch="armv7"},state="stopped"}]

096,647 (gdb)

096,647 98^done

 

Noice that in this portion:

addr="0x00000324",func="ReadSDCardStatus"

0x324 is the new address of “main” (per .map file) yet the name of the function “ReadSDCardStatus” is incorrect/irrelevant as it resides in “sdcard.c" and it is its closing brace that occupies line 630 …

 

After resuming execution, debugger steps back into “main”. However, I need to understand the reason for such odd behavior and that it’s not indicative of a deeper flaw.

 

Please help tackle this problem.

 

Device: LPC1788, board: Embedded Artists, MCUXpresso ver. 11.8.0, library: NewlibNano, debugger: LPC-LINK2

 

Update of October/05/2023: Strangely, the problem disappeared after I had renamed “sdcard.c” code file into “sd_card.c”.

To recap: File “sdcard.c” used in two separate projects from different workspaces.

                Debugger steps through the code in the project created earlier.

                In the project created later debugger jumps into the middle of a function residing in section apparently discarded according to the .map file.

                Renaming the code file in question to slightly different name restores correct stepping with debugger.

… odd! Any explanations, please?

 

Thank you,

 

Eugene

Tags (3)
0 Kudos
Reply
1 Reply

550 Views
lpcxpresso_supp
NXP Employee
NXP Employee

I'd like to inspect full GDB traces for both cases. Could it be that the ELF you used on host, for debugging, was actually different compared to the actual image executing on target? In other words, you rebuilt the project but you never programmed the new code on target.

Regards,

MCUXpresso IDE Support

0 Kudos
Reply