R无法识别命令行选项. (警告:未知选项"-d") [英] R doesn't recognize command line option. (WARNING: unknown option '-d')

查看:214
本文介绍了R无法识别命令行选项. (警告:未知选项"-d")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gdb以视频中指定的相同方式调试R包中的编译代码: https: //vimeo.com/11937905 写作R扩展程序第4.4节.

I am trying to use gdb to debug compiled code in an R package in the same way as specified in the video: https://vimeo.com/11937905 and Writing R Extensions section 4.4.

这些消息来源说要使用命令 启动R时R -d gdb.但是,每当我尝试执行此操作时,都会收到一条消息,提示WARNING: unknown option '-d',R在正常情况下启动. R为什么不识别-d标志?我正在使用Windows 10.

These sources say to use the command R -d gdb when starting R. However, whenever I try to do this I get a message saying WARNING: unknown option '-d' and R is started under normal conditions. Why isn't R recognizing the -d flag? I am using Windows 10.

推荐答案

@MatthewLueder终于发现自己在Windows上进行调试无法像在Linux上进行操作.

As @MatthewLueder has found out himself finally debugging on Windows does not work as on Linux.

R中缺少-d参数的主要原因似乎是 Windows无法向进程发送信号来中断执行并将控制权传递给(gdb)调试器:

The main reason for the missing -d argument in R seems to be that Windows cannot send a signal to a process to interrupt the execution and pass the control to the (gdb) debugger:

  • 在不中断R的情况下,您无法设置断点.
  • 如果不将R启动到R控制台中,则无法加载要调试的库(不弄脏手).

因此,Windows上的R提供了使用RGui而不是R的解决方法:

Therefore R on Windows offers a work-around using RGui instead of R:

gdb /path/to/R-3.x.x/bin/x64/Rgui.exe
(gdb) run

启动RGui后,您进入R外壳并可以加载软件包 包含要调试的DLL.

After starting the RGui you are in an R shell and can load your packages that contain the DLLs to be debugged.

要设置调试断点,您可以通过菜单项来中断R,使其闯入调试器,该菜单项仅在RGuigdb启动时可见:

To set breakpoints for debugging you can interrupt R to break into the debugger via a menu item that is only visible if RGui was started with gdb:

现在,您可以通过b a_function_name在代码中设置断点,输入c继续执行R,在R中调用该函数并贴上代码:gdb显示断点命中和 您可以进行调试(逐步执行代码并打印变量值).

Now you can set breakpoints in your code via b a_function_name, enter c to continue R, call the function in R and voilà: gdb shows the breakpoint hit and you can debug (stepping through the code and printing variable values).

PS:由于要在gdb中查看R变量或Rcpp数据类型的当前值非常困难,所以我目前正在开发R包以改进R包中C ++代码的调试. "https://github.com/aryoda/R_CppDebugHelper" rel ="nofollow noreferrer"> https://github.com/aryoda/R_CppDebugHelper

PS: I am currently developing an R package to improve the debugging of C++ code in R packages since it is quite difficult to view the current values of R variables or Rcpp data types in gdb: https://github.com/aryoda/R_CppDebugHelper

这篇关于R无法识别命令行选项. (警告:未知选项"-d")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆