Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Improve debugging of pointer values #2075

Merged
merged 2 commits into from
Nov 11, 2018
Merged

Improve debugging of pointer values #2075

merged 2 commits into from
Nov 11, 2018

Conversation

brycekahle
Copy link
Contributor

See #1989

This displays the address of the variable the pointer is pointing to (for pointer comparison). It also allows expansion in the debugger.

Example code:

package main

import "testing"

func TestX(t *testing.T) {
	var i, j int
	i = 0
	j = 1
	k := []string{"asdf"}
	var p = &i
	var q = &j
	var r = &k
	t.Logf("%#v %#v %#v", p, q, r)
}

Shown in debugger:
screen shot 2018-11-02 at 2 35 52 pm

@brycekahle
Copy link
Contributor Author

This does add an intermediate level to the expansion. Alternatively, I could attempt to rework the code to display it like so:

p: 0 <*int>(0xc000078080)
q: 1 <*int>(0xc000078088)
r: <*[]string>(0xc000086080)
  [0]: "asdf"

@ramya-rao-a
Copy link
Contributor

Re-working this to look like
#2075 (comment) would be simple for simple types like int, but would get complicated for arrays and maps I believe.

The current solution should be good enough.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants