Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Enable memory tracing #22

Merged
merged 3 commits into from
Dec 18, 2015
Merged

Enable memory tracing #22

merged 3 commits into from
Dec 18, 2015

Conversation

bogdanm
Copy link
Contributor

@bogdanm bogdanm commented Dec 16, 2015

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
}
}
}

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
        }
    }
}
@bogdanm
Copy link
Contributor Author

bogdanm commented Dec 16, 2015

@bogdanm
Copy link
Contributor Author

bogdanm commented Dec 17, 2015

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",

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.

Copy link
Contributor Author

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.

@bogdanm
Copy link
Contributor Author

bogdanm commented Dec 17, 2015

If people are fine with this first version of the tracer, i'd like to merge it.

@bremoran
Copy link
Contributor

I think it's good enough for now.

+1

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 18, 2015

+1

bogdanm added a commit that referenced this pull request Dec 18, 2015
@bogdanm bogdanm merged commit 9021555 into master Dec 18, 2015
@bogdanm bogdanm deleted the tracing branch December 18, 2015 09:02
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 { \
Copy link

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.

Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants