[coldfire-gnu-discuss] GDB freeze when steping into a loop with P&E BDM
Stephane Franck Rey
stephane.franck.rey at cern.ch
Mon May 23 09:52:35 UTC 2011
Hi Carlos,
Attached is a zip including my example project.
I've debugged my example code using gdb command line and found the same problem excluding then an IDE problem. Below are my tests results details but to summarize here is what I've seen:
1. invoking gdb, setting breakpoints, running the program with command 'continue'
The program starts but doesn't stop on breakpoint, I have to CTRL+C to stop it and could see then it is "halted" on line 57 (for ...). Displaying data 'i' shows GDB has reached an intermediate value loop iterations before halting. (several tests : i=23468, 37406, 24028, ...) When continuing again, then it stops to the first breakpoint line 66 correctly
2. When stopped on 1st breakpoint on line 66, I seize 'next' command and can stop on each line until line 68 (2nd breakpoint : for ...). Then from line 68 the program "halts" again and GDB seems to be crashed this time I can't CTRL+C. I have to kill GDB and restart it.
3. An other test is made when reaching breakpoint on line 68. I step by assembly instruction and it works perfectly. If after several steps (i=2 or 3) I 'continue' the program, then it stops correctly to the line 66 showing that the program works and reached the 2nd forever main loop iteration.
Here are the details of the tests :
My code is :
******************************************************************
41 int main(void)
42 {
43 unsigned int i;
44
45
46 SOPT=0X53;
47
48// Turn ON/OFF PTE6/7 LEDs
49 PTFDD |= 0 | PTFDD_PTFDD0_MASK | PTFDD_PTFDD1_MASK;
50 PTFD =0xff ;
51 PTFD =0x00 ;
52
53 for (;;)
54 {
55 PTFD |= PTFD_PTFD0_MASK ;
56 PTFD &= ~PTFD_PTFD1_MASK;
57 for (i=1; i<50000; i++)
58 {
59 asm ("nop");
60 SRS=0;
61
62 }
63
64
65
66 PTFD &= ~PTFD_PTFD0_MASK;;
67 PTFD |= PTFD_PTFD1_MASK ;;
68 for (i=1; i<40000; i++){asm ("nop");};
69 }
70
71 Return 0; } //end main
******************************************************************
Then defined the target connection :
******************************************************************
(gdb) target remote | m68k-elf-sprite pe://USBMultilink m51ac128cevb
Remote debugging using | m68k-elf-sprite pe://USBMultilink m51ac128cevb
m68k-elf-sprite: Opening P&E USBMultilink port 1 (USB1 : USB-ML-12 Rev C (PE5516
318))
m68k-elf-sprite: Target reset
0x00000000 in _ftext ()
******************************************************************
I've set some breakpoints lines 66 and line 68 :
******************************************************************
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000626 in main at ../main.c:66
2 breakpoint keep y 0x0000065a in main at ../main.c:68
******************************************************************
And ran the program :
******************************************************************
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
******************************************************************
After a while nothing is happening I press CTRL+C :
******************************************************************
Program received signal SIGINT, Interrupt.
0x00000620 in main () at ../main.c:57
57 for (i=1; i<50000; i++)
(gdb) display i
1: i = 24028
******************************************************************
Several tests have shown it halts for random value of I (24028, 37406, ...)
Then I continue the execution until it stops definitely on line 68 :
******************************************************************
(gdb) c
Continuing.
Breakpoint 1, main () at ../main.c:66
66 PTFD &= ~PTFD_PTFD0_MASK;;
1: i = 50000
(gdb) next
67 PTFD |= PTFD_PTFD1_MASK ;;
1: i = 50000
(gdb) next
Breakpoint 2, main () at ../main.c:68
68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 50000
(gdb)
^C
******************************************************************
There, CTRL+C has no action, have to quit GDB and restart it.
Other test made by stepping assembly instruction when reaching breakpoint line 68 :
******************************************************************
Breakpoint 2, main () at ../main.c:68
68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 50000
(gdb) nexti
0x0000065c 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 50000
(gdb)
0x00000660 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 1
(gdb)
0x00000668 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 1
(gdb)
0x0000066e 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 1
(gdb)
0x00000672 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 1
(gdb)
0x00000662 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 1
(gdb)
0x00000664 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 1
(gdb)
0x00000668 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 2
(gdb)
0x0000066e 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 2
(gdb)
0x00000672 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 2
(gdb)
0x00000662 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 2
(gdb)
0x00000664 68 for (i=1; i<40000; i++){asm ("nop");};
1: i = 2
(gdb) c
Continuing.
Breakpoint 1, main () at ../main.c:66
66 PTFD &= ~PTFD_PTFD0_MASK;;
1: i = 50000
******************************************************************
Here the program has been executed normally and looped until line 66 (1st breakpoint)
-----Original Message-----
From: Carlos O'Donell [mailto:carlos at codesourcery.com]
Sent: vendredi 20 mai 2011 22:22
To: Stephane Franck Rey
Cc: coldfire-gnu-discuss at codesourcery.com
Subject: Re: [coldfire-gnu-discuss] GDB freeze when steping into a loop with P&E BDM
On 5/20/2011 4:16 PM, Stephane Franck Rey wrote:
Please keep the list in the CC so others can learn about the problem.
> #define SOPT (*( unsigned char *)0xFFFF9802)
> #define SOPT_COPE_MASK 128
>
> #define PTFD (*( unsigned char *)0xFFFF800A)
> #define NVFTRIM (*(unsigned char *)0x000003FE)
> #define PTFDD (*( unsigned char *)0xFFFF800B)
Should be volatile otherwise the compiler will optimize them away as
constants when -ON for N > 0.
> // Turn ON/OFF PTE6/7 LEDs
> PTFDD |= 0 | PTFDD_PTFDD0_MASK | PTFDD_PTFDD1_MASK;
> PTFD =0xff ;
> PTFD =0x00 ;
>
> for (;;) {
> PTFD |= PTFD_PTFD0_MASK ;
> PTFD&= ~PTFD_PTFD1_MASK;
> for (i=1; i<50000; i++){asm ("nop");};
>
> PTFD&= ~PTFD_PTFD0_MASK;;
> PTFD |= PTFD_PTFD1_MASK ;;
> for (i=1; i<40000; i++){asm ("nop");};
> }
Have you debugged this from the command line gdb to show it's not an IDE
problem?
Cheers,
Carlos.
--
Carlos O'Donell
Mentor Graphics / CodeSourcery
carlos at codesourcery.com
+1 (650) 331-3385 x716
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testEclipse.zip
Type: application/x-zip-compressed
Size: 952741 bytes
Desc: testEclipse.zip
URL: <http://sourcerytools.com/pipermail/coldfire-gnu-discuss/attachments/20110523/6f43c190/attachment.bin>
More information about the coldfire-gnu-discuss
mailing list