blob: 9fe8039bc602260c0d105d33dfbef98ca86b5265 [file] [log] [blame]
Damien George075d5972014-11-27 20:30:33 +00001/*
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 George075d5972014-11-27 20:30:33 +000027#include <stdio.h>
28
Damien Georgefe7d5422015-01-01 21:16:58 +000029#include "py/gc.h"
Damien George075d5972014-11-27 20:30:33 +000030#include "gccollect.h"
Paul Sokolovsky8bc3fc22016-11-06 01:30:19 +030031#include "modmachine.h"
Damien George075d5972014-11-27 20:30:33 +000032
Damien Georgea6aa35a2016-04-28 12:23:55 +010033// 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 Sokolovsky8bc3fc22016-11-06 01:30:19 +030036// esp module, pending deletion/renaming/moving elsewhere.
Damien Georgea6aa35a2016-04-28 12:23:55 +010037
Damien George075d5972014-11-27 20:30:33 +000038STATIC 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 Georgea6aa35a2016-04-28 12:23:55 +010079MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_info_obj, 0, 1, pyb_info);