-
Notifications
You must be signed in to change notification settings - Fork 8
Enable memory tracing #22
Conversation
This commit enables tracing of dynamic memory operations (alloc/free/realloc) using the existing logging support in ualloc. Note that this support is preliminary, check the code for more details. In particular, "prevent_tracing" will have to go away eventually, but for now we need it. Tracing must be enabled via "yotta config": { "debug": { "options": { "memory-trace": true } } }
Fixed logging inconsistencies and curly bracket placement. |
2. prevent a possible scenario when an interrupt occurs while ualloc_debug | ||
is printing debug information and the interrupt also calls 'mbed_ualloc' or | ||
another memory operation that would result in ualloc_debug being called, | ||
which would in turn result in garbled output. By using "prevent_tracing", |
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.
Should be possible to have a re-entrant logging format (surround messages by matching brackets?), which would make this OK. This seems like a suitable solution for now though, especially as we don't malloc from interrupt handlers.
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.
Actually, I think this is already re-entrant, since it always starts with a known prefix that isn't repeated im the rest of the message. I can't remove prevent_tracing
yet tohugh, because of printf.
If people are fine with this first version of the tracer, i'd like to merge it. |
I think it's good enough for now. +1 |
+1 |
2 above can be prevented by queueing log messages instead of logging them immediately. | ||
*****************************************************************************************/ | ||
static volatile int prevent_tracing = 0; | ||
|
||
#define ualloc_debug(ADBG_LEVEL, fmt, ...) do { \ |
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.
this should be inside separate trace library, because for example it might be that sometimes user wan't to change endpoint where to print these debug messages (=traces), or change trace format easily without touching ualloc -library.
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 file this as an issue against this repo.
This commit enables tracing of dynamic memory operations
(alloc/free/realloc) using the existing logging support in ualloc.
Note that this support is preliminary, check the code for more details.
In particular, "prevent_tracing" will have to go away eventually, but
for now we need it.
Tracing must be enabled via "yotta config":
{
"debug": {
"options": {
"memory-trace": true
}
}
}