EmbeddedRelated.com
Forums
Memfault Beyond the Launch

C preprocessors in GCC-AVR & AVR studio

Started by terry August 22, 2004
Hi,

I am using GCC and AVR sudio in my MCU project. I find a big problem
when the two tools are used together.

My C program has many "#ifdef"/"#endif" instruction segments to
control different compilation options. However, when I debug the
program in AVR studio and set watch points, some locations are
misaligned so that the real position of instruction lines cannot be
really located. I knew that becaue I found that some instruction lines
cannot be set watchpoint successfully. So this brings a lot of
troubles to me.

Could anyone teach me how to solve the problem? Or I need to remove
those preprocesors?
On 2004-08-22, terry <leonlai2k@yahoo.com> wrote:

> I am using GCC and AVR sudio in my MCU project. I find a big problem > when the two tools are used together. > > My C program has many "#ifdef"/"#endif" instruction segments to > control different compilation options. However, when I debug the > program in AVR studio and set watch points, some locations are > misaligned so that the real position of instruction lines cannot be > really located. I knew that becaue I found that some instruction lines > cannot be set watchpoint successfully. So this brings a lot of > troubles to me. > > Could anyone teach me how to solve the problem? Or I need to remove > those preprocesors?
I'd be very, very surprised if the preprocessor stuff is causing problems. Most likey, you need to turn off optimization in the compiler. With optimization enabled, lines get eliminated and re-arranged. -- Grant Edwards grante Yow! Half a mind is a at terrible thing to waste! visi.com
> > I'd be very, very surprised if the preprocessor stuff is causing problems. > > Most likey, you need to turn off optimization in the compiler. With > optimization enabled, lines get eliminated and re-arranged.
I think the problem i not in the optimization. For example, if A is not defined in the following, the alignment would become wrong in b() funciton. Setting or not setting optimization cannot help. : : #ifdef A void a() { : : } #endif : : void b() { : }
"terry" <leonlai2k@yahoo.com> wrote in message
news:9904d48.0408212305.40e590dd@posting.google.com...
> Hi, > > I am using GCC and AVR sudio in my MCU project. I find a big problem > when the two tools are used together. > > My C program has many "#ifdef"/"#endif" instruction segments to > control different compilation options. However, when I debug the > program in AVR studio and set watch points, some locations are > misaligned so that the real position of instruction lines cannot be > really located. I knew that becaue I found that some instruction lines > cannot be set watchpoint successfully. So this brings a lot of > troubles to me. > > Could anyone teach me how to solve the problem? Or I need to remove > those preprocesors?
This might be an oversimplification of your problem, but you know that changing the source code after the last compilation can cause alignment problems for most source-level debuggers.

Memfault Beyond the Launch