Sep 18, 2014
02:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 18, 2014
02:51 AM
Hi,
I got a problem while debugging a program. I reduced the source code to a small sample which behaves as the big one.
Then I set up a new project ('File' -> 'new' -> 'DAVE project' -> 'DAVE CE Project' without any apps) and expanded main.c by some lines of code.
source code:
#include //Declarations from DAVE3 Code Generation (includes SFR declaration)
void func_1(void)
{
int a;
int b;
int c;
a = 4;
b = 5;
c= a * b;
if (c == c)
{
//
}
}
int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)
char aaa;
char data_str1[] = {"HELLO WORLD\n"};
char data_str2[] = {"Dies ist noch ein Teststring\n"};
DAVE_Init(); // Initialization of DAVE Apps
func_1();
// ========================================================================
// ab hier sind die Variablen data_str1 und data_str2 nicht mehr erreichbar
// ========================================================================
aaa = data_str1[3];
aaa = data_str2[5];
if(aaa == aaa)
{
//
}
while(1)
{
}
return 0;
}
A breakpoint is set and activated in main() before executing func_1(). Execution is started with F8 and stops at breakpoint.
The addresses of data_str1 and data_str2 are 0x200007e0 and 0x200007c0 (Dave_3_1_10_DebugError_a.png) After stepping through func_1 with single steps (F5) and returning to main, the addreses have changed and are out of bounds: 0x1079e100 and 0x1079e0e0 (Dave_3_1_10_DebugError_b.png)
This problem does not occur if I step over func_1 (F6).
Where is the a bug in my sample program? Or is it a bug in DAVE3?
Version of DAVE 3 is: 3.1.10, Installer build : 2014-02-26
Hardware: "XMC4500-E144x1024 AA"
Debugger: SEGGER J-Link GDB Server V4.80f
Thanks in advance
Rudi
PS At the moment I cannot upload some screenshots
I got a problem while debugging a program. I reduced the source code to a small sample which behaves as the big one.
Then I set up a new project ('File' -> 'new' -> 'DAVE project' -> 'DAVE CE Project' without any apps) and expanded main.c by some lines of code.
source code:
#include
void func_1(void)
{
int a;
int b;
int c;
a = 4;
b = 5;
c= a * b;
if (c == c)
{
//
}
}
int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)
char aaa;
char data_str1[] = {"HELLO WORLD\n"};
char data_str2[] = {"Dies ist noch ein Teststring\n"};
DAVE_Init(); // Initialization of DAVE Apps
func_1();
// ========================================================================
// ab hier sind die Variablen data_str1 und data_str2 nicht mehr erreichbar
// ========================================================================
aaa = data_str1[3];
aaa = data_str2[5];
if(aaa == aaa)
{
//
}
while(1)
{
}
return 0;
}
A breakpoint is set and activated in main() before executing func_1(). Execution is started with F8 and stops at breakpoint.
The addresses of data_str1 and data_str2 are 0x200007e0 and 0x200007c0 (Dave_3_1_10_DebugError_a.png) After stepping through func_1 with single steps (F5) and returning to main, the addreses have changed and are out of bounds: 0x1079e100 and 0x1079e0e0 (Dave_3_1_10_DebugError_b.png)
This problem does not occur if I step over func_1 (F6).
Where is the a bug in my sample program? Or is it a bug in DAVE3?
Version of DAVE 3 is: 3.1.10, Installer build : 2014-02-26
Hardware: "XMC4500-E144x1024 AA"
Debugger: SEGGER J-Link GDB Server V4.80f
Thanks in advance
Rudi
PS At the moment I cannot upload some screenshots
7 Replies
Sep 19, 2014
02:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 19, 2014
02:59 AM
Hi,
here are the pictures referred to ...
Best regards,
Rudi
here are the pictures referred to ...
Best regards,
Rudi
Not applicable
Sep 19, 2014
08:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 19, 2014
08:16 AM
You're initialising the strings wrong.
This: {"HELLO WORLD\n"};
Has the following type: const char ** const
I.e. an array of pointers to const char arrays.
This:
char data_str1[] = "HELLO WORLD\n";
Would work as expected.
This: {"HELLO WORLD\n"};
Has the following type: const char ** const
I.e. an array of pointers to const char arrays.
This:
char data_str1[] = "HELLO WORLD\n";
Would work as expected.
Sep 21, 2014
11:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 21, 2014
11:17 PM
Hi kamikaze,
nice idea, but DAVE3 is not fond of it. The address of the string is changed again.
I tried several ways to define strings and found a workaround (see data_str3):
It takes some more typing but DAVE3 does not destroy pointer to strings defined like data_str3 after single stepping subroutines.
Best regards,
Rudi
nice idea, but DAVE3 is not fond of it. The address of the string is changed again.
I tried several ways to define strings and found a workaround (see data_str3):
#include//Declarations from DAVE3 Code Generation (includes SFR declaration)
void func_1(void)
{
int a;
int b;
int c;
a = 4;
b = 5;
c= a * b;
if (c == c)
{
//
}
}
int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)
char aaa;
char data_str1[] = "HELLO WORLD\n";
const char data_str2[] = "Dies ist noch ein Teststring\n";
const char data_str3[] = {'D', 'A', 'V', 'E', '3', '\n', '\0'}; // workaround for DAVE3
const char data_str4[6] = "12345";
DAVE_Init(); // Initialization of DAVE Apps
func_1();
// =========================================================================================================
// since here variables data_str1, data_str2, data_str4 not reachable after single stepping through func_1()
// =========================================================================================================
aaa = data_str1[3];
aaa = data_str2[5];
aaa = data_str3[3];
aaa = data_str4[3];
if(aaa == aaa)
{
//
}
while(1)
{
}
return 0;
}
It takes some more typing but DAVE3 does not destroy pointer to strings defined like data_str3 after single stepping subroutines.
Best regards,
Rudi
Not applicable
Sep 22, 2014
04:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 22, 2014
04:57 AM
Did you try:
const char * const data_str4 = "12345";
That should be exactly the same as:
const char data_str4[6] = "12345";
or:
const char data_str4[] = "12345";
or:
const char data_str4[] = {'1', '2', '3', '4', '5', 0};
They should all be equivalent. If they don't, at least logically, do the same, I'd expect that to be in violation of the standard.
const char * const data_str4 = "12345";
That should be exactly the same as:
const char data_str4[6] = "12345";
or:
const char data_str4[] = "12345";
or:
const char data_str4[] = {'1', '2', '3', '4', '5', 0};
They should all be equivalent. If they don't, at least logically, do the same, I'd expect that to be in violation of the standard.
Sep 24, 2014
12:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 24, 2014
12:35 AM
Hi Rudi,
I recommend you to use iSystem debugger, then the problem will be resolved. Here is the documentation how to install iSystem in DAVE3:
http://www.infineon.com/dgdlc/en?dcId=8a8181663431cb50013431cb500b0000&downloadTitle=winIDEA_open_DA...
Alternatively, you can define the three variables as global variables like:
char aaa;
char data_str1[] = {"HELLO WORLD\n"};
char data_str2[] = {"Dies ist noch ein Teststring\n"};
int main(void)
{
}
Then, you can also user IFX GDB and Tasking debugger to step into func_1().
Best regards
Guangyu
I recommend you to use iSystem debugger, then the problem will be resolved. Here is the documentation how to install iSystem in DAVE3:
http://www.infineon.com/dgdlc/en?dcId=8a8181663431cb50013431cb500b0000&downloadTitle=winIDEA_open_DA...
Alternatively, you can define the three variables as global variables like:
char aaa;
char data_str1[] = {"HELLO WORLD\n"};
char data_str2[] = {"Dies ist noch ein Teststring\n"};
int main(void)
{
}
Then, you can also user IFX GDB and Tasking debugger to step into func_1().
Best regards
Guangyu
Not applicable
Sep 29, 2014
12:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 29, 2014
12:49 AM
Hi,
You can try to upgrade the Segger J-Link to v4.9e…
Best regards,
Sophia
You can try to upgrade the Segger J-Link to v4.9e…
Best regards,
Sophia
Oct 13, 2014
02:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 13, 2014
02:37 AM
Hi Sophia,
Update to Segger J-Link to v4.9e was helpfully. Addresses stuck as expected.
Best regards,
Rudi
Update to Segger J-Link to v4.9e was helpfully. Addresses stuck as expected.
Best regards,
Rudi