Поместить несколько строк в скрипт, чтобы выполнить их в GDB

Я хочу создать скрипт или ярлык для серфинга в мире

#!/bin/bash
konsole -e firefox --debug
(gdb) handle SIGPIPE noprint nostop pass
(gdb) handle SIGSEGV noprint nostop pass
(gdb) run

это не работает Я надеюсь, что кто-то поможет мне. после решения я могу рассказать вам историю. Возможно, я помогу многим людям с этим.

пока я могу сделать это:

создание bash-скрипта с

#!/bin/bash
konsole -e firefox --debug

пометить его как исполняемый. двойной щелчок заканчивается открытием в терминале, ожидая, когда я наберу команду run и введите

создавая ~/.gdbinit со следующим содержанием

handle SIGPIPE noprint nostop pass
handle SIGSEGV noprint nostop pass

2 ответа

Решение

Вы можете использовать здесь документы bash (<<) передавать интерактивные команды gdb:

#!/bin/bash
firefox --debug  <<'EOF'
handle SIGPIPE noprint nostop pass
handle SIGSEGV noprint nostop pass
run
EOF 

Проверить Here Documents раздел man bash чтобы получить больше идеи.

Пример:

$ cat scr.sh 
#!/bin/bash
firefox --debug <<'EOF'
help
quit
EOF

$ bash scr.sh 
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/lib/firefox/firefox...(no debugging symbols found)...done.
(gdb) (gdb) (gdb) (gdb) (gdb) (gdb) (gdb) List of classes of commands:

aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands

Type "help" followed by a class name for a list of commands in that class.
Type "help all" for the list of all commands.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
(gdb) 

$  ##Back to prompt

Хорошо , это работает. Теперь я знаю, как создать новую линию здесь. это shift + enter. только для режима редактирования. может быть 4 пробела работают.... всего 600 символов wtf?

this is the code:
#!/bin/bash
firefox --debug <<'EOF'
handle SIGPIPE noprint nostop pass
handle SIGSEGV noprint nostop pass
run
EOF

не нужно "konsole -e"...... тогда просто дважды щелкните скрипт, затем gdbinit можно удалить

спасибо химайл. Вы спасли жизнь многим, многим разочарованным пользователям Linux, чей крах Firefox слишком высок! Прошу прощения за добавление текста выше, но konsole -e не является обязательным, что было моей ошибкой. Мне сейчас очень интересно, что означает EOF.

Другие вопросы по тегам