Skip to content

Commit b336b6b

Browse files
committed
stm32/pybthread: Make pyb_thread_dump take a printer as its argument.
Signed-off-by: Damien George <[email protected]>
1 parent 067c7cd commit b336b6b

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

Diff for: ports/stm32/modmachine.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
239239
}
240240

241241
#if MICROPY_PY_THREAD
242-
pyb_thread_dump();
242+
pyb_thread_dump(print);
243243
#endif
244244

245245
if (n_args == 1) {

Diff for: ports/stm32/pybthread.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include <string.h>
28-
#include <stdio.h>
29-
3027
#include "py/obj.h"
3128
#include "boardctrl.h"
3229
#include "gccollect.h"
@@ -142,11 +139,11 @@ uint32_t pyb_thread_new(pyb_thread_t *thread, void *stack, size_t stack_len, voi
142139
return (uint32_t)thread; // success
143140
}
144141

145-
void pyb_thread_dump(void) {
142+
void pyb_thread_dump(const mp_print_t *print) {
146143
if (!pyb_thread_enabled) {
147-
printf("THREAD: only main thread\n");
144+
mp_printf(print, "THREAD: only main thread\n");
148145
} else {
149-
printf("THREAD:\n");
146+
mp_printf(print, "THREAD:\n");
150147
for (pyb_thread_t *th = pyb_thread_all; th != NULL; th = th->all_next) {
151148
bool runable = false;
152149
for (pyb_thread_t *th2 = pyb_thread_cur;; th2 = th2->run_next) {
@@ -158,11 +155,11 @@ void pyb_thread_dump(void) {
158155
break;
159156
}
160157
}
161-
printf(" id=%p sp=%p sz=%u", th, th->stack, th->stack_len);
158+
mp_printf(print, " id=%p sp=%p sz=%u", th, th->stack, th->stack_len);
162159
if (runable) {
163-
printf(" (runable)");
160+
mp_printf(print, " (runable)");
164161
}
165-
printf("\n");
162+
mp_printf(print, "\n");
166163
}
167164
}
168165
}

Diff for: ports/stm32/pybthread.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#ifndef MICROPY_INCLUDED_STM32_PYBTHREAD_H
2727
#define MICROPY_INCLUDED_STM32_PYBTHREAD_H
2828

29+
#include "py/mpprint.h"
30+
2931
typedef struct _pyb_thread_t {
3032
void *sp;
3133
uint32_t local_state;
@@ -48,7 +50,7 @@ extern pyb_thread_t *volatile pyb_thread_cur;
4850
void pyb_thread_init(pyb_thread_t *th);
4951
void pyb_thread_deinit();
5052
uint32_t pyb_thread_new(pyb_thread_t *th, void *stack, size_t stack_len, void *entry, void *arg);
51-
void pyb_thread_dump(void);
53+
void pyb_thread_dump(const mp_print_t *print);
5254

5355
static inline uint32_t pyb_thread_get_id(void) {
5456
return (uint32_t)pyb_thread_cur;

0 commit comments

Comments
 (0)