Skip to content

Commit 914bcf1

Browse files
committed
unix: Add poorman's stack usage info to mem_info() dump.
1 parent b30a777 commit 914bcf1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

unix/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ long heap_size = 128*1024 * (sizeof(machine_uint_t) / 4);
6363
#endif
6464

6565
// Stack top at the start of program
66-
void *stack_top;
66+
char *stack_top;
6767

6868
void microsocket_init();
6969
void time_init();
@@ -212,7 +212,10 @@ int usage(char **argv) {
212212
}
213213

214214
mp_obj_t mem_info(void) {
215-
printf("mem: total=%d, current=%d, peak=%d\n", m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
215+
volatile int stack_dummy;
216+
printf("mem: total=%d, current=%d, peak=%d\n",
217+
m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
218+
printf("stack: %d\n", stack_top - (char*)&stack_dummy);
216219
#if MICROPY_ENABLE_GC
217220
gc_dump_info();
218221
#endif
@@ -258,7 +261,7 @@ void pre_process_options(int argc, char **argv) {
258261

259262
int main(int argc, char **argv) {
260263
volatile int stack_dummy;
261-
stack_top = (void*)&stack_dummy;
264+
stack_top = (char*)&stack_dummy;
262265

263266
pre_process_options(argc, argv);
264267

0 commit comments

Comments
 (0)