Was the code built with optimizations disabled?

On Tuesday, July 27, 2021 at 1:57:17 PM UTC-4 林 子鹏 wrote:

> When I use delve to debug this project(dlv debug t.go): 
>
> //t.gopackage main
> import (
>     "fmt"
>     "os"
>     "reflect"
>     "unsafe"
> )
> func main() {
>     s1 := make([]uint8, 0)
>     aboutSlice(&s1, "s1")
>     s2 := make([]uint8, 8)
>     aboutSlice(&s2, "s2")
>     new_s1 := append(s1, 10)
>     new_s2 := append(s2, 20)
>     aboutSlice(&new_s1, "new_s1")
>     aboutSlice(&new_s2, "new_s2")
>     os.Exit(0)
> }
> func aboutSlice(s *[]uint8, n string) {
>     fmt.Printf("%s:\tmem_addr:%p\tsize:%v\taddr:%#x\tlen:%v\tcap:%v\n", n, s, 
> unsafe.Sizeof(*s), (*reflect.SliceHeader)(unsafe.Pointer(s)).Data, len(*s), 
> cap(*s))
> }
>
> I want to analyze the behavior of function growslice(in 
> runtime/slice.go),and then set breakpoints on func growslice,I use n and s 
> to analyze it, but it will skip some step, like the picture below:
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/092abda0-72ba-429d-96df-60faf570198fn%40googlegroups.com.

Reply via email to