Skip to content

Commit 81e6831

Browse files
authored
Merge pull request rails#47429 from ybakos/guide_debugging
2 parents 1fd0bc1 + 766fa24 commit 81e6831

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

guides/source/debugging_rails_applications.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Please check its [documentation](https://github.com/ruby/debug) for usage.
333333

334334
### Entering a Debugging Session
335335

336-
By default, a debugging session will start after the `debug` library is required, which happens when your app boots. But don't worry, the session won't interfere your program.
336+
By default, a debugging session will start after the `debug` library is required, which happens when your app boots. But don't worry, the session won't interfere with your application.
337337

338338
To enter the debugging session, you can use `binding.break` and its aliases: `binding.b` and `debugger`. The following examples will use `debugger`:
339339

@@ -371,11 +371,11 @@ Processing by PostsController#index as HTML
371371
(rdbg)
372372
```
373373

374-
You can exit the debugging session at any time and continue your application execution with the `continue` (or `c`) command. Or, to exit both the debugging session and your application, use the `quit` (or `q`) command.
374+
You can exit the debugging session at any time and continue your application execution with the `continue` (or `c`) command. Or, to exit both the debugging session and your application, use the `quit` (or `q`) command.
375375

376376
### The Context
377377

378-
After entering the debugging session, you can type in Ruby code as you're in a Rails console or IRB.
378+
After entering the debugging session, you can type in Ruby code as if you are in a Rails console or IRB.
379379

380380
```rb
381381
(rdbg) @posts # ruby
@@ -385,7 +385,7 @@ After entering the debugging session, you can type in Ruby code as you're in a R
385385
(rdbg)
386386
```
387387

388-
You can also use `p` or `pp` command to evaluate Ruby expressions (e.g. when a variable name conflicts with a debugger command).
388+
You can also use the `p` or `pp` command to evaluate Ruby expressions, which is useful when a variable name conflicts with a debugger command.
389389

390390
```rb
391391
(rdbg) p headers # command
@@ -400,15 +400,15 @@ You can also use `p` or `pp` command to evaluate Ruby expressions (e.g. when a v
400400
(rdbg)
401401
```
402402

403-
Besides direct evaluation, debugger also helps you collect rich amount of information through different commands. Just to name a few here:
403+
Besides direct evaluation, the debugger also helps you collect a rich amount of information through different commands, such as:
404404

405405
- `info` (or `i`) - Information about current frame.
406406
- `backtrace` (or `bt`) - Backtrace (with additional information).
407407
- `outline` (or `o`, `ls`) - Available methods, constants, local variables, and instance variables in the current scope.
408408

409409
#### The `info` Command
410410

411-
It'll give you an overview of the values of local and instance variables that are visible from the current frame.
411+
`info` provides an overview of the values of local and instance variables that are visible from the current frame.
412412

413413
```rb
414414
(rdbg) info # command
@@ -428,7 +428,7 @@ It'll give you an overview of the values of local and instance variables that ar
428428

429429
#### The `backtrace` Command
430430

431-
When used without any options, it lists all the frames on the stack:
431+
When used without any options, `backtrace` lists all the frames on the stack:
432432

433433
```rb
434434
=>#0 PostsController#index at ~/projects/rails-guide-example/app/controllers/posts_controller.rb:7
@@ -449,21 +449,21 @@ Every frame comes with:
449449
- Call location
450450
- Additional information (e.g. block or method arguments)
451451

452-
This will give you a great sense about what's happening in your app. However, you probably will notice that:
452+
This will give you a great sense about what is happening in your app. However, you probably will notice that:
453453

454454
- There are too many frames (usually 50+ in a Rails app).
455455
- Most of the frames are from Rails or other libraries you use.
456456

457-
Don't worry, the `backtrace` command provides 2 options to help you filter frames:
457+
The `backtrace` command provides 2 options to help you filter frames:
458458

459459
- `backtrace [num]` - only show `num` numbers of frames, e.g. `backtrace 10` .
460460
- `backtrace /pattern/` - only show frames with identifier or location that matches the pattern, e.g. `backtrace /MyModel/`.
461461

462-
It's also possible to use these options together: `backtrace [num] /pattern/`.
462+
It is also possible to use these options together: `backtrace [num] /pattern/`.
463463

464464
#### The `outline` Command
465465

466-
This command is similar to `pry` and `irb`'s `ls` command. It will show you what's accessible from the current scope, including:
466+
`outline` is similar to `pry` and `irb`'s `ls` command. It will show you what is accessible from the current scope, including:
467467

468468
- Local variables
469469
- Instance variables
@@ -558,7 +558,7 @@ And to remove them, you can use:
558558
Stop by #0 BP - Line /Users/st0012/projects/rails-guide-example/app/controllers/posts_controller.rb:28 (line)
559559
```
560560

561-
**Set a breakpoint on a given method call - e.g. `b @post.save`**
561+
Set a breakpoint on a given method call - e.g. `b @post.save`.
562562

563563
```rb
564564
[20, 29] in ~/projects/rails-guide-example/app/controllers/posts_controller.rb
@@ -602,7 +602,7 @@ Stop by #0 BP - Method @post.save at /Users/st0012/.rbenv/versions/3.0.1/lib/r
602602
603603
#### The `catch` Command
604604
605-
**Stop when an exception is raised - e.g. `catch ActiveRecord::RecordInvalid`**
605+
Stop when an exception is raised - e.g. `catch ActiveRecord::RecordInvalid`.
606606
607607
```rb
608608
[20, 29] in ~/projects/rails-guide-example/app/controllers/posts_controller.rb
@@ -645,7 +645,7 @@ Stop by #1 BP - Catch "ActiveRecord::RecordInvalid"
645645

646646
#### The `watch` Command
647647

648-
**Stop when the instance variable is changed - e.g. `watch @_response_body`**
648+
Stop when the instance variable is changed - e.g. `watch @_response_body`.
649649

650650
```rb
651651
[20, 29] in ~/projects/rails-guide-example/app/controllers/posts_controller.rb
@@ -689,7 +689,7 @@ Stop by #0 BP - Watch #<PostsController:0x00007fce69ca5320> @_response_body =
689689

690690
#### Breakpoint Options
691691

692-
In addition to different types of breakpoints, you can also specify options to achieve more advanced debugging workflow. Currently, the debugger supports 4 options:
692+
In addition to different types of breakpoints, you can also specify options to achieve more advanced debugging workflows. Currently, the debugger supports 4 options:
693693

694694
- `do: <cmd or expr>` - when the breakpoint is triggered, execute the given command/expression and continue the program:
695695
- `break Foo#bar do: bt` - when `Foo#bar` is called, print the stack frames

0 commit comments

Comments
 (0)