View previous topic :: View next topic |
Author |
Message |
dclavette
Joined: 22 Apr 2019 Posts: 3
|
can_fifo_getd.data appearing in symbol file, not called |
Posted: Mon Apr 22, 2019 3:14 pm |
|
|
Hi All,
First post. I have been tracking down a bug and could use some help to see if others have ever experienced this.
I found an instance where a variable keeping track of my currentTime was smaller than a variable keeping track of a variable keeping track of my lastUpdateTime, i.e the last time this function was completed.
It was concluded that currentTime was overwritten with a smaller value since, at the end of the function, lastUpdateTime was set to currentTime.
Specifically, the last two bytes were changed. Looking in my symbol file I found that the the last two bytes of currentTime, declared in main (and therefore is never out of scope) shares it's lower two bytes with the variables can_fifo_getd.data and can2_fifo_getd.data.
We do not use these functions - can_fifo_getd or can2_fifo_getd. We do, however, use can_getd and can2_getd.
Using compiler version v5.061 using device DSPIC33FJ128GP706A.
Thank you! |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1358
|
|
Posted: Mon Apr 22, 2019 3:50 pm |
|
|
You might check the ROM portion of the SYM file and see if those two functions also appear there. If so, then something in your code is making them seem like they are being used somewhere.
One potential reason is if you are using function pointers and you take the address to those functions anywhere. You might additionally check and see if any precompiler directives are in play such as #ORG.
As an example:
Code: |
#ORG 0x1000, 0x10FF
void Do_Something(){
unsigned int8 var;
}
void main(void)
{
}
|
gives the following symbol table for me:
Code: |
W0 @SCRATCH
W0L _RETURN_
W0 -W1 @READ_ROM_MEMORY.P1
W0 -W1 @DIV3232B.P2
W0 @delay_ms1.P3
W0 @delay_us1.P4
W1 @SCRATCH
W1 @READ_PACKED_MEMORY.P1
W1 @WRITE_PACKED_MEMORY.P2
W2 @READ_ROM_MEMORY.P1
W2 -W3 @DIV3232B.P2
W2 @WRITE_PACKED_MEMORY.P3
W2 -W3 @SPI_XFER_1.P4
W2 @READ_PACKED_MEMORY.P5
W3 @READ_ROM_MEMORY.P1
W3 @WRITE_PACKED_MEMORY.P2
W3 @READ_PACKED_MEMORY.P3
W4 @SPI_XFER_1.P1
W5 @SPI_XFER_1.P1
630.6 C1OUT
630.7 C2OUT
800-801 rs232_errors
802 Do_Something.var
2780-2781 _STACK_
ROM Allocation:
000200 MAIN
000200 @cinit1
000246 @cinit2
001000 Do_Something
|
|
|
|
dclavette
Joined: 22 Apr 2019 Posts: 3
|
|
Posted: Mon Apr 22, 2019 4:12 pm |
|
|
jeremiah,
I have checked, those functions (can_fifo_putd and can2_fifo_putd) are not in ROM. Additionally, I am not using any #ORG directives.
Thanks for the suggestions. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1358
|
|
Posted: Mon Apr 22, 2019 6:24 pm |
|
|
Given that you cannot provide us a small compilable example of the problem and the description thus far, I would suggest contacting CCS support and suggest it as a possible bug. If the variables are showing up in the sym table but the functions are not, that is odd. |
|
|
dclavette
Joined: 22 Apr 2019 Posts: 3
|
|
Posted: Mon Apr 22, 2019 7:00 pm |
|
|
jeremiah - here is a small, compilable example.
Code: |
#include <main.h>
#include <can-pic24.c>
#define GET_SYS_TIME(x) currentTime = currentTime + 1;
void doSomeThing(int64_t currentTime)
{
static int64_t lastUpdateTime;
if (currentTime >= lastUpdateTime + 10) {
// Do the task!
lastUpdateTime = currentTime;
}
return;
}
void main()
{
int64_t currentTime;
while(TRUE)
{
GET_SYS_TIME(currentTime);
doSomeThing(currentTime);
}
}
|
Which creates the following symbol file
Code: |
W0 @SCRATCH
W0L _RETURN_
W0 -W1 @READ_ROM_MEMORY.P1
W0 -W1 @DIV3232B.P2
W0 @delay_ms1.P3
W0 @delay_us1.P4
W1 @SCRATCH
W1 @WRITE_PACKED_MEMORY.P1
W1 @READ_PACKED_MEMORY.P2
W2 @WRITE_PACKED_MEMORY.P1
W2 -W3 @DIV3232B.P2
W2 @READ_ROM_MEMORY.P3
W2 @READ_PACKED_MEMORY.P4
W3 @WRITE_PACKED_MEMORY.P1
W3 @READ_PACKED_MEMORY.P2
W3 @READ_ROM_MEMORY.P3
400-401 C1CTRL1
402-403 C1CTRL2
404-405 C1VEC
406-407 C1FCTRL
408-409 C1FIFO
40A-40B C1INTF
40C-40D C1INTE
40E-40F C1EC
410-411 C1CFG1
412-413 C1CFG2
414 C1FEN1
418-419 C1FMSKSEL1
41A-41B C1FMSKSEL2
420-421 C1BUFPNT1
420-421 C1RXFUL1
422-423 C1RXFUL2
422-423 C1BUFPNT2
424-425 C1BUFPNT3
426-427 C1BUFPNT4
428-429 C1RXOVF1
42A-42B C1RXOVF2
430 C1RXM0SID
430-431 C1TR01CON
432-433 C1TR23CON
432 C1RXM0
434-435 C1TR45CON
434 C1RXM1SID
436 C1RXM2
436-437 C1TR67CON
436 C1RXM1
438 C1RXM2SID
440 C1RXD
440 C1RXF0SID
442 C1TXD
442 C1RXF0
444 C1RXF1SID
446 C1RXF1
448 C1RXF2SID
44A C1RXF2
44C C1RXF3SID
44E C1RXF3
450 C1RXF4SID
452 C1RXF4
454 C1RXF5SID
456 C1RXF5
458 C1RXF6SID
45A C1RXF6
45C C1RXF7SID
45E C1RXF7
460 C1RXF8SID
462 C1RXF8
464 C1RXF9SID
466 C1RXF9
468 C1RXF10SID
46A C1RXF10
46C C1RXF11SID
46E C1RXF11
470 C1RXF12SID
472 C1RXF12
474 C1RXF13SID
476 C1RXF13
478 C1RXF14SID
47A C1RXF14
47C C1RXF15SID
47E C1RXF15
500-501 C2CTRL1
502-503 C2CTRL2
504-505 C2VEC
506-507 C2FCTRL
508-509 C2FIFO
50A-50B C2INTF
50C-50D C2INTE
50E-50F C2EC
510-511 C2CFG1
512-513 C2CFG2
514 C2FEN1
518-519 C2FMSKSEL1
51A-51B C2FMSKSEL2
520-521 C2RXFUL1
520-521 C2BUFPNT1
522-523 C2BUFPNT2
522-523 C2RXFUL2
524-525 C2BUFPNT3
526-527 C2BUFPNT4
528-529 C2RXOVF1
52A-52B C2RXOVF2
530 C2RXM0SID
530-531 C2TR01CON
532 C2RXM0
532-533 C2TR23CON
534-535 C2TR45CON
534 C2RXM1SID
536 C2RXM1
536-537 C2TR67CON
538 C2RXM2SID
53A C2RXM2
540 C2RXD
540 C2RXF0SID
542 C2RXF0
542 C2TXD
544 C2RXF1SID
546 C2RXF1
548 C2RXF2SID
54A C2RXF2
54C C2RXF3SID
54E C2RXF3
550 C2RXF4SID
552 C2RXF4
554 C2RXF5SID
556 C2RXF5
558 C2RXF6SID
55A C2RXF6
55C C2RXF7SID
55E C2RXF7
560 C2RXF8SID
562 C2RXF8
564 C2RXF9SID
566 C2RXF9
568 C2RXF10SID
56A C2RXF10
56C C2RXF11SID
56E C2RXF11
570 C2RXF12SID
572 C2RXF12
574 C2RXF13SID
576 C2RXF13
578 C2RXF14SID
57A C2RXF14
57C C2RXF15SID
57E C2RXF15
800 curmode
802-809 doSomeThing.lastUpdateTime
80A-811 MAIN.currentTime
80A-80B can2_getd.data
80A-80B can2_fifo_getd.data
80A-80B can_fifo_getd.data
80A-80B can_getd.data
80C.0 can2_getd.temp
80C.0 can_fifo_getd.temp
80C.0 can_getd.temp
80C.0 can2_fifo_getd.temp
80E-80F can_getd.i
80E-80F can2_fifo_getd.i
80E-80F can_fifo_getd.i
80E-80F can2_getd.i
810-811 can_fifo_getd.temp1
810-811 can2_getd.ptr
810-811 can2_fifo_getd.temp1
810-811 can_getd.ptr
812-813 can_fifo_getd.ptr
812-819 doSomeThing.currentTime
812-813 can2_fifo_getd.ptr
3F80-3FFF Stack
4000-41FF ecan1_message_buffer
4200-43FF ecan2_message_buffer
ROM Allocation:
000200 doSomeThing
000240 @cinit1
000240 MAIN
000252 @cinit2
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Tue Apr 23, 2019 12:34 am |
|
|
That _isn't_ your problem.....
It is putting the local variable there, because it is not used.
The compiler knows it can place a variable in the same memory, provided
it is not used by one function inside the other. It has the declarations
for the fifo functions, and merrily says 'not used inside main', so I can
put them into the same memory space.
If you called the can_fifo_putd function from anywhere at all, it'd
immediately relocate the variable elsewhere.
So if I modify your example and call can_fifo_putd. it immediately
changes the symbol file to:
Code: |
80C MAIN.len
80C-80D can2_getd.data
80C-80D can2_fifo_getd.data
80C-80D can_getd.data
80E.0 can_getd.temp
80E.0 can2_fifo_getd.temp
80E.0 can2_getd.temp
80E-815 MAIN.currentTime
80E.1 can2_fifo_getd.done
810-811 can2_fifo_getd.i
810-811 can2_getd.i
810-811 can_getd.i
812-813 can2_getd.ptr
812-813 can2_fifo_getd.BUFFER
812-813 can_getd.ptr
814-815 can2_fifo_getd.rxful1
816-817 can2_fifo_getd.rxful2
816-819 MAIN.id
|
As you can see it has immediately realised the variable is used, and moved
it so there is not a conflict.
Since it is not being used, this is not the issue. Honestly the most
likely problem is that something in your code is accessing using a
pointer, and overwriting the variable....
Because the function is declared, it's variables _will_ appear in the symbol
file. However the rules to ensure that variables don't overlap, will not
be applied, until the variables are actually used.
In your case, the fifo_putd function is 'not in ROM', so it _can't_ be
changing the variable. Has to be something else.... |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1358
|
|
Posted: Tue Apr 23, 2019 9:30 am |
|
|
dclavette wrote: | jeremiah - here is a small, compilable example.
Code: |
#include <main.h>
#include <can-pic24.c>
#define GET_SYS_TIME(x) currentTime = currentTime + 1;
void doSomeThing(int64_t currentTime)
{
static int64_t lastUpdateTime;
if (currentTime >= lastUpdateTime + 10) {
// Do the task!
lastUpdateTime = currentTime;
}
return;
}
void main()
{
int64_t currentTime;
while(TRUE)
{
GET_SYS_TIME(currentTime);
doSomeThing(currentTime);
}
}
|
|
This example shows that you are indeed using the function doSomething. You are calling it in main() It even shows up in the ROM in your symbol table:
Quote: |
Code: |
ROM Allocation:
000200 doSomeThing
000240 @cinit1
000240 MAIN
000252 @cinit2
|
|
Take a look at Ttelmah's post. He gave a good discourse on your most likely problem. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19587
|
|
Posted: Wed Apr 24, 2019 7:04 am |
|
|
As a comment, I note that you are using an int64 for 'time'. This means
you must be using a third party 'time' library, since the CCS functions
only use int32. Are you very sure there isn't an issue in this?. What
does it use as it's base time?. |
|
|
|