(level int)
| 693 | } |
| 694 | |
| 695 | func (ls *LState) stackTrace(level int) string { |
| 696 | buf := []string{} |
| 697 | header := "stack traceback:" |
| 698 | if ls.currentFrame != nil { |
| 699 | i := 0 |
| 700 | for dbg, ok := ls.GetStack(i); ok; dbg, ok = ls.GetStack(i) { |
| 701 | cf := dbg.frame |
| 702 | buf = append(buf, fmt.Sprintf("\t%v in %v", ls.Where(i), ls.formattedFrameFuncName(cf))) |
| 703 | if !cf.Fn.IsG && cf.TailCall > 0 { |
| 704 | for tc := cf.TailCall; tc > 0; tc-- { |
| 705 | buf = append(buf, "\t(tailcall): ?") |
| 706 | i++ |
| 707 | } |
| 708 | } |
| 709 | i++ |
| 710 | } |
| 711 | } |
| 712 | buf = append(buf, fmt.Sprintf("\t%v: %v", "[G]", "?")) |
| 713 | buf = buf[intMax(0, intMin(level, len(buf))):len(buf)] |
| 714 | if len(buf) > 20 { |
| 715 | newbuf := make([]string, 0, 20) |
| 716 | newbuf = append(newbuf, buf[0:7]...) |
| 717 | newbuf = append(newbuf, "\t...") |
| 718 | newbuf = append(newbuf, buf[len(buf)-7:len(buf)]...) |
| 719 | buf = newbuf |
| 720 | } |
| 721 | return fmt.Sprintf("%s\n%s", header, strings.Join(buf, "\n")) |
| 722 | } |
| 723 | |
| 724 | func (ls *LState) formattedFrameFuncName(fr *callFrame) string { |
| 725 | name, ischunk := ls.frameFuncName(fr) |
no test coverage detected