-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Hook system debug messages #1613
Conversation
Another way to do this is to put the code into your application, then call |
8c1767e
to
d0a462c
Compare
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, see the comments and change also the Makefile's so that it is easy to set that directive at compile time.
Sming/system/uart.cpp
Outdated
|
||
if(c == '\r' || c == '\n') { | ||
if(lineLength >= 2) { | ||
if(memcmp(line, "E:M", 2) == 0) { |
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 Maybe you can change this to "E:M " ( <-- one space after the capital M) just to avoid false positives.
Can you paste here some code to illustrate also the other approach? |
OK, so instead of changing
And in our debugging application we'd have:
|
I like that! |
How did I know you were going to say that. LOL. |
;-) Some might call it "magic" but I guess it is due to "consistency". A consistent behaviour leads to predictable behaviour same as with programming code. Thus it makes it easy to guess, use and advance. |
That's deep, man :-) |
d0a462c
to
5f904f6
Compare
OK, this is a more generic hook which, when installed, suppresses actual output so can do stuff like this:
That includes the timestamp on system messages as well as trapping E:Mstuff. I've also blocked recursion in case further system messages get emitted during the callback. It does require the addition of |
@mikee47 Thanks for your efforts. Your comments are quite helpful but I would like to ask you to either modify an existing sample or create a new one demonstrating the usage of the new feature(s). |
@slaff I'm thinking an addition to the LiveDebug sample, an additional command to force an "E:M" output, etc. |
Sounds good to me. |
… sample to demonstrate * SDK debug output is reassembled into lines and passed to a defined callback * Add `new0` and `freetwice` commands to LiveDebug sample
5f904f6
to
f7b6e88
Compare
@mikee47 Is the PR tested and ready to merge? |
@slaff It works, but taking another look at the code as I'm not completely happy with it yet. It feels clunky and overly complex to use. I'll update later today, but in the meantime if you get a chance to run it would welcome your feedback on how it fits in with debugging in general, and whether it's clear enough what it's supposed to be doing. |
I'm also not 100% happy with the name - |
Perfect. Thanks in advance.
How about |
* Add separate `LineBuffer` class to deal with line reconstruction, including `startsWith()` and `contains()` methods for simple parsing. * Add `OsMessageInterceptor` class with standard `begin()` and `end()` usage * Update `LiveDebug` sample to use LineBuffer for editing
The rewrite is, I hope, an improvement. However, it does highlight an issue I've found using GDB when inspecting the stack. I'll illustrate with an example.
All good so far. Now let's see if we can find which piece of code caused the problem.
It stops before we get to anything useful. The 'corrupt stack' warning doesn't help either, and I cannot find any way to get GDB to skip the dodgy stack frames. To get any further I have to skip ahead manually, thus:
That's better.
|
Also, I note that the Arduino project uses a different java-based stack dumper (repo here), and uses GDB to get the address information (instead of addr2line). |
Yes, the python stack dumper that we use is based on that code. I could check later on their progress and try to update the python code.
@igrr @earlephilhower Do you have some ideas? (See the previous comments in the thread) |
|
@igrr Thanks for the pointer - missing symbols it was |
|
I tried this again using the 'hang' command in
Looks like |
To help track down "E:M" errors output by system functions, #define UART_DEBUG_SNOOP and rebuild. Any lines starting with "E:M" will then receive a full stack dump.