-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fix/gdbstub continuation crash #1671
Fix/gdbstub continuation crash #1671
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikee47 Thanks a lot for your fantastic work on the debugger! I was able to have proper debug sessions and debug areas that were impossible with the previous versions of GdbStub.
There are small changes that need to be addressed before merging this code. Mainly removing debug lines.See the comments in this review.
Sming/gdb/gdbcmds
Outdated
@@ -1,5 +1,5 @@ | |||
# Enable this if you want to log all traffic between GDB and the stub | |||
# set remotelogfile gdb_rsp_logfile.txt | |||
set remotelogfile gdb_rsp_logfile.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, make this line commented out by default.
@@ -178,7 +178,7 @@ | |||
* Set to 0 to wait indefinitely. | |||
*/ | |||
#ifndef GDBSTUB_UART_READ_TIMEOUT | |||
#define GDBSTUB_UART_READ_TIMEOUT 2000 | |||
#define GDBSTUB_UART_READ_TIMEOUT 0 | |||
#endif | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, make GDBSTUB_ENABLE_SYSCALL
to be 0
by default. This will help visual debuggers behave as expected. Allow also that setting to be changed during compilation so that adventurous developers can try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the instructions simpler, how about we do this?
To build for normal (command-line GDB) use: make flash
To build for eclipse: make flash ENABLE_CONSOLE=0
The problem is specific to the LiveDebug
sample.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use ENABLE_SYS_CONSOLE
instead of ENABLE_CONSOLE
. In addition I would prefer the syscall stuff to be disabled by default. For the LiveSample we can enable it by default by writing in the Makefile-user.mk.
When ENABLE_SYS_CONSOLE
is enabled a warning message should be shown to inform the developers that this might interfere with visual debuggers, like Eclipse. And that it can be disabled using make ENABLE_SYS_CONSOLE=0
.
What do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even better ENABLE_GDB_CONSOLE
instead of ENABLE_CONSOLE
. The name prompts that this is related to the special GDB console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow also that setting to be changed during compilation so that adventurous developers can try it.
The simplest way is to just edit the gdbstub-cfg.h
file directly to make changes as required (same goes for gdbcmds
). I also have a note in the readme.md
about using USER_CFLAGS
to set these values for a particular project - I've done this for the LiveDebug
sample as per your suggestions.
Are you propsing we add the abillty to change these directly from the make
command line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you proposing we add the ability to change these directly from the make command line?
Ok, I see. Then can you do the the following?
- GDBSTUB_ENABLE_SYSCALL=0 in Sming/gdb/gdbstub-cfg.h
- In samples/LiveDebug/Makefile-user.mk add
# Comment the line below if you want to disable the GDB system calls
USER_CFLAGS += -DGDBSTUB_ENABLE_SYSCALL=1
- Update the README in LiveDebug to mention that change.
Sming/gdb/gdbstub.cpp
Outdated
*/ | ||
case 'F': | ||
// if(gdb_syscall_complete(data)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the commented code? Can you remove it?
@@ -268,7 +268,8 @@ void fileStat(const char* filename) | |||
XX(ls, "Use `syscall_system` function to perform a directory listing on the host") \ | |||
XX(time, "Use `syscall_gettimeofday` to get current time from host") \ | |||
XX(log, "Show state of log file") \ | |||
XX(break, "Demonstrated `gdb_do_break()` function to pause this application and obtain a GDB command prompt") \ | |||
XX(break, "Demonstrate `gdb_do_break()` function to pause this application and obtain a GDB command prompt") \ | |||
XX(queueBreak, "Demonstrate `gdb_do_break()` function called via task queue") \ | |||
XX(hang, "Enter infinite loop to force a watchdog timeout") \ | |||
XX(read0, "Read from invalid address") \ | |||
XX(write0, "Write to invalid address") \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A side note here for the exit
command: I guess my expectations here are incorrect but I was hoping that exit
will allow me to continue to control the debug process. What I am seeing instead is:
(Attached) exit
300252092 gdb_read_console() returned 5
Calling gdb_detach() - resuming normal program execution.
[Inferior 1 (Remote target) exited normally]
(gdb)
The program is not being run.
And I have to restart the debugging session in order to do anything more. If that is what was expected may be the short description of the exit
command should be changed to reflect that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably better renamed as detach
. Was your expectation that it behaves like break
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A... is that the "disconnect" function in Eclipse. If yes just rename it to disconnect
with short description Terminates the connection between the debugger and the remote debug target
.
@slaff Are you able to get eclipse to show any of the debug output from an application? i.e. stuff from |
Not really. I've tried with |
Me either. I've added it to the |
Previously observed problem with `LEVEL` interrupt when using gdbstub in debug mode was probably because there was no check for invalid register number. It appears to work without issue now.
Note: Missing return value should _always_ be reported as error; the only reason it isn't at present is because Library builds will fail.
* Set uart read timeout to 0 by default - used during testing but isn't necessary for normal use * Only optimize stub code in non-debug mode
Used in original GDB stub PR but this change was omitted
When a syscall is being processed, especially a lengthy one like reading from the console, a regular debug break or exception takes us into the debugger command loop but GDB doesn't know we've stopped (it ignores our 'T' message). Then, when the 'F' response (which completes the syscall) is received, it takes us back out of the debugger loop immediately, which is wrong; at that point we should tell GDB again why we've stopped so things can proceed as for a regular break handling. ONGOING: When testing with a breakpoint in a regular system timer the stub hangs during the `gdbstub_icount_ena_single_step()` call - this has been temporarily highlighted with the !! debug statements.
…nt_ena_single_step()`
* Comment out `remotelogfile` setting in gdbcmds * Disable system calls by default * Remove commented-out code * Update `readme.md`
Make sure to rebase your branch on the latest develop. See "Rebase if needed" in CONTRIBUTING.md |
* Rename `exit` command to `disconnect * Add make option `ENABLE_GDB_CONSOLE` * Rename `state` to `ledState` * Revise command map to include more detail in the description, and improve the layout of `help` * Add `consoleOff` command * Move forward declarations to top of file * Update `README.md`
426a2b1
to
5a70f09
Compare
@mikee47 All looks good to me. Is the PR ready to merge or you would like to add some small changes? |
* Move source symbols into separate `gdb\symbols` directory * Provide separate rule to copy symbol files into application folder
@slaff That's it One last point - I'm not sure that (I think this is a hangover from having gdbstub compiled into the framework.) |
@slaff OK, ready to merge. Thanks for your help testing this! |
@mikee47 Thank you for your hard work! |
When a syscall is being processed, especially a lengthy one like reading from the console, a regular debug break or exception takes us into the debugger command loop but GDB doesn't know we've stopped (it ignores our 'T' message). Then, when the 'F' response (which completes the syscall) is received, it takes us back out of the debugger loop immediately, which is wrong: we should instead remain within the debugger loop and tell GDB why we've stopped so things can proceed as for a regular break handling.
When testing with a breakpoint in a regular system timer the stub hangs during the
gdbstub_icount_ena_single_step()
call. This has been fixed by raising the interrupt level before setting up the count registers. ThequeueBreak
command has been added to test this particular code path.See #1670 for discussion.
Also:
SimpleTimerCallback
- used in original GDB stub PR but this change was omittedreturn
statements in LiveDebug samplem_printf
supports flash strings directlyqueueBreak
command