(level int)
| 793 | } |
| 794 | |
| 795 | func (ls *LState) stackTrace(level int) string { |
| 796 | buf := []string{} |
| 797 | header := "stack traceback:" |
| 798 | if ls.currentFrame != nil { |
| 799 | i := 0 |
| 800 | for dbg, ok := ls.GetStack(i); ok; dbg, ok = ls.GetStack(i) { |
| 801 | cf := dbg.frame |
| 802 | buf = append(buf, fmt.Sprintf("\t%v in %v", ls.Where(i), ls.formattedFrameFuncName(cf))) |
| 803 | if !cf.Fn.IsG && cf.TailCall > 0 { |
| 804 | for tc := cf.TailCall; tc > 0; tc-- { |
| 805 | buf = append(buf, "\t(tailcall): ?") |
| 806 | i++ |
| 807 | } |
| 808 | } |
| 809 | i++ |
| 810 | } |
| 811 | } |
| 812 | buf = append(buf, fmt.Sprintf("\t%v: %v", "[G]", "?")) |
| 813 | buf = buf[intMax(0, intMin(level, len(buf))):len(buf)] |
| 814 | if len(buf) > 20 { |
| 815 | newbuf := make([]string, 0, 20) |
| 816 | newbuf = append(newbuf, buf[0:7]...) |
| 817 | newbuf = append(newbuf, "\t...") |
| 818 | newbuf = append(newbuf, buf[len(buf)-7:len(buf)]...) |
| 819 | buf = newbuf |
| 820 | } |
| 821 | return fmt.Sprintf("%s\n%s", header, strings.Join(buf, "\n")) |
| 822 | } |
| 823 | |
| 824 | func (ls *LState) formattedFrameFuncName(fr *callFrame) string { |
| 825 | name, ischunk := ls.frameFuncName(fr) |
no test coverage detected