This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Total stack size and memory of a program in Keil

Is there a way to determine the total stack size available and consumed by the variables in the program?

Same for the memory i.e total available and consumed by the program? It seems there's a stack overflow or the program is accessing something beyond its limit which is resulting in garbage characters in debug print viewer.

Parents
  • As I add a few more variables in my program, suddenly I get an error ARM: *** error 65: access violation at 0xD1010BC8 : no 'read' permission.

    I suspect that's because target memory is exceeded or perhaps stack overflow occurs?!

    Didn't quite get by "..fill it with a character you recognized, and then put the stack in the memory view of the debugger, and watch the fill character get eaten away".

    You mean fill a character in the stack?

    Unfortunately I don't know alot of people who are good with this so I have to learn everything by myself

Reply
  • As I add a few more variables in my program, suddenly I get an error ARM: *** error 65: access violation at 0xD1010BC8 : no 'read' permission.

    I suspect that's because target memory is exceeded or perhaps stack overflow occurs?!

    Didn't quite get by "..fill it with a character you recognized, and then put the stack in the memory view of the debugger, and watch the fill character get eaten away".

    You mean fill a character in the stack?

    Unfortunately I don't know alot of people who are good with this so I have to learn everything by myself

Children
  • Look at what code is causing the Error! Work backward from there. Consider bisecting the additional code until you understand exactly which variable pushes you over the edge.

    Fill it with something you can recognize. Say it's 0x1000 in size, fill that space with 'C' (0x43), look at it with a viewer, and see the 'C' characters get eroded as the tide of stack usage ebbs in and out of the call trees. Remember how stacks work on this CPU, they descend downward. Stack usage here is 0x1000-0x0374

    20000000 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43   CCCCCCCCCCCCCCCC
    20000010 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43   CCCCCCCCCCCCCCCC
    20000020 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43   CCCCCCCCCCCCCCCC
    20000030 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43   CCCCCCCCCCCCCCCC
    ...
    20000350 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43   CCCCCCCCCCCCCCCC
    20000360 : 43 43 43 43 43 43 43 43 - 43 43 43 43 43 43 43 43   CCCCCCCCCCCCCCCC
    20000370 : 43 43 43 43 FE BD F7 B5 - 16 46 0D 46 00 24 FF F7   CCCC.....F.F.$..
    20000380 : A4 FF 76 4F 38 46 FF F0 - 3B FE 04 28 11 D0 FF F7   ..vO8F..;..(....
    20000390 : 71 FE 0E E0 28 5B C0 43 - 01 04 28 5B 08 43 00 99   q...([.C..([.C..
    ...
    20000FD0 : 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00   ................
    20000FE0 : 61 70 68 31 00 00 00 00 - 00 00 00 00 00 00 00 00   aph1............
    20000FF0 : 00 00 00 00 00 00 00 00 - 00 00 11 00 31 00 C0 00   ............1...
    

    If you suspect something, do some testing/analysis to prove or disprove the theory. Look at things you can inspect.