Skip to content

Docs for MemoryStats API, Debug API, Assert and Error APIs #310

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

Merged
merged 9 commits into from
Nov 9, 2017

Conversation

SenRamakri
Copy link
Contributor

No description provided.

@SenRamakri
Copy link
Contributor Author

Note that for Assert and Error functions there are no specific examples code/repo apart from usage example on the help docs. These are simple functions and does not require specific examples to demonstrate their usage and calling these puts the system in error state/stops execution.

@AnotherButler AnotherButler requested a review from sg- October 26, 2017 18:51
@@ -1,5 +1,20 @@
## Error

The error function generates a fatal runtime error, which allows the user to dump a message to the serial line, halt the program and place the device in an idle mode with a blinking red LED.
Mbed-OS provides an error function to output messages to STDIO at runtime when the system encounters a fatal error. Its declared in mbed_error.h. The function will output the error message when called for the first time, but will ignore subsequent calls without generating any output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding that this function invokes exit - termination process .

Sidequestion: I do not remember why are subsequent calls ingored?

Copy link
Contributor

@0xc0170 0xc0170 Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also conditionally compiled with NDEBUG macro (similar note is for assert above)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good idea, to add the termination/NDEBUG note.

Currently error function internally uses a static variable which prevents further output if you call again.

### Error usage example
The code below uses error function to print a fatal error indicating out of memory condition.

void *operator new(std::size_t count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this use code snippet syntax ?

// code here

### Assert example
### Assert usage example

MBED_ASSERT macro can be used for runtime evaluation of expressions. If the evaluation fails, an error message will be printed out to bash in the below format. Note that MBED_ASSERT macro is available in debug builds only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume debug builds here means debug + develop profiles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I really thought its just debug builds. Let me confirm and update the docs.

Copy link
Contributor

@AnotherButler AnotherButler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed Assert.md so far. Please review my changes to make sure I haven't accidentally changed the meaning of anything. Also, please address my comments and queries. I'll start on the other files tomorrow.

@@ -1,11 +1,33 @@
## Assert
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Should we change this to "mbed_assert" to match the macro name?

}
```

You can use the `MBED_STATIC_ASSERT` macro for compile-time evaluation of expressions. If the evaluation fails, the passed in error message prints, and the compilation fails.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: This says "MBED_STATIC_ASSERT", but the paragraph below says "MBED_ASSERT_STATIC". Are these two separate macros, or is one incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, its a typo, let me fix and others. thanks for the review.

[Add example(s) here.]
You can use the `MBED_ASSERT` macro for runtime evaluation of expressions. If the evaluation fails, an error message prints to bash in the below format. Note that the `MBED_ASSERT` macro is available in the debug and develop build profiles but not in the release build profile.

mbed assertation failed: <EVALUATED EXPRESSION>, file: <FILE NAME>, line <LINE NUMBER IN FILE>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Should this be part of the code block that starts on line 17? If not, please put it in code format and give it some context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Amanda, I fixed the comments but kept the heading as "Assert" since we are explaining the usage/purpose in the doc anyway, also I thought if we change to Mbed Assert, the same applies to many other places as well, so I thought we will keep the heading as Assert. Let me know if you think otherwise.


[Add example(s) here.]
You can use the `MBED_ASSERT` macro for runtime evaluation of expressions. If the evaluation fails, an error message prints to bash in the below format. Note that the `MBED_ASSERT` macro is available in the debug and develop build profiles but not in the release build profile.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to link to the build profiles page.

Copy link
Contributor

@AnotherButler AnotherButler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed Debug.md. Please review my changes to make sure I didn't accidentally change the meaning of anything. Please also address my comments and queries.


### Debug example

[Add example here.]
[![View Example](https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-example-platform-utils)](https://github.com/ARMmbed/mbed-os-example-platform-utils)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sg- Should this be in the Mbed example teams folder like the other examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example program demonstrates MemoryStats and then have few things to demonstrate debug functions. That's why I have it as a separate example in its own repo. Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sam,
Yeah, it makes more sense to move it to example teams folder. Ill do that, Thanks for pointing that out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sam, Looks like I need permission to publish to mbed_example. When I try to publish "mbed_example" is not showing as a option for me. Can you please add me to the mbed_example repo?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is your developer account name?

[Embed class reference here. If you've never done this before, please ask your editor.]
[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.6/mbed-os-api-doxy/group__platform__debug.html)

### Debug functions usage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the content in this section, but this section breaks the standardization with the other APIs. Could we make it a second example or move some of the content up to the description area?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yes, we can move it to description area.


[Embed class reference here. If you've never done this before, please ask your editor.]
[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.6/mbed-os-api-doxy/group__platform__debug.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Does this link work for you? I can't get it to work.

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 it doesn't work now, it depends on my other change coming into mbed-os side.

Copy link
Contributor

@AnotherButler AnotherButler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've copy edited the remaining two documents. Please review my edits to make sure I didn't accidentally change the meaning of any content. Please also address my queries and comments.

@@ -1,5 +1,21 @@
## Error

The error function generates a fatal runtime error, which allows the user to dump a message to the serial line, halt the program and place the device in an idle mode with a blinking red LED.
Mbed OS provides an error function to output messages to `STDIO` at runtime when the system encounters a fatal error and causes the application to terminate. `mbed_error.h` declares this error message. Note that the error function outputs the error message in debug and develop builds only. In release builds, the error function does not generate any output, but the application is still be terminated.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Who or what terminates the application? Please clarify for active voice. [Note: I'll fix that extra "be" that I accidentally left in there after I know how to change the passive to active voice.]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, its the mbed-OS error function implementation that terminates the application.

You can read more about the Error function in [its documentation](https://github.com/ARMmbed/mbed-os/blob/master/platform/mbed_error.h).
### Error function reference

[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.6/mbed-os-api-doxy/group__platform__error.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Does this link work for you? I see "Page error".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, it depends on my other change coming into mbed-os side.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. In the description of this PR, could you please list the mbed-os PR#s as dependencies?

[Add embedded class reference here. If you've never done this, please talk to your editor.]
### MemoryStats functions reference

[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/v5.6/mbed-os-api-doxy/group__platform__stats.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Does this link work for you? I see "Page error".


### MemoryStats example

[Add example here.]
[![View Example](https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-example-platform-utils)](https://github.com/ARMmbed/mbed-os-example-platform-utils)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sg- Should this be in the Mbed example teams folder like the other API examples?

@SenRamakri
Copy link
Contributor Author

Depends on - ARMmbed/mbed-os#5372

@@ -1,11 +1,15 @@
## MemoryStats

[Add description here.]
Mbed OS provides a set of functions that you can use to capture the memory statistics at runtime. `mbed_stats.h` declares these functions. You can use memory statistics functions to capture heap usage, cumulative stack usage or stack usage per thread at runtime. To enable memory usage monitoring, you must build Mbed OS with the following macros.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some differences between tracing and stats. It would be good to call them out explicitly and explain how each would be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, actually I shouldn't have mentioned MBED_MEM_TRACING_ENABLED at all. There is a separate requirement for writing "mem_trace functions" assigned to Martin. So let me clean this up and remove the references to MBED_MEM_TRACING_ENABLED. I think it should be captured in mem_trace docs, not here.

@AnotherButler
Copy link
Contributor

@SenRamakri What are the PR #s for the mbed-os repo dependencies?

@SenRamakri
Copy link
Contributor Author

@AnotherButler It depends on PR ARMmbed/mbed-os#5372. Please see my comment from yesterday.

SenRamakri and others added 9 commits November 2, 2017 10:39
Copy edit, mostly for active voice, parallelism and spelling.
Copy edit file, mostly for active voice and punctuation around restrictive clauses.
Copy edit for active voice, branding and consistent tense across docs.
Edit file for active voice, expansion of words and formatting.
@SenRamakri SenRamakri force-pushed the sen_AssertAndOtherDocs branch from c692cf1 to bd3c432 Compare November 2, 2017 15:57
@AnotherButler
Copy link
Contributor

@SenRamakri Is this ready to merge now, or are there any other dependencies or reviews we still need?

@SenRamakri
Copy link
Contributor Author

This can be merged now as the dependency on mbed-os side is merged.

@AnotherButler AnotherButler merged commit 4c44489 into ARMmbed:new_engine Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants