调试时将尖括号作为命令行参数输入传递

Passing a angled bracket as a command-line argument input while debugging

我正在 NASM 中编写一个 brainfuck 解释器,其中代码作为程序的命令行参数提供。我正在尝试测试循环,但 GDB 不喜欢我的输入。例如,当 运行 单独执行时,这会无错误地执行:

$./interpret "+++++[->+<]"

它无限期挂起,但我认为这是由于解释器(因此是 GDB)中循环逻辑中的错误。

如果我将 interpret 加载到 GDB 中并尝试提供相同的参数,我会收到投诉:

gef➤  start "+++++[->+<]"
/bin/bash: line 1: ]: No such file or directory
/bin/bash: line 1: ]: No such file or directory

这似乎是由于 < 被解释为重定向,尽管有引号,因为 [] 在 GDB 中工作正常。

我尝试使用 \< 转义 STDIN 重定向,但这会导致相同的错误,而 << 也会导致警告:

gef➤  start "+++++[->+<<]"
/bin/bash: line 1: warning: here-document at line 1 delimited by end-of-file (wanted `]')

代码被截断:

$r15   : 0x00007fffffffe428  →  0x002d5b2b2b2b2b2b ("+++++[-"?)

有没有办法让 GDB 接受我给 start 的字面意思,而不尝试做任何 redirection/interpretation 的参数?

Is there a way to have GDB take what I give literally to start, and not attempt to do any redirection/interpretation of the arguments?

GDB 不做任何解释,bash 做。使用单引号而不是双引号可能会解决这个问题。

(虽然我无法使用 GDB-10.0 和 bash-5.1.4 用双引号复制问题。)