Skip to content

Commit

Permalink
debug crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Dec 16, 2020
1 parent 0dcc659 commit 3923351
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ports/esp32s2/common-hal/alarm/pin/PinAlarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ bool alarm_pin_pin_alarm_woke_us_up(void) {
return low_pin_status != 0 || high_pin_status != 0;
}

#include "esp_log.h"

// static const char* TAG = "pinalarm";

mp_obj_t alarm_pin_pin_alarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) {
// First, check to see if we match any given alarms.
uint64_t pin_status = ((uint64_t) high_pin_status) << 32 | low_pin_status;
Expand Down Expand Up @@ -142,6 +146,10 @@ mp_obj_t alarm_pin_pin_alarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *a
break;
}
}

// Uncommenting this fixes the crash caused by invalid object type in obj.c
// ESP_LOGI(TAG, "type");
assert(alarm->base.type == &alarm_pin_pin_alarm_type);
return alarm;
}

Expand Down
6 changes: 6 additions & 0 deletions py/obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
mp_print_str(print, "\n");
}

#include "esp_log.h"

static const char* TAG = "obj";

bool PLACE_IN_ITCM(mp_obj_is_true)(mp_obj_t arg) {
if (arg == mp_const_false) {
return 0;
Expand All @@ -149,7 +153,9 @@ bool PLACE_IN_ITCM(mp_obj_is_true)(mp_obj_t arg) {
return 1;
}
} else {
ESP_LOGI(TAG, "obj %p", arg);
mp_obj_type_t *type = mp_obj_get_type(arg);
ESP_LOGI(TAG, "type %p", type);
if (type->unary_op != NULL) {
mp_obj_t result = type->unary_op(MP_UNARY_OP_BOOL, arg);
if (result != MP_OBJ_NULL) {
Expand Down

0 comments on commit 3923351

Please sign in to comment.