mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 09:46:56 +08:00
proc: for optimized functions allow .closureptr to not exist (#3808)
* proc: flag variables correctly when range-over-func stmts are used Argument variables of a range-over-func body closure should be returned flagged as normal local variables, not as function arguments. Updates #3806 * proc: for optimized functions allow .closureptr to not exist For optimized functions .closureptr is sometimes omitted from DWARF, allow it to be 0 and try to recover the range-over-func stack by best effort. Fixes #3806
This commit is contained in:
committed by
GitHub
parent
b9fadbae9b
commit
582305a813
51
_fixtures/setiterator.go
Normal file
51
_fixtures/setiterator.go
Normal file
@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"iter"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
set := New[string]()
|
||||
for i := 10; i < 100; i++ {
|
||||
set.Add(strconv.Itoa(i))
|
||||
}
|
||||
PrintAllElements[string](set)
|
||||
}
|
||||
|
||||
// Set holds a set of elements.
|
||||
type Set[E comparable] struct {
|
||||
m map[E]struct{}
|
||||
}
|
||||
|
||||
// New returns a new [Set].
|
||||
func New[E comparable]() *Set[E] {
|
||||
return &Set[E]{m: make(map[E]struct{})}
|
||||
}
|
||||
|
||||
// All is an iterator over the elements of s.
|
||||
func (s *Set[E]) All() iter.Seq[E] {
|
||||
return func(yield func(E) bool) {
|
||||
for v := range s.m {
|
||||
tmp := make([]byte, 1024)
|
||||
str := string(tmp)
|
||||
if !yield(v) {
|
||||
return
|
||||
}
|
||||
go func() { println(str) }()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Set[E]) Add(v E) {
|
||||
s.m[v] = struct{}{}
|
||||
}
|
||||
|
||||
func PrintAllElements[E comparable](s *Set[E]) {
|
||||
for v := range s.All() {
|
||||
time.Sleep(100 * time.Second)
|
||||
fmt.Println(v)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user