-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Improving debug / development support in our builds #2146
Comments
I have now really got to grips with the make system and its subtleties, but also in the detailed debugging of all of the main build variants for #2068, I have sorted out a lot of the usability issues with the remote debugger, and I am now finding it a really powerful tool even though some annoying limitations remain. So as it stands:
I couldn't have done the LFS patch without all this so I will be including these features in the patch. But the scope of debugging is quite different hence this issue. I've also picked up a couple of benign bugs in the elua base code (e.g. enabling All of this experience would really help most C library developers in the development of their code, so another C developers FAQ is definitely needed. |
Just as a footnote, this allows some really powerful ways of using the debugger:
If you are a developer of C libraries, once you start using this, then you won't go back to the old techniques. |
Having got into power debugging, and resolved most of the issues, what we are really left with is a documentation issue. In terms of programmatic functionality, this issue is effectively done. |
This is probably closer to a feature request rather than a bugrep, but more of a lessons-learnt from my developing the LFS (Lua Flash Store) as discussed in #2068, and the changes that I needed to make to support the debugging environment. These changes were not LFS-specific, but they were needed to support useful debugging of LFS.
The
./Makefile
andapp/Makefile
magic already support the concept ofdebug
andrelease
flavours -- though this is always defaulted to debug. I think that there is a good justifcation for revisiting this and properly enabling these two flavours:release. Used to build standard images where you as a developer are only working in Lua and don't want access to image internals. This will build the current default module list. This will be the default and the normal option for Docker builds, and typically not modified, other than the normal user configuration changes.
debug. Used to build debug images where you as a developer are working on one or more C modules / library functions and therefore want access to image internals, and to use the GDB stub. You are going to be cycling through bugfix builds, so minimising flash times is essential, so this build should be be default an absolute cutdown module and option set, and a small SPIFFS at a fixed offset for rapid SPIFFS reimaging. You are also probably going to be connecting a second USB serial chip to GND/TDX1 for extra diagnostic output. Developers will be typically working in Linux (possibly in a VM), and this is core which will be extended / customised to their needs.
What I propose is to make this a separate PR covering the changes that I needed for LFS development:
Makefile
. Changes to enable remote debug (-ggdb
compile flag) and-O2
instead of-Os
. We've talked about this last one and this should be standard fordev
andmaster
as there is a roughly %3 increase in the image size, but a huge drop in unaligned flash exceptions without the unaligned string constants. A no-brainer, IMO, and should also be the default for release builds.esp-gdbstub/gdbstub.c
. Fix compile warning.include/user_config.h
,include/user_modules.h
. I have a minimal configuration for testing to reduce reflash times to the minimum. Also a fixed 32b SPIFFS at a fixed 0x100000 offset for the same reason. What I suggest is that we extend the use of theDEVELOP_VERSION
define to group configuration options into core and non-core, so that the standard versions generate a minimal build ifDEVELOP_VERSION
is definedlibc/c_stdio.h
,libc/dbg_printf.c
,libc/Makefile
,driver/uart.c
. Extra functiondbg_set_uart
which enables thedbg_printf
to go UART1 instead of UART0. (If you output debug diagnostics to UART0 before the GDB stub is initialised, then this can prevent the successful connection of the GDB stub todebug_set_uart
). Also export a previously internaluart1_write_char
function.modules/gpio.c
. Bugfix to allowgpio.c
to compile if GPIO_INTERRUPT_ENABLE is not defined and DEVELOP_VERSION is.user/user_exceptions.c
. Fix bug in exception chaining when in GDB stub debugging.Yes, this patch would also impact on how we document all of this as discussed in #1862, and I am happy to take this one on as well. If I get general support then I will raise this as a separate PR to LFS one.
The text was updated successfully, but these errors were encountered: