查找具有跟踪活动的所有函数的值

Find value of all functions with trace active

如何找到我已激活 trace 的所有功能的值?我知道我可以关闭全局 tracingState,但我发现我忘记了正在跟踪哪些函数,并且想知道是否有办法检索此信息?简单的例子,

tst <- function(cond) { if (cond) 'yay' else 'neigh' }
tst1 <- function(x) { x*x }
trace('tst', tracer=browser)
trace('tst1', tracer=browser)

## Can I retrieve a vector of functions being traced?
## would like a result here to be:
## [1] "tst"  "tst1"

## Cleaning
untrace('tst')
untrace('tst1')

我没有意识到这一点,但是trace在修改后的函数中添加了class、"functionWithTrace"。所以,很容易检索这些,

res <- eapply(.GlobalEnv, function(x) if (inherits(x, 'functionWithTrace')) TRUE)
names(unlist(res))
# [1] "tst"  "tst1"