Debug to Release causes different application behavior


1 comment

  • Avatar
    Richard Webb

    You're correct that the difference in behaviour (a nod to the UK side of the pond ;-) is almost certainly a side effect of the changed memory layout in the debug as compared to the release configuration. One way to get at it would be to return to the dark ages before JTAG and add a small routine that sends dumps of suspect variables or memory locations out through a serial port*. Of course, adding such a routine alters the program image so it is necessarily not as clean as JTAG but sometimes it's all we have.

    As regards strncpy(s1, s2, n): This doesn't verify that no more than n characters are written to s1. Rather, it always writes exactly n characters to s1. If s2 is shorter than n then after copying the terminal null character from s2 it will append additional null characters to s1 until a combined total of n characters have been written. With Percent_Text an array [6] of uint8_t, an n of 10 will always write past the declared end of the array. Gimpel lint will catch this. I suspect that CrossWorks can as well, perhaps with -Wall?

    * Or SPI or GPIO, etc. I recall once debugging a PIC14 app by dumping floating point values from a single output pin and then reading them with an o'scope. It's a wonder that I'm still (mostly) sane.

    Comment actions Permalink

Please sign in to leave a comment.