shithub: mc

ref: 303798469e8afe0e514c667f3c8c7ae2c65e58c5
dir: /lib/std/backtrace+x64.myr/

View raw version
use "types"

pkg std =
	const backtrace	: (pc	: void#[:] -> std.size)
;;

type stackrec = struct
	next	: stackrec#
	pc	: void#
;;

extern const getbp	: (-> stackrec#)
const backtrace = {pc
	var bp, i, len

	i = 0
	len = pc.len
	bp = getbp()
	while bp != (0 : stackrec#) && i < len
		pc[i++] = bp.pc
		bp = bp.next
	;;
	-> i
}