Helmut Tschemernjak
/
StackHeapCodeDataInfo
prints the location of heap, stack, data and code
main.cpp@0:29ed9d142ea8, 2015-09-20 (annotated)
- Committer:
- Helmut64
- Date:
- Sun Sep 20 08:54:32 2015 +0000
- Revision:
- 0:29ed9d142ea8
Initial checkin of stack/data/heap testing app
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Helmut64 | 0:29ed9d142ea8 | 1 | #include "mbed.h" |
Helmut64 | 0:29ed9d142ea8 | 2 | |
Helmut64 | 0:29ed9d142ea8 | 3 | /** |
Helmut64 | 0:29ed9d142ea8 | 4 | * @file StackHeapCodeDataInfo |
Helmut64 | 0:29ed9d142ea8 | 5 | * @brief print the location of heap, stack, data and code. |
Helmut64 | 0:29ed9d142ea8 | 6 | * @author Helmut Tschemernjak |
Helmut64 | 0:29ed9d142ea8 | 7 | * @version 1.0 |
Helmut64 | 0:29ed9d142ea8 | 8 | */ |
Helmut64 | 0:29ed9d142ea8 | 9 | |
Helmut64 | 0:29ed9d142ea8 | 10 | Serial *bs; |
Helmut64 | 0:29ed9d142ea8 | 11 | |
Helmut64 | 0:29ed9d142ea8 | 12 | int main() |
Helmut64 | 0:29ed9d142ea8 | 13 | { |
Helmut64 | 0:29ed9d142ea8 | 14 | int temp = 0; |
Helmut64 | 0:29ed9d142ea8 | 15 | |
Helmut64 | 0:29ed9d142ea8 | 16 | bs = new Serial(USBTX, USBRX); |
Helmut64 | 0:29ed9d142ea8 | 17 | bs->baud(115200); |
Helmut64 | 0:29ed9d142ea8 | 18 | |
Helmut64 | 0:29ed9d142ea8 | 19 | char *p1 = new char[4096]; |
Helmut64 | 0:29ed9d142ea8 | 20 | |
Helmut64 | 0:29ed9d142ea8 | 21 | bs->printf(" main=0x%x\r\n", &main); |
Helmut64 | 0:29ed9d142ea8 | 22 | bs->printf(" data=0x%x\r\n", &bs); |
Helmut64 | 0:29ed9d142ea8 | 23 | bs->printf("stack=0x%x\r\n", &temp); |
Helmut64 | 0:29ed9d142ea8 | 24 | bs->printf(" heap=0x%x-0x%x\r\n", p1, p1+4096); |
Helmut64 | 0:29ed9d142ea8 | 25 | for(;;) |
Helmut64 | 0:29ed9d142ea8 | 26 | sleep(); |
Helmut64 | 0:29ed9d142ea8 | 27 | } |
Helmut64 | 0:29ed9d142ea8 | 28 |