Hi all,
I would like to disable any optimization of the C code. I am using the Eclipse IDE, having the CFLAGS env variable set to optimize for gdb.
It this the right approach? When debugging via JTAG, I still can see cases when I hover over a varaiable, it says "Optimized Out".
Thanks and best regards
Patrick
Disable optimization (optimize for JTAG debugging)
Disable optimization (optimize for JTAG debugging)
- Attachments
-
- eclipse-disableOptimization.png (59.64 KiB) Viewed 8817 times
-
- Posts: 33
- Joined: Wed Mar 28, 2018 6:58 am
Re: Disable optimization (optimize for JTAG debugging)
Hello I'm looking for the same stuff here. How am i supposed to disable the compiler optimization ? I've checked sdkconfig file and it seems that there are only 2 options as mentions in the "readthedocs" website. -Og (debug) and -Os (release).
The reason why I want to disable the optimization is because when I'm debugging my code some of my variable's values are characterized as "<optimized out>" and I can't see the vale of this variable. I do not know all stuff about a compiler but with some research in the web I've found out that I should turn off compiler's optimization.
The reason why I want to disable the optimization is because when I'm debugging my code some of my variable's values are characterized as "<optimized out>" and I can't see the vale of this variable. I do not know all stuff about a compiler but with some research in the web I've found out that I should turn off compiler's optimization.
- Attachments
-
- optimized_out_variables.jpg (10.89 KiB) Viewed 8396 times
- PaulVdBergh
- Posts: 58
- Joined: Fri Feb 23, 2018 4:45 pm
- Location: Brasschaat, Belgium
Re: Disable optimization (optimize for JTAG debugging)
My guess is the compiler put these variables in registers, so they are optimized away. Try to make them volatile ?
Paul.
Paul.
-
- Posts: 33
- Joined: Wed Mar 28, 2018 6:58 am
Re: Disable optimization (optimize for JTAG debugging)
Dear Paul, thank you for your reply.
Firstly I would like to describe my situation. I'm inside a module's function which is started as a Task from main.
I've used my breakpoint right in the begging of the task and I've also set-up the expressions that I want to watch (test var).
Case 1. Variable declared inside func(local var) the compiler optimizes the value of the variable and I can not see it's contents.
Case 2. Variable declared volatile inside func( volatile uint8_t test = 0;) -> variable's value becomes unavailiable.(attached img)
Case 3. Declare the variable global (tested both volatile and non-volatile declaration)-> It works like a charm.
What am I supposed to do ?! I want to avoid declaring my variables as global :-/ It was quite hard for me to get used to using local variables that I don't want to go back to using globals.
Regards, Kostas.
Firstly I would like to describe my situation. I'm inside a module's function which is started as a Task from main.
I've used my breakpoint right in the begging of the task and I've also set-up the expressions that I want to watch (test var).
Case 1. Variable declared inside func(local var) the compiler optimizes the value of the variable and I can not see it's contents.
Case 2. Variable declared volatile inside func( volatile uint8_t test = 0;) -> variable's value becomes unavailiable.(attached img)
Case 3. Declare the variable global (tested both volatile and non-volatile declaration)-> It works like a charm.
What am I supposed to do ?! I want to avoid declaring my variables as global :-/ It was quite hard for me to get used to using local variables that I don't want to go back to using globals.
Regards, Kostas.
- Attachments
-
- optimized_out_variables02.jpg (9.48 KiB) Viewed 8382 times
- PaulVdBergh
- Posts: 58
- Joined: Fri Feb 23, 2018 4:45 pm
- Location: Brasschaat, Belgium
Re: Disable optimization (optimize for JTAG debugging)
Hi Kostas,
If it's only to observe the value of some variables, why not use any kind of the printf or LOGx() functions? It's only for debugging, isn't it? Keep in mind that making a varaible global or static whitin a function makes the function non-reenrtant.
Paul
If it's only to observe the value of some variables, why not use any kind of the printf or LOGx() functions? It's only for debugging, isn't it? Keep in mind that making a varaible global or static whitin a function makes the function non-reenrtant.
Paul
-
- Posts: 33
- Joined: Wed Mar 28, 2018 6:58 am
Re: Disable optimization (optimize for JTAG debugging)
Thank you for your reply. I'll keep this in mind !!
I've used printf in order to read the optimized variable.
Best regards, Kostas.
I've used printf in order to read the optimized variable.
Best regards, Kostas.
Who is online
Users browsing this forum: gomez9656, Majestic-12 [Bot], tahseenabbas52 and 60 guests