Skip to content
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

Gdb usage appendex #234

Merged
merged 4 commits into from
Sep 3, 2020
Merged

Conversation

yusefkarim
Copy link
Contributor

Refers to #10

@yusefkarim yusefkarim requested a review from a team as a code owner May 4, 2020 14:25
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jamesmunns (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-resources labels May 4, 2020
Copy link
Member

@hargoniX hargoniX left a comment

Choose a reason for hiding this comment

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

Despite my lots of comments most of them are really just about the use of shortcuts which I don't feel are good for a cheatsheet for a beginner, they can figure out the shortcuts themselves if it is mentioned at the beginning that they exist and are usually mnemonics such as b(reak). Encouraging them to use shortcuts though just feels like a potential error and confusion source for me. Apart from that there is really only the comment on how to break, other than that great work and a good addition!


## General Debugging

> **NOTE:** Many of the commands you see below can be executed using a short form. For example, `continue` can simply be used as `c`, or `break $location` can be used as `b $location`. While you are learning GDB try to see how short you can get the commands to go before GDB doesn't recognize it!
Copy link
Member

Choose a reason for hiding this comment

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

Not quite sure about this comment, users might end up with some confusing behaviour they don't really understand, I'd say getting the short forms of the command is not something for a person who's just learning GDB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You may be right, I have not removed it yet, but made a slight change in addition to getting rid of all the shortcuts in the main section. If you still think it could lead to any confusion, let me know and we can take it out. Thanks.


* `break $location`: Set a breakpoint at a place in your code. The value of `$location` can include:
* `b 123` - Break on line 123 of the currently displayed file
* `b main.rs:123` - Break on line 123 of `main.rs`
Copy link
Member

Choose a reason for hiding this comment

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

I'd say we should mention that it is possible to use break like b function_name or even at specific locations of memory etc, refer to the gdb help text.

Copy link
Member

Choose a reason for hiding this comment

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

Also if we can agree to remove the shortcuts from the material for now just to make it more clear, after all they aren't being used consistently right now either, e.g. i b is not mentioned along info break.

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 added two more examples, could likely squish these into two again but have source filename, function name, label name, and line number all explained (like in help text). These would be more concise but maybe a little harder to read. Any preference?

* `b main.rs:123` - Break on line 123 of `main.rs`
* `info break`: Display current breakpoints
* `delete`: Delete all breakpoints
* `d $n`: Delete breakpoint `$n`
Copy link
Member

Choose a reason for hiding this comment

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

Same not on shortcuts

* `clear main.rs:$function`: Delete breakpoint at entry of `$function` in `main.rs`
* `clear main.rs:123`: Delete breakpoint on line 123 of `main.rs`
* `enable`: Enable all set breakpoints
* `en $n`: Enable breakpoint `$n`
Copy link
Member

Choose a reason for hiding this comment

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

Shortcuts

* `enable`: Enable all set breakpoints
* `en $n`: Enable breakpoint `$n`
* `disable`: Disable all set breakpoints
* `dis $n`: Disable breakpoint `$n`
Copy link
Member

Choose a reason for hiding this comment

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

Shortcuts


### Controlling Execution

* `continue`: Begin execution of your program
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer something like "Begin or continue execution of your program" but I guess that's obvious from the name...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better to be explicit, I added your suggestion. Nice catch.


* `continue`: Begin execution of your program
* `next`: Execute the next line of your program
* `n $n`: Repeat `next` `$n` number times
Copy link
Member

Choose a reason for hiding this comment

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

Shorcuts

* `n $n`: Repeat `next` `$n` number times
* `nexti`: Same as `next` but with machine instructions instead
* `step`: Execute the next line, if the next line includes a call to another function, step into that code
* `s $n`: Repeat `step` `$n` number times
Copy link
Member

Choose a reason for hiding this comment

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

Shorcuts

### Looking at the Symbol Table

* `info functions $regex`: Print the names and data types of functions matched by `$regex`, omit `$regex` to print all functions
* `i func main`: Print names and types of defined functions that contain the word `main`
Copy link
Member

Choose a reason for hiding this comment

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

Shorthand...I'll stop mentioning them from now on.

Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

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

Great addition! Just a couple nitpicks from my side.

src/appendix/2-how-to-use-gdb/README.md Outdated Show resolved Hide resolved
src/appendix/2-how-to-use-gdb/README.md Outdated Show resolved Hide resolved
Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
@eldruin
Copy link
Member

eldruin commented Sep 3, 2020

Fine for me now but let's wait for @hargoniX who was much more involved here.

Copy link
Member

@hargoniX hargoniX left a comment

Choose a reason for hiding this comment

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

LGTM to me as well!

@eldruin
Copy link
Member

eldruin commented Sep 3, 2020

Great, then let's get this merged!

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 3, 2020

Build succeeded:

@bors bors bot merged commit 179402e into rust-embedded:master Sep 3, 2020
@eldruin eldruin mentioned this pull request Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-resources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants