-
-
Notifications
You must be signed in to change notification settings - Fork 81
pbdrv/uart_debug_first_port: (EV3) Log on panic. #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
bdf4979 to
6951b91
Compare
It's helpful when you crash to see what happens right before you
crash. For example, if you add a log message "about to dereference
sketchy pointer" and then you get a segfault, you'd love to know
whether that message occurred. This change makes it so that at least
on EV3, we will.
This also adds "pb_log" as an alias for pbdrv_uart_debug_printf.
Usually, platforms make it easy to log debug messages, and we should
be no different. C.f. `ESP_LOGI`, Zephyr's `LOG_ERR`, glog's
`LOG(WARNING)` etc.
Tested by adding the following code to pbdrv_init.
```
pb_log("test\n");
lwrb_t* rb = (lwrb_t*)0x1281441490;
pb_log("%p\n", lwrb_get_free(rb));
```
Before this, the "test" would not appear before the panic.
After, it does. If a panic occurs while some messages are pending
in the uart send state, some bytes may be duplicated on the log.
6951b91 to
9f46367
Compare
|
Thanks! I think this fine. Maybe the alias could still keep the word UART in it? I'll be adding USB debugging in an upcoming commit. This will be helpful for platforms without uart (like NXT) and for most people without custom cables. Output will go into the existing stdout ring buffer, so it simply shows up in Pybricks Code without custom terminal tools. Since the EV3 reconnect itself on reboot, this should even be convenient for our own everyday use cases. They can be complementary - we'll still want the UART version for sketchy pointers and other reasons for panic 😄. |
It's helpful when you crash to see what happens right before you crash. For example, if you add a log message "about to dereference sketchy pointer" and then you get a segfault, you'd love to know whether that message occurred. This change makes it so that at least on EV3, we will.
This also adds "pb_log" as an alias for pbdrv_uart_debug_printf. Usually, platforms make it easy to log debug messages, and we should be no different. C.f.
ESP_LOGI, Zephyr'sLOG_ERR, glog'sLOG(WARNING)etc.Tested by adding the following code to pbdrv_init.
Before this, the "test" would not appear before the panic. After, it does. If a panic occurs while some messages are pending in the uart send state, some bytes may be duplicated on the log.
This only makes this change for EV3. I will separately look into whether it might be useful on other platforms.