stm32/pybthread: Make pyb_thread_dump take a printer as its argument.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
067c7cd9dc
commit
b336b6bb74
ports/stm32
@ -239,7 +239,7 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MICROPY_PY_THREAD
|
#if MICROPY_PY_THREAD
|
||||||
pyb_thread_dump();
|
pyb_thread_dump(print);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (n_args == 1) {
|
if (n_args == 1) {
|
||||||
|
@ -24,9 +24,6 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "boardctrl.h"
|
#include "boardctrl.h"
|
||||||
#include "gccollect.h"
|
#include "gccollect.h"
|
||||||
@ -142,11 +139,11 @@ uint32_t pyb_thread_new(pyb_thread_t *thread, void *stack, size_t stack_len, voi
|
|||||||
return (uint32_t)thread; // success
|
return (uint32_t)thread; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyb_thread_dump(void) {
|
void pyb_thread_dump(const mp_print_t *print) {
|
||||||
if (!pyb_thread_enabled) {
|
if (!pyb_thread_enabled) {
|
||||||
printf("THREAD: only main thread\n");
|
mp_printf(print, "THREAD: only main thread\n");
|
||||||
} else {
|
} else {
|
||||||
printf("THREAD:\n");
|
mp_printf(print, "THREAD:\n");
|
||||||
for (pyb_thread_t *th = pyb_thread_all; th != NULL; th = th->all_next) {
|
for (pyb_thread_t *th = pyb_thread_all; th != NULL; th = th->all_next) {
|
||||||
bool runable = false;
|
bool runable = false;
|
||||||
for (pyb_thread_t *th2 = pyb_thread_cur;; th2 = th2->run_next) {
|
for (pyb_thread_t *th2 = pyb_thread_cur;; th2 = th2->run_next) {
|
||||||
@ -158,11 +155,11 @@ void pyb_thread_dump(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(" id=%p sp=%p sz=%u", th, th->stack, th->stack_len);
|
mp_printf(print, " id=%p sp=%p sz=%u", th, th->stack, th->stack_len);
|
||||||
if (runable) {
|
if (runable) {
|
||||||
printf(" (runable)");
|
mp_printf(print, " (runable)");
|
||||||
}
|
}
|
||||||
printf("\n");
|
mp_printf(print, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#ifndef MICROPY_INCLUDED_STM32_PYBTHREAD_H
|
#ifndef MICROPY_INCLUDED_STM32_PYBTHREAD_H
|
||||||
#define MICROPY_INCLUDED_STM32_PYBTHREAD_H
|
#define MICROPY_INCLUDED_STM32_PYBTHREAD_H
|
||||||
|
|
||||||
|
#include "py/mpprint.h"
|
||||||
|
|
||||||
typedef struct _pyb_thread_t {
|
typedef struct _pyb_thread_t {
|
||||||
void *sp;
|
void *sp;
|
||||||
uint32_t local_state;
|
uint32_t local_state;
|
||||||
@ -48,7 +50,7 @@ extern pyb_thread_t *volatile pyb_thread_cur;
|
|||||||
void pyb_thread_init(pyb_thread_t *th);
|
void pyb_thread_init(pyb_thread_t *th);
|
||||||
void pyb_thread_deinit();
|
void pyb_thread_deinit();
|
||||||
uint32_t pyb_thread_new(pyb_thread_t *th, void *stack, size_t stack_len, void *entry, void *arg);
|
uint32_t pyb_thread_new(pyb_thread_t *th, void *stack, size_t stack_len, void *entry, void *arg);
|
||||||
void pyb_thread_dump(void);
|
void pyb_thread_dump(const mp_print_t *print);
|
||||||
|
|
||||||
static inline uint32_t pyb_thread_get_id(void) {
|
static inline uint32_t pyb_thread_get_id(void) {
|
||||||
return (uint32_t)pyb_thread_cur;
|
return (uint32_t)pyb_thread_cur;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user