First of all, thank you very much for your answer. I use the giant font 
because I copied it directly from Google Translate.
When I debug grow func of mheap.go file, I print the ask variable, it 
output No symbol "ask" in current context, print npage it output optimized 
out.

func (h *mheap) grow(npage uintptr) bool {
ask := npage << _PageShift
v, size := h.sysAlloc(ask)
if v == nil {
print("runtime: out of memory: cannot allocate ", ask, "-byte block (", 
memstats.heap_sys, " in use)\n")
return false
}

// Create a fake "in use" span and free it, so that the
// right coalescing happens.
s := (*mspan)(h.spanalloc.alloc())
s.init(uintptr(v), size/pageSize)
h.setSpans(s.base(), s.npages, s)
atomic.Store(&s.sweepgen, h.sweepgen)
s.state = _MSpanInUse
h.pagesInUse += uint64(s.npages)
h.freeSpanLocked(s, false, true, 0)
return true
}


在 2019年3月15日星期五 UTC+8上午12:49:51,Jake Montgomery写道:
>
> First off. Please don't use a giant font in this group. It adds no 
> valuable information, and makes it seem like you are yelling at the reader.
>
> I use delve <https://github.com/go-delve/delve> not gdb, so I can not 
> speak directly to that. I use -gcflags="-N -l", and so far it has always 
> produced a reasonably debuggable (with delve 
> <https://github.com/go-delve/delve> at least) executable.
>
> Your question is probably too vague to answer though. What, specifically, 
> are you experiencing as being "optimized out"? If you provided code for a 
> small sample program, and told us what you actually see, and what you 
> expect to see, you would have a better chance of a useful response. 
>
>
> On Thursday, March 14, 2019 at 12:03:50 AM UTC-4, mount...@gmail.com 
> wrote:
>>
>>
>> Very strange, when I compile with go build -o main -gcflags "-N -l" 
>> main.go, it appears optimized out when debugging with gdb.
>>
>> Who knows why?
>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to