{"action":"created","comment":{"url":"https://api.github.com/repos/ARMmbed/ualloc/pulls/comments/47891482","id":47891482,"diff_hunk":"@@ -27,12 +27,44 @@ extern int printf(const char *, ...);\n \n extern void * volatile mbed_sbrk_ptr;\n \n-// Set debug level to 0 until non-allocating printf is available\n-const UAllocDebug_t ualloc_debug_level = UALLOC_DEBUG_NONE;//(DEBUG?UALLOC_DEBUG_MAX:UALLOC_DEBUG_NONE);\n+/*****************************************************************************************\n+UALLOC_DEBUG_LOG is effectively reserved for tracing memory allocations\n+Tracing must be enabled via \"yotta config\":\n+{\n+    \"debug\": {\n+        \"options\": {\n+            \"memory-trace\": true\n+        }\n+    }\n+}\n+[TODO]: ualloc_debug_level probably needs better control with \"yotta config\"\n+*****************************************************************************************/\n+#ifdef YOTTA_CFG_DEBUG_OPTIONS_MEMORY_TRACE\n+const UAllocDebug_t ualloc_debug_level = UALLOC_DEBUG_LOG;\n+#else\n+const UAllocDebug_t ualloc_debug_level = UALLOC_DEBUG_NONE;\n+#endif\n \n // Debug characters\n const char ua_chars[] = \"NFEWIL\";\n \n+/*****************************************************************************************\n+The purpose of \"prevent_tracing\" below is twofold:\n+\n+1. prevent infinite loops (mbed_ualloc_internal -> ualloc_debug -> printf ->\n+   mbed_ualloc_internal -> ualloc_debug -> printf...)\n+2. prevent a possible scenario when an interrupt occurs while ualloc_debug\n+   is printing debug information and the interrupt also calls 'mbed_ualloc' or\n+   another memory operation that would result in ualloc_debug being called,\n+   which would in turn result in garbled output. By using \"prevent_tracing\",","path":"source/ualloc.c","position":35,"original_position":35,"commit_id":"abcb0fe75c539f6380e0c2fe63a6f28fe8460809","original_commit_id":"abcb0fe75c539f6380e0c2fe63a6f28fe8460809","user":{"login":"autopulated","id":3456211,"avatar_url":"https://avatars.githubusercontent.com/u/3456211?v=3","gravatar_id":"","url":"https://api.github.com/users/autopulated","html_url":"https://github.com/autopulated","followers_url":"https://api.github.com/users/autopulated/followers","following_url":"https://api.github.com/users/autopulated/following{/other_user}","gists_url":"https://api.github.com/users/autopulated/gists{/gist_id}","starred_url":"https://api.github.com/users/autopulated/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autopulated/subscriptions","organizations_url":"https://api.github.com/users/autopulated/orgs","repos_url":"https://api.github.com/users/autopulated/repos","events_url":"https://api.github.com/users/autopulated/events{/privacy}","received_events_url":"https://api.github.com/users/autopulated/received_events","type":"User","site_admin":false},"body":"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.","created_at":"2015-12-17T10:40:52Z","updated_at":"2015-12-17T10:40:52Z","html_url":"https://github.com/ARMmbed/ualloc/pull/22#discussion_r47891482","pull_request_url":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/ARMmbed/ualloc/pulls/comments/47891482"},"html":{"href":"https://github.com/ARMmbed/ualloc/pull/22#discussion_r47891482"},"pull_request":{"href":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22","id":53913543,"html_url":"https://github.com/ARMmbed/ualloc/pull/22","diff_url":"https://github.com/ARMmbed/ualloc/pull/22.diff","patch_url":"https://github.com/ARMmbed/ualloc/pull/22.patch","issue_url":"https://api.github.com/repos/ARMmbed/ualloc/issues/22","number":22,"state":"open","locked":false,"title":"Enable memory tracing","user":{"login":"bogdanm","id":211717,"avatar_url":"https://avatars.githubusercontent.com/u/211717?v=3","gravatar_id":"","url":"https://api.github.com/users/bogdanm","html_url":"https://github.com/bogdanm","followers_url":"https://api.github.com/users/bogdanm/followers","following_url":"https://api.github.com/users/bogdanm/following{/other_user}","gists_url":"https://api.github.com/users/bogdanm/gists{/gist_id}","starred_url":"https://api.github.com/users/bogdanm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogdanm/subscriptions","organizations_url":"https://api.github.com/users/bogdanm/orgs","repos_url":"https://api.github.com/users/bogdanm/repos","events_url":"https://api.github.com/users/bogdanm/events{/privacy}","received_events_url":"https://api.github.com/users/bogdanm/received_events","type":"User","site_admin":false},"body":"This commit enables tracing of dynamic memory operations\r\n(alloc/free/realloc) using the existing logging support in ualloc.\r\n\r\nNote that this support is preliminary, check the code for more details.\r\nIn particular, \"prevent_tracing\" will have to go away eventually, but\r\nfor now we need it.\r\n\r\nTracing must be enabled via \"yotta config\":\r\n\r\n{\r\n    \"debug\": {\r\n        \"options\": {\r\n            \"memory-trace\": true\r\n        }\r\n    }\r\n}","created_at":"2015-12-16T23:19:18Z","updated_at":"2015-12-17T10:40:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"adc26a3b5e43dbe3cc81c5d28f024fde7f74879f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22/commits","review_comments_url":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22/comments","review_comment_url":"https://api.github.com/repos/ARMmbed/ualloc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ARMmbed/ualloc/issues/22/comments","statuses_url":"https://api.github.com/repos/ARMmbed/ualloc/statuses/abcb0fe75c539f6380e0c2fe63a6f28fe8460809","head":{"label":"ARMmbed:tracing","ref":"tracing","sha":"abcb0fe75c539f6380e0c2fe63a6f28fe8460809","user":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars.githubusercontent.com/u/8916057?v=3","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"repo":{"id":37459147,"name":"ualloc","full_name":"ARMmbed/ualloc","owner":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars.githubusercontent.com/u/8916057?v=3","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARMmbed/ualloc","description":"mbed allocator functions","fork":false,"url":"https://api.github.com/repos/ARMmbed/ualloc","forks_url":"https://api.github.com/repos/ARMmbed/ualloc/forks","keys_url":"https://api.github.com/repos/ARMmbed/ualloc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARMmbed/ualloc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARMmbed/ualloc/teams","hooks_url":"https://api.github.com/repos/ARMmbed/ualloc/hooks","issue_events_url":"https://api.github.com/repos/ARMmbed/ualloc/issues/events{/number}","events_url":"https://api.github.com/repos/ARMmbed/ualloc/events","assignees_url":"https://api.github.com/repos/ARMmbed/ualloc/assignees{/user}","branches_url":"https://api.github.com/repos/ARMmbed/ualloc/branches{/branch}","tags_url":"https://api.github.com/repos/ARMmbed/ualloc/tags","blobs_url":"https://api.github.com/repos/ARMmbed/ualloc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARMmbed/ualloc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARMmbed/ualloc/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARMmbed/ualloc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARMmbed/ualloc/statuses/{sha}","languages_url":"https://api.github.com/repos/ARMmbed/ualloc/languages","stargazers_url":"https://api.github.com/repos/ARMmbed/ualloc/stargazers","contributors_url":"https://api.github.com/repos/ARMmbed/ualloc/contributors","subscribers_url":"https://api.github.com/repos/ARMmbed/ualloc/subscribers","subscription_url":"https://api.github.com/repos/ARMmbed/ualloc/subscription","commits_url":"https://api.github.com/repos/ARMmbed/ualloc/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARMmbed/ualloc/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARMmbed/ualloc/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARMmbed/ualloc/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARMmbed/ualloc/contents/{+path}","compare_url":"https://api.github.com/repos/ARMmbed/ualloc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARMmbed/ualloc/merges","archive_url":"https://api.github.com/repos/ARMmbed/ualloc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARMmbed/ualloc/downloads","issues_url":"https://api.github.com/repos/ARMmbed/ualloc/issues{/number}","pulls_url":"https://api.github.com/repos/ARMmbed/ualloc/pulls{/number}","milestones_url":"https://api.github.com/repos/ARMmbed/ualloc/milestones{/number}","notifications_url":"https://api.github.com/repos/ARMmbed/ualloc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARMmbed/ualloc/labels{/name}","releases_url":"https://api.github.com/repos/ARMmbed/ualloc/releases{/id}","created_at":"2015-06-15T10:39:38Z","updated_at":"2015-12-03T09:08:16Z","pushed_at":"2015-12-17T10:10:52Z","git_url":"git://github.com/ARMmbed/ualloc.git","ssh_url":"git@github.com:ARMmbed/ualloc.git","clone_url":"https://github.com/ARMmbed/ualloc.git","svn_url":"https://github.com/ARMmbed/ualloc","homepage":null,"size":49,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"ARMmbed:master","ref":"master","sha":"5bfe6c876a240dc6e78a29df724c2a0bf9b0f870","user":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars.githubusercontent.com/u/8916057?v=3","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"repo":{"id":37459147,"name":"ualloc","full_name":"ARMmbed/ualloc","owner":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars.githubusercontent.com/u/8916057?v=3","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARMmbed/ualloc","description":"mbed allocator functions","fork":false,"url":"https://api.github.com/repos/ARMmbed/ualloc","forks_url":"https://api.github.com/repos/ARMmbed/ualloc/forks","keys_url":"https://api.github.com/repos/ARMmbed/ualloc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARMmbed/ualloc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARMmbed/ualloc/teams","hooks_url":"https://api.github.com/repos/ARMmbed/ualloc/hooks","issue_events_url":"https://api.github.com/repos/ARMmbed/ualloc/issues/events{/number}","events_url":"https://api.github.com/repos/ARMmbed/ualloc/events","assignees_url":"https://api.github.com/repos/ARMmbed/ualloc/assignees{/user}","branches_url":"https://api.github.com/repos/ARMmbed/ualloc/branches{/branch}","tags_url":"https://api.github.com/repos/ARMmbed/ualloc/tags","blobs_url":"https://api.github.com/repos/ARMmbed/ualloc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARMmbed/ualloc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARMmbed/ualloc/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARMmbed/ualloc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARMmbed/ualloc/statuses/{sha}","languages_url":"https://api.github.com/repos/ARMmbed/ualloc/languages","stargazers_url":"https://api.github.com/repos/ARMmbed/ualloc/stargazers","contributors_url":"https://api.github.com/repos/ARMmbed/ualloc/contributors","subscribers_url":"https://api.github.com/repos/ARMmbed/ualloc/subscribers","subscription_url":"https://api.github.com/repos/ARMmbed/ualloc/subscription","commits_url":"https://api.github.com/repos/ARMmbed/ualloc/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARMmbed/ualloc/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARMmbed/ualloc/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARMmbed/ualloc/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARMmbed/ualloc/contents/{+path}","compare_url":"https://api.github.com/repos/ARMmbed/ualloc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARMmbed/ualloc/merges","archive_url":"https://api.github.com/repos/ARMmbed/ualloc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARMmbed/ualloc/downloads","issues_url":"https://api.github.com/repos/ARMmbed/ualloc/issues{/number}","pulls_url":"https://api.github.com/repos/ARMmbed/ualloc/pulls{/number}","milestones_url":"https://api.github.com/repos/ARMmbed/ualloc/milestones{/number}","notifications_url":"https://api.github.com/repos/ARMmbed/ualloc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARMmbed/ualloc/labels{/name}","releases_url":"https://api.github.com/repos/ARMmbed/ualloc/releases{/id}","created_at":"2015-06-15T10:39:38Z","updated_at":"2015-12-03T09:08:16Z","pushed_at":"2015-12-17T10:10:52Z","git_url":"git://github.com/ARMmbed/ualloc.git","ssh_url":"git@github.com:ARMmbed/ualloc.git","clone_url":"https://github.com/ARMmbed/ualloc.git","svn_url":"https://github.com/ARMmbed/ualloc","homepage":null,"size":49,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22"},"html":{"href":"https://github.com/ARMmbed/ualloc/pull/22"},"issue":{"href":"https://api.github.com/repos/ARMmbed/ualloc/issues/22"},"comments":{"href":"https://api.github.com/repos/ARMmbed/ualloc/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/ARMmbed/ualloc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ARMmbed/ualloc/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/ARMmbed/ualloc/statuses/abcb0fe75c539f6380e0c2fe63a6f28fe8460809"}}}}