Damien George | 075d597 | 2014-11-27 20:30:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the Micro Python project, http://micropython.org/ |
| 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2014 Damien P. George |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and associated documentation files (the "Software"), to deal |
| 10 | * in the Software without restriction, including without limitation the rights |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | * copies of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | * THE SOFTWARE. |
| 25 | */ |
| 26 | |
Damien George | 075d597 | 2014-11-27 20:30:33 +0000 | [diff] [blame] | 27 | #include <stdio.h> |
| 28 | |
Damien George | fe7d542 | 2015-01-01 21:16:58 +0000 | [diff] [blame] | 29 | #include "py/gc.h" |
Damien George | 075d597 | 2014-11-27 20:30:33 +0000 | [diff] [blame] | 30 | #include "gccollect.h" |
Paul Sokolovsky | 8bc3fc2 | 2016-11-06 01:30:19 +0300 | [diff] [blame] | 31 | #include "modmachine.h" |
Damien George | 075d597 | 2014-11-27 20:30:33 +0000 | [diff] [blame] | 32 | |
Damien George | a6aa35a | 2016-04-28 12:23:55 +0100 | [diff] [blame] | 33 | // The pyb module no longer exists since all functionality now appears |
| 34 | // elsewhere, in more standard places (eg time, machine modules). The |
| 35 | // only remaining function is pyb.info() which has been moved to the |
Paul Sokolovsky | 8bc3fc2 | 2016-11-06 01:30:19 +0300 | [diff] [blame] | 36 | // esp module, pending deletion/renaming/moving elsewhere. |
Damien George | a6aa35a | 2016-04-28 12:23:55 +0100 | [diff] [blame] | 37 | |
Damien George | 075d597 | 2014-11-27 20:30:33 +0000 | [diff] [blame] | 38 | STATIC mp_obj_t pyb_info(mp_uint_t n_args, const mp_obj_t *args) { |
| 39 | // print info about memory |
| 40 | { |
| 41 | printf("_text_start=%p\n", &_text_start); |
| 42 | printf("_text_end=%p\n", &_text_end); |
| 43 | printf("_irom0_text_start=%p\n", &_irom0_text_start); |
| 44 | printf("_irom0_text_end=%p\n", &_irom0_text_end); |
| 45 | printf("_data_start=%p\n", &_data_start); |
| 46 | printf("_data_end=%p\n", &_data_end); |
| 47 | printf("_rodata_start=%p\n", &_rodata_start); |
| 48 | printf("_rodata_end=%p\n", &_rodata_end); |
| 49 | printf("_bss_start=%p\n", &_bss_start); |
| 50 | printf("_bss_end=%p\n", &_bss_end); |
| 51 | printf("_heap_start=%p\n", &_heap_start); |
| 52 | printf("_heap_end=%p\n", &_heap_end); |
| 53 | } |
| 54 | |
| 55 | // qstr info |
| 56 | { |
| 57 | mp_uint_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; |
| 58 | qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); |
| 59 | printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); |
| 60 | } |
| 61 | |
| 62 | // GC info |
| 63 | { |
| 64 | gc_info_t info; |
| 65 | gc_info(&info); |
| 66 | printf("GC:\n"); |
| 67 | printf(" " UINT_FMT " total\n", info.total); |
| 68 | printf(" " UINT_FMT " : " UINT_FMT "\n", info.used, info.free); |
| 69 | printf(" 1=" UINT_FMT " 2=" UINT_FMT " m=" UINT_FMT "\n", info.num_1block, info.num_2block, info.max_block); |
| 70 | } |
| 71 | |
| 72 | if (n_args == 1) { |
| 73 | // arg given means dump gc allocation table |
| 74 | gc_dump_alloc_table(); |
| 75 | } |
| 76 | |
| 77 | return mp_const_none; |
| 78 | } |
Damien George | a6aa35a | 2016-04-28 12:23:55 +0100 | [diff] [blame] | 79 | MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_info_obj, 0, 1, pyb_info); |