Skip to content

Commit 3ea90db

Browse files
authored
Merge pull request #5263 from jepler/printf-0xp
Include leading 0x on addresses printed with %p
2 parents 8fbb3e6 + 558f9cd commit 3ea90db

File tree

9 files changed

+19
-15
lines changed

9 files changed

+19
-15
lines changed

ports/unix/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ ifeq ($(HASCPP17), 1)
213213
else
214214
CXXFLAGS += -std=c++11
215215
endif
216-
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99,$(CFLAGS) $(CXXFLAGS_MOD))
216+
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99 -std=gnu11,$(CFLAGS) $(CXXFLAGS_MOD))
217217

218218
ifeq ($(MICROPY_FORCE_32BIT),1)
219219
RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc -march=x86'

ports/unix/variants/coverage/mpconfigvariant.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ FROZEN_DIR=variants/coverage/frzstr
2222
FROZEN_MPY_DIR=variants/coverage/frzmpy
2323

2424
SRC_QRIO := $(patsubst ../../%,%,$(wildcard ../../shared-bindings/qrio/*.c ../../shared-module/qrio/*.c ../../lib/quirc/lib/*.c))
25-
$(info SRC_QRIO = $(SRC_QRIO))
2625
SRC_C += $(SRC_QRIO)
2726

2827
CFLAGS += -DCIRCUITPY_QRIO=1

py/mkrules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ vpath %.cpp . $(TOP) $(USER_C_MODULES)
6565
$(BUILD)/%.o: %.cpp
6666
$(call compile_cxx)
6767

68-
QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR
68+
QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR -x c
6969

7070
# frozen.c and frozen_mpy.c are created in $(BUILD), so use our rule
7171
# for those as well.

py/mpprint.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,12 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
545545
case 'p':
546546
case 'P': // don't bother to handle upcase for 'P'
547547
// Use unsigned long int to work on both ILP32 and LP64 systems
548-
chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags, fill, width);
548+
#if SUPPORT_INT_BASE_PREFIX
549+
chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags | PF_FLAG_SHOW_PREFIX, fill, width);
550+
#else
551+
print->print_strn(print->data, "0x", 2);
552+
chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags, fill, width) + 2;
553+
#endif
549554
break;
550555
#if MICROPY_PY_BUILTINS_FLOAT
551556
case 'e':

py/objfun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
182182
STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
183183
(void)kind;
184184
mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(o_in);
185-
mp_printf(print, "<function %q at 0x%p>", mp_obj_fun_get_name(o_in), o);
185+
mp_printf(print, "<function %q at %p>", mp_obj_fun_get_name(o_in), o);
186186
}
187187
#endif
188188

py/profile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ STATIC void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
6868
const mp_raw_code_t *rc = o->rc;
6969
const mp_bytecode_prelude_t *prelude = &rc->prelude;
7070
mp_printf(print,
71-
"<code object %q at 0x%p, file \"%q\", line %d>",
71+
"<code object %q at %p, file \"%q\", line %d>",
7272
prelude->qstr_block_name,
7373
o,
7474
prelude->qstr_source_file,
@@ -202,7 +202,7 @@ STATIC void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
202202
const mp_raw_code_t *rc = code->rc;
203203
const mp_bytecode_prelude_t *prelude = &rc->prelude;
204204
mp_printf(print,
205-
"<frame at 0x%p, file '%q', line %d, code %q>",
205+
"<frame at %p, file '%q', line %d, code %q>",
206206
frame,
207207
prelude->qstr_source_file,
208208
frame->lineno,
@@ -950,7 +950,7 @@ void mp_prof_print_instr(const byte *ip, mp_code_state_t *code_state) {
950950

951951
/* long path */ if (1) {
952952
mp_printf(&mp_plat_print,
953-
"@0x%p:%q:%q+0x%04x:%d",
953+
"@%p:%q:%q+0x%04x:%d",
954954
ip,
955955
prelude->qstr_source_file,
956956
prelude->qstr_block_name,

tests/extmod/uctypes_print.py.exp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<struct STRUCT 0>
2-
<struct ERROR 0>
3-
<struct ARRAY 0>
4-
<struct PTR 0>
1+
<struct STRUCT 0x0>
2+
<struct ERROR 0x0>
3+
<struct ARRAY 0x0>
4+
<struct PTR 0x0>

tests/micropython/meminfo.py.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mem: total=\\d\+, current=\\d\+, peak=\\d\+
66
stack: \\d\+ out of \\d\+
77
GC: total: \\d\+, used: \\d\+, free: \\d\+
88
No. of 1-blocks: \\d\+, 2-blocks: \\d\+, max blk sz: \\d\+, max free sz: \\d\+
9-
GC memory layout; from \[0-9a-f\]\+:
9+
GC memory layout; from 0x\[0-9a-f\]\+:
1010
########
1111
qstr pool: n_pool=1, n_qstr=\\d, n_str_data_bytes=\\d\+, n_total_bytes=\\d\+
1212
qstr pool: n_pool=1, n_qstr=\\d, n_str_data_bytes=\\d\+, n_total_bytes=\\d\+

tests/unix/extra_coverage.py.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ false true
1515
abc
1616
%
1717
# GC
18-
0
19-
0
18+
0x0
19+
0x0
2020
# vstr
2121
tests
2222
sts

0 commit comments

Comments
 (0)