delve icon indicating copy to clipboard operation
delve copied to clipboard

confused debug output of local variable(runtime.growslice function in go.1..18.2)

Open qshuai opened this issue 2 years ago • 2 comments

  1. What version of Delve are you using (dlv version)?
Delve Debugger
Version: 1.8.3
Build: $Id: f92bb46b82b3b92d79ce59c4b55eeefbdd8d040c $
  1. What version of Go are you using? (go version)?
go version go1.18.2 darwin/amd64
  1. What operating system and processor architecture are you using?
System Version: macOS 11.3.1 (20E241)
Kernel Version: Darwin 20.4.0
CPU: Intel
Arch: x86_64
  1. What did you do? When I append a new element to the empty slice(Len: 0, Cap: 0),debug‘s output of newcap and old.cap are conflicting. Luckly, the program works well. image
  2. What did you expect to see? Shouldn't newcap and old.cap be equal?
(dlv) p newcap
0
(dlv) p old.cap
0
  1. What did you see instead?
(dlv) p newcap
1
(dlv) p old.cap
0

qshuai avatar Jun 06 '22 02:06 qshuai

@dr2chase At that line both the variables newcap and cap have the same loclist: DW_OP_reg4 (which happens to be correct for cap). This is optimized code so I don't know if I should even open an issue in golang/go.

aarzilli avatar Jun 09 '22 09:06 aarzilli

Not fixed on tip. I made a few changes to location list generation that might have helped, but not in this case. Fixing this kind of location list shortfall is on my list for the next few months. No guarantee that I'll be able to fix this one, but I'll look.

dr2chase avatar Jun 24 '22 19:06 dr2chase