Breakpoints in debugger

Beta Testing discussion on mikroC PRO for AVR.
Post Reply
Author
Message
sadavis80
Posts: 114
Joined: 15 Nov 2008 19:27

Breakpoints in debugger

#1 Post by sadavis80 » 19 Nov 2008 06:02

After running through my code for about the 50th time, I've decided that there *IS* a problem with breakpoints. I can't identify what it is, but I set breakpoints on a (legitimate) line and the debugger sometimes stops somewhere else - most likely where a breakpoint was previously set, but the screen no longer indicates it. Furthermore, when it stops at that other place, no matter what I do, the debugger is essentially dead after that until I kill it, recompile, clear ALL breakpoints, recompile again, reset my breakpoint(s) and restart.

Attempting to add or delete a breakpoint while 'running' is also "not productive" - although the screen indicates that things have happened as I would expect, the debugger has other ideas and is essentially DEAD.

Hopefully, it will get better with time ... time is something I'm wasting a *LOT* of, trying to figure this all out and get my program working :(.

On edit - I noticed something else. I really LIKE 'Code Folding' - however, if I have a break point set, and then fold up some code, the breakpoint stays in the same POSITION ON THE SCREEN where it was - it doesn't go with the LINE it was on, but rather with the screen POSITION ... doesn't seem good to me since I then end up with BP's where I don't want them .. then have to clear the BP's, then recompile, etc.

Hope I'm not aggravating you with all these ... :)

Steve

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Breakpoints in debugger

#2 Post by zristic » 19 Nov 2008 09:34

Hi Steve,

We really appreciate any bug reported by our users. Moreover, we encourage our users to report as many problems as possible. Therefore, keep on reporting, it will make the compiler better.

Concerning the problem, Code Folding feature is a rather new invention of ours. It is a very complicated to be implemented and therefore to be tested. We have brought it to a final state, but some problems still remained, such as those you discovered. I have added the bug report to our bug list and it shall be solved in some of the future releases.

Thanks again.

User avatar
milan
mikroElektronika team
Posts: 1013
Joined: 04 May 2006 16:36
Contact:

Re: Breakpoints in debugger

#3 Post by milan » 22 Nov 2008 08:46

Hi Steve,
sadavis80 wrote:After running through my code for about the 50th time, I've decided that there *IS* a problem with breakpoints. I can't identify what it is, but I set breakpoints on a (legitimate) line and the debugger sometimes stops somewhere else - most likely where a breakpoint was previously set, but the screen no longer indicates it. Furthermore, when it stops at that other place, no matter what I do, the debugger is essentially dead after that until I kill it, recompile, clear ALL breakpoints, recompile again, reset my breakpoint(s) and restart.

Attempting to add or delete a breakpoint while 'running' is also "not productive" - although the screen indicates that things have happened as I would expect, the debugger has other ideas and is essentially DEAD.

Hopefully, it will get better with time ... time is something I'm wasting a *LOT* of, trying to figure this all out and get my program working :(.
Is this part of your breakpoints problem report including code folding ?

If not, then we would like to reproduce it without code folding involved.
We are planing to solve breakpoint reports first, and after that to deal with code folding.

Please post the simple code and step-by-step explanation how
to reproduce the breakpoints problems.

Thank you for testing our compiler and posting error reports.

sadavis80
Posts: 114
Joined: 15 Nov 2008 19:27

Breakpoints in debugger - add 'Save Project As' problem

#4 Post by sadavis80 » 22 Nov 2008 16:03

If I use 'Save Project As', what I am expecting is that the IDE will save the project under a new name - so that 'Project1.mcpav' that I'm working, which includes T1.c and T2.c would be saved under a new name 'Project2.mcpav' and optionally let me rename each of the included .c files. No other files would be needed (to be copied) for the new project. (I find this while trying to create small parts of my major file to simply duplicate problems I list here in the forum).

What HAPPENS, is the IDE goes to the new directory that I specify in the 'Save As' window and copies *EVERYTHING* that EXISTS in the original directory to the new directory and does NOT rename the .mcpav file. When I say EVERYTHING, I mean ALL project associated files - including all output files from the compiler and ALL subdirectories that I might have created in the past (like a backup dir) no matter whether they are related to the project or not. I could fill up a harddrive pretty fast that way :). If I don't change directories, then the IDE creates new files with the same name - calling them 'copy of..filename'. It also loads any source files created back into the IDE along with the original files, but if 'copy of' was added to the filename, it is NOT reflected on the IDE tab - I have no way of knowing which is the new/old files. It becomes a big mess quickly. I also have to go CLOSE PROJECT and go outside the IDE (Win Explorer) to rename all the files that I want and then delete all the other files.

This points out another small issue - we need an explanation of all those files created by the IDE as to what they do. Most are obvious, but some like '.dct' and '.user.dic' are not so.

Now - on to the bp problem.
I'll show code at the bottom of this message. (still a bit of junk left from full project)
Create new project and include code shown below.
Compile
Set BP on line 111. (PORTL0 = 0 ; )
Hit F9 .. then F6 - note code stops on Line 111.
Hit Ctrl F2 to kill debugger
Use editor to insert 2 blank lines above 111 - BP now shows in editor as being on line 113.
Hit F9 ... F6
Editor stops on (blank) line 111 - where the BP USED to be.
Hit Ctrl F2.. stop debugger ... then Ctrl F9 to recompile. (BP still showing on Line 113).
Hit F9 .. F6
WHERE DID DEBUGGER GO?? (on edit - I think it's running that 50000 count loop now) Watch window shows cycles and time passing, but no idea where or what debugger is doing ... (this will go on a LONG time - no idea if it will EVER stop).
Hit Ctrl F2 to kill debugger.
Click on line 113 'x' to delete BP on that line (note that BP gone from editor, but menu icon for 'Delete all Breakpoints' is still active. Note - if you 'show all BP' you will see BP's listed for both lines 111 and 113 - and NO BP's showing in editor.)
Hit Ctrl F2 again - no change
Hit Ctrl F9 (note that 'green arrow' is still showing in editor at line 113.
Hit F9... F6 - debugger goes off to see wizard again...
Hit Ctrl F2 then ... Oops - somewhere along the way, green arrow moved to line 115 (I think I moved the line CURSOR to there on last iteration).
Now, 'Delete all BP's' is grayed out, but 'Show All BP's still shows BP's on lines 111 and 113.... and suddenly 'Delete All BP's' is active again.
Hit Delete All BP's - show all window clears.
Hit Ctrl F9 (green arrow is still showing on line 115 - recompile for good measure)
Hit F9... F6.
Program now running in debugger with no BP's. Click to activate BP on line 113 again and debugger stops where it should.
Kill BP and *NOW* debugger is ready to run again with a new BP.

Code: Select all

/*
 * Project name:
     BreakPoint test
 * Copyright:
     (c) Antenna Authority, Inc, 2008.
     Engineer - Stevan A. Davis
 * Revision History:
     11/22/2008:
       - initial release;
 * Description:
     This code demonstrates erratic behavior of BP's in the IDE.
 * Test configuration:
     MCU:             ATmega1280
     Dev.Board:       BigAVR
     Oscillator:      Crystal Clock 10.0000 MHz
     Ext. Modules:    -
     SW:              mikroC PRO for AVR
 * NOTES:
*/
#define BYTE unsigned char
#define WORD unsigned int
const double PI = 3.14159;

unsigned int c2;
BYTE c1, t;
//unsigned char nib;


BYTE ADR;
unsigned int Bng[256]; // 0..255
BYTE DacVolts[256 + 64];  // 0..255 (360) + 0..63 (90)


#define FOSC 10000000// Clock Speed
#define BAUD 9600
#define MYUBRR FOSC/16/BAUD-1
void USART0_Init(unsigned int ubrr){
/* Set baud rate */
UBRR0H = (ubrr>>8);
UBRR0L = ubrr;
/* Enable transmitter */
TXEN0 = 1; // TX only
/* Set frame format: 8data, 2stop bit */
USBS0 = 0;  // 1 stop
UCSZ02 = 0; UCSZ00 = 1; UCSZ01 = 1; // 8 bit data
UPM01 = 0; UPM00 = 0; // no parity
UMSEL00 = 0; UMSEL01 = 0; // async
} // USART_Init


void main() {
// use Timer1 COMA interrupt for DAC/RSF service routine
// use Timer1 output COMA for ~12.5 kHz for digital filters
// use External interrupt for ZeroCrossing detector (not implemented yet)
unsigned int cntr;
// strings for writing to sLCD
BYTE sclr[] = {'\xfe', '\1', '\0'};
BYTE sl1[] = {'\xfe', '\x80', '\0'};
BYTE sl2[] = {'\xfe', '\xc0', '\0'};
BYTE sl3[] = {'\xfe', '\x94', '\0'};
BYTE sl4[] = {'\xfe', '\xd4', '\0'};

BYTE st[] = "Test 1 2 3";
sfr unsigned char rx sptr, eptr; <- If you use this, you won't see it in debugger!
//BYTE sptr, eptr;
char s[41];
//#define test

  DDRA   =  0xFF;               // set PORTA as output
  PORTA  =  255;                  // set PORTA
  DDRB   =  0xFF;               // set PORTB as output
  PORTB  =  0xc2;                  // clear PORTB
  DDRC   =  0x0;               // set PORTC as input for temp use of buttons
  PORTC  =  255;                  // set PORTC (sets pull-up active for now)
  DDRJ   = 0xff;
  PORTJ  = 0;
  DDRK   = 0xff;
  PORTK  = 0;
  DDRL   = 0xff;
  PORTL  = 0;

  TCCR1A = 0b01000000;                   // OCOA and PWM disabled
  TCCR1B = 0b00001011;           // add CTC on 1A (chg ISV above to 0x22)
  OCR1AH = 0x00;                 //set compare match registers to 0c to be visible
  OCR1AL = 5;
  // disable interrupt for this BP test since I didn't include the ISR
//  OCIE1A = 1;                     // Timer1 Output Compare Match interrupt enabled
// should also be putting out a square wave on OC1A = PB5
// duplicate Timer1 stuff on Timer 4
  TCCR4A = 0b01000000;                   // OCOA and PWM disabled
  TCCR4B = 0b00001011;           // add CTC on 4A
  OCR4AH = 0x00;                 //set compare match registers to 0c to be visible
  OCR4AL = 5;
  DDRH.B3 = 1;                   // set OC4A for output (PH3)
//  OCIE4A = 1;                     // Timer4 Output Compare Match interrupt enabled
// should be putting out a square wave on OC1A = PH3
  USART0_Init(FOSC/16/BAUD-1);  // set up USART0 for output only at 9600 baud
// skip this too  SREG_I = 1;                   // Global Interrupt enable
    PORTB6 = 0;
  sptr = eptr = 0;
  while (1) {     // Endless loop, port is changed inside Interrupt Service Routine (ISR)
    PORTJ = UCSR0A; // show status of USART Control and Status Reg A
    PORTK = UCSR0B; // show status of USART Control and Status Reg A
    PORTA = ~PORTA; // toggle bits so I can tell loop is running
      if (eptr > sptr) {
        PORTL0 = 1;    // show that I have something to write
        if (UDRE0) {
          PORTB6 = 1;  // show that TDR is available
          UDR0 = (s[sptr]);
          sptr += 1;
          PORTB6 = 0;
          }
      } else {
      PORTL0 = 0;
      if (cntr < 50000) {  // insert delay to keep from multiple calls on same btn press
        cntr += 1; // delay
      } else
      if (PINC0 == 1) {    // clear screen
        strcpy(s, sclr);
        eptr = strlen(s);
        sptr = 0;
        cntr = 0;
      } else
      if (PINC1 == 1) {    // test message on Line 1
        strcpy(s, sl1);
        strcat(s, st);
        eptr = strlen(s);
        sptr = 0;
        cntr = 0;
        PORTL1 = 1;
      } else
      if (PINC2 == 1) {    // test message on Line 2
        strcpy(s, sl2);
        strcat(s, st);
        eptr = strlen(s);
        sptr = 0;
        cntr = 0;
        PORTL2 = 1;
      } else
      if (PINC3 == 1) {    // test message on Line 3
        strcpy(s, sl3);
        strcat(s, st);
        eptr = strlen(s);
        sptr = 0;

        cntr = 0;
      } else
      if (PINC4 == 1) {    // test message on Line 4
        strcpy(s, sl4);
        strcat(s, st);
        eptr = strlen(s);
        sptr = 0;
        cntr = 0;
      }

    }
  }
}
#ifdef test
    nib = PORTB & 0x0f; // low mibble
    nib = ~nib & 0x0f;
    nib = (PORTB & 0xF0) | nib;
    PORTB =  nib;    // toggle PORTB low nibble
#endif
Steve

User avatar
milan
mikroElektronika team
Posts: 1013
Joined: 04 May 2006 16:36
Contact:

#5 Post by milan » 24 Nov 2008 10:15

Hi Steve,

I reproduced Breakpoints problem.
It is reported to our IDE developers, and they will check it.

Just one note, it is very hard for us to debug the compiler with large user code,
it has preprocessor directives, structures, functions, variables and we must check everything, to see if it is connected to the error.

To avoid this we are making the smallest possible codes for bug reports, I transformed your code to this:

Code: Select all

void main() {


  PORTB = 1;
  PORTB = 2;  // Insert two lines before this line
  PORTB = 3;
  
  
}
This small code shows the same error with breakpoints.
We prefer small projects for bug reports :wink: I hope you understand.
SmartADAPT2 rules !

sadavis80
Posts: 114
Joined: 15 Nov 2008 19:27

#6 Post by sadavis80 » 24 Nov 2008 15:17

OK - I'll work on that :).
Steve

Post Reply

Return to “mikroC PRO for AVR Beta Testing”