调试器不会从调用函数返回到被调用函数

IAMTubby

我已经获得了我的代码,并且正在对下面的代码进行debug(myfun1)。如图所示,我在第13行设置了一个断点。在此处输入图片说明

我的代码如下

myfun1 = function()
{
  print("This is myfun1, before calling the myfun2()")
  myfun2()
  print("This is myfun1, after calling the myfun2()")
  print("Does the debugger come back to this point")
}

myfun2 = function()
{
  print("This is myfun2, before calling the myfun3()")
  myfun3()
  print("This is  myfun2, after calling the myfun3()")
  print("This is the last but one line of myfun2()")
  print("This is the last line of myfun2()")
}

myfun3 = function()
{
  print("This is myfun3")
}

这些是我用于调试的步骤顺序

  1. 我从myfun1开始,然后在第4行上执行“ s”以进入myfun2()
  2. 调试器直接将我带到第13行,因为我设置了断点
  3. 现在,我在myfun2()中执行了n次,这使我进入了后续的行,即line14和line15 resp。
  4. But, if I do 'n' on line 15, I expect it to go back to myfun1(). However, it just exits(I was able to get it to go back to myfun1() by setting a breakpoint in myfun1 after myfun2() is called(say in line5 or line6), but shouldn't it return even otherwise?)

See my debug log below

> debugSource('~/Desktop/foo1.R')
> debug(myfun1)
> myfun1()
debugging in: myfun1()
debug at ~/Desktop/foo1.R#2: {
    print("This is myfun1, before calling the myfun2()")
    myfun2()
    print("This is myfun1, after calling the myfun2()")
    print("Does the debugger come back to this point")
}
Browse[2]> c
[1] "This is myfun1, before calling the myfun2()"
[1] "This is myfun2, before calling the myfun3()"
[1] "This is myfun3"
Called from: eval(expr, envir, enclos)
Browse[1]> n
debug at ~/Desktop/foo1.R#13: print("This is  myfun2, after calling the myfun3()")
Browse[2]> n
[1] "This is  myfun2, after calling the myfun3()"
debug at ~/Desktop/foo1.R#14: print("This is the last but one line of myfun2()")
Browse[2]> n
[1] "This is the last but one line of myfun2()"
debug at ~/Desktop/foo1.R#15: print("This is the last line of myfun2()")
Browse[2]> n
[1] "This is the last line of myfun2()"
[1] "This is myfun1, after calling the myfun2()"
[1] "Does the debugger come back to this point"
exiting from: myfun1()
MrFlick

I'm assuming the GUI for RStudio is just a wrapper to the basic debugging functions in R. Setting the breakpoint by clicking on the margin would be equivalent to calling setBreakpoint().

这些函数会trace()在函数级别上不合时宜地调用也就是说,跟踪器用启用跟踪的新功能替换了当前功能。并且该替换函数包括一个on.exit在函数完成时停止跟踪调用。因此,myfun2退出,tacser被禁用,因此您无法在调用myfun2(is myfun2的函数中进行调试

如果需要在更高级别上进行调试,请在更高级别上设置断点。我不确定是否可以在RStudio GUI中更改调试器,但是如果您自叫,则trace()可以调用recover()而不是调用它,browser()它可以跳转到调用堆栈的不同部分。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法在调试器中调用标准数学函数?

Chrome 调试器 - 从模板调用的异步函数中的参数

Flutter-为什么调试器要在函数完全调试之前在函数调用下调试代码?

不能通过异步调用的函数加入Python调试器吗?

使用`this`调用匿名函数时,NodeJS调试器会崩溃吗?

是否可以使用Visual Studio 2013 C / C ++调试器调用函数并打印结果

调试函数调用

AngularJS $ http.get服务未将数据返回到调用控制器函数

告诉gcc函数调用不会返回

我可以在没有调试器/堆栈跟踪的情况下从调用函数的bash脚本中找到该行吗?

将响应从获取返回到调用它的函数

Python - 如何从类调用外部函数然后返回到类

React-将api调用结果返回到原始函数

无法从NSURLSession委托返回到调用函数而不杀死任务

在 C++ 中将结构从被调用函数返回到调用函数的适当方式是什么?

调用另一个函数并使其直接返回到这个函数的调用者

递归函数陷入无限循环。即使在返回语句评估之后,控制也会返回到函数调用

C 函数返回 0,即使调试器显示它返回 1

Java调试模式:如何获取函数调用的返回值

为什么调试器不会在drupal hook_menu函数中停止?

Chrome浏览器调试器将jQuery语句作为“未定义函数”返回

从函数调用的函数返回输出

调用返回的函数

调用函数返回 Promise

如何在Chrome调试器中检查JavaScript函数的返回值?

有没有办法在chrome或firebox调试器的堆栈跟踪中隐藏第三方JS函数调用?

Delphi:在没有调试器0.16 s的情况下,使用Debugger调用C dll函数需要15 s。为什么?

尽管调用了 promise resolve(),但异步函数不会返回

即使返回HTTP 200,也不会调用AJAX成功函数