prints the location of heap, stack, data and code

Dependencies:   mbed

main.cpp

Committer:
Helmut64
Date:
2015-09-20
Revision:
0:29ed9d142ea8

File content as of revision 0:29ed9d142ea8:

#include "mbed.h"

/**
 * @file    StackHeapCodeDataInfo
 * @brief   print the location of heap, stack, data and code.
 * @author  Helmut Tschemernjak
 * @version 1.0
 */
 
Serial *bs;

int main()
{
    int temp = 0;
    
    bs = new Serial(USBTX, USBRX);
    bs->baud(115200);
    
    char *p1 = new  char[4096];

    bs->printf(" main=0x%x\r\n", &main);
    bs->printf(" data=0x%x\r\n", &bs);
    bs->printf("stack=0x%x\r\n", &temp);
    bs->printf(" heap=0x%x-0x%x\r\n", p1, p1+4096);
    for(;;)
        sleep();
}