mirror of
https://github.com/jbranchaud/til
synced 2026-01-20 07:28:02 +00:00
Compare commits
8 Commits
a488653873
...
0bd705d69c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bd705d69c | ||
|
|
527038ca23 | ||
|
|
b972673008 | ||
|
|
cc31aae25a | ||
|
|
26f30c3225 | ||
|
|
e14da2f207 | ||
|
|
5615da920f | ||
|
|
c60c63f554 |
13
README.md
13
README.md
@@ -12,6 +12,10 @@ For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-
|
|||||||
|
|
||||||
_1555 TILs and counting..._
|
_1555 TILs and counting..._
|
||||||
|
|
||||||
|
See some of the other learning resources I work on:
|
||||||
|
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||||
|
- [Vim Un-Alphabet](https://www.youtube.com/playlist?list=PL46-cKSxMYYCMpzXo6p0Cof8hJInYgohU)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Categories
|
### Categories
|
||||||
@@ -191,7 +195,7 @@ _1555 TILs and counting..._
|
|||||||
- [Aliasing An Ansible Host](devops/aliasing-an-ansible-host.md)
|
- [Aliasing An Ansible Host](devops/aliasing-an-ansible-host.md)
|
||||||
- [Allow Cross-Origin Requests To Include Cookies](devops/allow-cross-origin-requests-to-include-cookies.md)
|
- [Allow Cross-Origin Requests To Include Cookies](devops/allow-cross-origin-requests-to-include-cookies.md)
|
||||||
- [Allow HTTPS Through Your UFW Firewall](devops/allow-https-through-your-ufw-firewall.md)
|
- [Allow HTTPS Through Your UFW Firewall](devops/allow-https-through-your-ufw-firewall.md)
|
||||||
- [Check For Cached Site Assocation File For iOS](devops/check-for-cached-site-association-file-for-ios.md)
|
- [Check For Cached Site Association File For iOS](devops/check-for-cached-site-association-file-for-ios.md)
|
||||||
- [Check The Status of All Services](devops/check-the-status-of-all-services.md)
|
- [Check The Status of All Services](devops/check-the-status-of-all-services.md)
|
||||||
- [Check The Syntax Of nginx Files](devops/check-the-syntax-of-nginx-files.md)
|
- [Check The Syntax Of nginx Files](devops/check-the-syntax-of-nginx-files.md)
|
||||||
- [Connect To An RDS PostgreSQL Database](devops/connect-to-an-rds-postgresql-database.md)
|
- [Connect To An RDS PostgreSQL Database](devops/connect-to-an-rds-postgresql-database.md)
|
||||||
@@ -403,6 +407,7 @@ _1555 TILs and counting..._
|
|||||||
|
|
||||||
- [Access Go Docs Offline](go/access-go-docs-offline.md)
|
- [Access Go Docs Offline](go/access-go-docs-offline.md)
|
||||||
- [Add A Method To A Struct](go/add-a-method-to-a-struct.md)
|
- [Add A Method To A Struct](go/add-a-method-to-a-struct.md)
|
||||||
|
- [Basic Delve Debugging Session](go/basic-delve-debugging-session.md)
|
||||||
- [Build For A Specific OS And Architecture](go/build-for-a-specific-os-and-architecture.md)
|
- [Build For A Specific OS And Architecture](go/build-for-a-specific-os-and-architecture.md)
|
||||||
- [Check If Cobra Flag Was Set](go/check-if-cobra-flag-was-set.md)
|
- [Check If Cobra Flag Was Set](go/check-if-cobra-flag-was-set.md)
|
||||||
- [Combine Two Slices](go/combine-two-slices.md)
|
- [Combine Two Slices](go/combine-two-slices.md)
|
||||||
@@ -752,7 +757,7 @@ _1555 TILs and counting..._
|
|||||||
- [Check If Clusters Are Upgrade Compatible](postgres/check-if-clusters-are-upgrade-compatible.md)
|
- [Check If Clusters Are Upgrade Compatible](postgres/check-if-clusters-are-upgrade-compatible.md)
|
||||||
- [Check If The Local Server Is Running](postgres/check-if-the-local-server-is-running.md)
|
- [Check If The Local Server Is Running](postgres/check-if-the-local-server-is-running.md)
|
||||||
- [Check If User Role Exists For Database](postgres/check-if-user-role-exists-for-database.md)
|
- [Check If User Role Exists For Database](postgres/check-if-user-role-exists-for-database.md)
|
||||||
- [Check Table For Any Oprhaned Records](postgres/check-table-for-any-orphaned-records.md)
|
- [Check Table For Any Orphaned Records](postgres/check-table-for-any-orphaned-records.md)
|
||||||
- [Checking Inequality](postgres/checking-inequality.md)
|
- [Checking Inequality](postgres/checking-inequality.md)
|
||||||
- [Checking The Type Of A Value](postgres/checking-the-type-of-a-value.md)
|
- [Checking The Type Of A Value](postgres/checking-the-type-of-a-value.md)
|
||||||
- [Clear The Screen In psql](postgres/clear-the-screen-in-psql.md)
|
- [Clear The Screen In psql](postgres/clear-the-screen-in-psql.md)
|
||||||
@@ -1859,11 +1864,11 @@ I shamelessly stole this idea from
|
|||||||
|
|
||||||
* [Today I Learned by Hashrocket](https://til.hashrocket.com)
|
* [Today I Learned by Hashrocket](https://til.hashrocket.com)
|
||||||
* [jwworth/til](https://github.com/jwworth/til)
|
* [jwworth/til](https://github.com/jwworth/til)
|
||||||
* [thoughtbot/til](https://github.com/thoughtbot/til)
|
* [til.simonwillison.net](https://til.simonwillison.net/)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
© 2015-2022 Josh Branchaud
|
© 2015-2025 Josh Branchaud
|
||||||
|
|
||||||
This repository is licensed under the MIT license. See `LICENSE` for
|
This repository is licensed under the MIT license. See `LICENSE` for
|
||||||
details.
|
details.
|
||||||
|
|||||||
63
go/basic-delve-debugging-session.md
Normal file
63
go/basic-delve-debugging-session.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Basic Delve Debugging Session
|
||||||
|
|
||||||
|
When using [delve](https://github.com/go-delve/delve) to debug a Go program,
|
||||||
|
these are the series of things I usually find myself doing.
|
||||||
|
|
||||||
|
First, I start running the program with `dlv` including any arguments after a `--` (in my case, the `solve` subcommand and a filename).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ dlv debug . -- solve samples/001.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
`dlv` starts up and is ready to run my program from the beginning. I'll need to
|
||||||
|
set a couple breakpoints before continuing. I do this with the `break` command,
|
||||||
|
specifying the filename and line number.
|
||||||
|
|
||||||
|
```
|
||||||
|
(dlv) break main.go:528
|
||||||
|
Breakpoint 1 set at 0x10c1a5bea for main.traversePuzzleIterative() ./main.go:528
|
||||||
|
(dlv) break main.go:599
|
||||||
|
Breakpoint 2 set at 0x10c1a6dcc for main.traversePuzzleIterative() ./main.go:599
|
||||||
|
```
|
||||||
|
|
||||||
|
Now I can continue which will run the program until hitting a breakpoint.
|
||||||
|
|
||||||
|
```
|
||||||
|
(dlv) continue
|
||||||
|
> [Breakpoint 2] main.traversePuzzleIterative() ./main.go:599 (hits goroutine(1):1 total:1) (PC: 0x10c1a6dcc)
|
||||||
|
594: }
|
||||||
|
595: }
|
||||||
|
596:
|
||||||
|
597: topStackFrame := stack[len(stack)-1]
|
||||||
|
598: // if the current stack frame has more values, try the next
|
||||||
|
=> 599: if len(topStackFrame.PossibleValues) > 0 {
|
||||||
|
600: nextValue := topStackFrame.PossibleValues[0]
|
||||||
|
601: topStackFrame.PossibleValues = topStackFrame.PossibleValues[1:]
|
||||||
|
602: topStackFrame.CurrValue = nextValue
|
||||||
|
603:
|
||||||
|
604: // Undo the last placement and make a new one
|
||||||
|
```
|
||||||
|
|
||||||
|
I can see the context around the line we've stopped on. From here I can dig
|
||||||
|
into the current state of the program by looking at local variables (`locals`)
|
||||||
|
or printing out a specific value (`print someVar`). I can continue to step
|
||||||
|
through the program line by line with `next` or eventually run `continue` to
|
||||||
|
proceed to the next breakpoint.
|
||||||
|
|
||||||
|
```
|
||||||
|
(dlv) locals
|
||||||
|
diagnostics = main.Diagnostics {BacktrackCount: 0, NodeVisitCount: 1, ValidityCheckCount: 2,...+2 more}
|
||||||
|
stack = []main.StackData len: 1, cap: 1, [...]
|
||||||
|
emptyCellPositions = [][]int len: 3, cap: 4, [...]
|
||||||
|
emptyCellIndex = 1
|
||||||
|
status = "Invalid"
|
||||||
|
topStackFrame = main.StackData {RowIndex: 1, ColumnIndex: 7, PossibleValues: []int len: 8, cap: 8, [...],...+1 more}
|
||||||
|
(dlv) print topStackFrame
|
||||||
|
main.StackData {
|
||||||
|
RowIndex: 1,
|
||||||
|
ColumnIndex: 7,
|
||||||
|
PossibleValues: []int len: 8, cap: 8, [2,3,4,5,6,7,8,9],
|
||||||
|
CurrValue: 1,}
|
||||||
|
(dlv) next
|
||||||
|
> main.traversePuzzleIterative() ./main.go:600 (PC: 0x10c1a6dea)
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user