How to execute a GDB command from a string variable?

xmllmx

Say the debugged process has a string variable as follows:

char* cmd_str = "set confirm on";

How to execute the command from cmd_str in GDB?

(gdb) $cmd = cmd_str
(gdb) ???
Mark Plotnick

You can use gdb's eval command, which runs printf on its arguments and then evaluates the result as a command.

(gdb) list
1   #include <stdlib.h>
2   main()
3   {
4       char *a = "set confirm off";
5   
6       pause();
7   }
(gdb) break 6
Breakpoint 1 at 0x400540: file cmdtest.c, line 6.
(gdb) run
Starting program: ./cmdtest 
Breakpoint 1, main () at cmd.c:6
6       pause();

(gdb) show confirm
Whether to confirm potentially dangerous operations is on.
(gdb) printf "%s", a
set confirm off(gdb) 
(gdb) eval "%s", a
(gdb) show confirm
Whether to confirm potentially dangerous operations is off.

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

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

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How to execute a shell command with root permission from swift

来自分类Dev

How to pass the output of a command as argument in gdb?

来自分类Dev

python:How to print the character from a variable with unicode string

来自分类Dev

Find files and execute command

来自分类Dev

Pulling variable length substring from middle of string

来自分类Dev

How to remove � from a String?

来自分类Dev

ADODB Command.Execute超时

来自分类Dev

How to load bash command history from file

来自分类Dev

How to bind a Command to a ContextMenu from within an ItemTemplate?

来自分类Dev

相当于lldb中的python gdb.execute('...')

来自分类Dev

How to execute a specific plugin/Mojo from a pom.xml programmatically?

来自分类Dev

GDB错误安装错误:gdb.execute_unwinders函数丢失

来自分类Dev

How to make a Node from a String?

来自分类Dev

How to get type from String?

来自分类Dev

print in GDB,how to examine a register?

来自分类Dev

PHP Variable in a string in a string

来自分类Dev

Execute shell command and retrieve stdout in Python

来自分类Dev

My FreeMarker method returns a string with ${variable} -- how to force FreeMarker to parse that?

来自分类Dev

how to get python installed path from command line

来自分类Dev

How to remove junk characters from the file generated by script command in linux

来自分类Dev

How to retrieve values from junction table as a String?

来自分类Dev

How to Remove JavaScript Remnants from String in PHP

来自分类Dev

How to create a list of Tab from a list of String?

来自分类Dev

how correctly execute query?

来自分类Dev

How do I execute a function after 5 sec from last keyup?

来自分类Dev

How to extract value of root variable from kernel commandline

来自分类Dev

How to remove / dispose a broadcast variable from heap in Spark?

来自分类Dev

jQuery- How to get the GET variable from a URL

来自分类Dev

How to update system PATH variable permanently from cmd?

Related 相关文章

  1. 1

    How to execute a shell command with root permission from swift

  2. 2

    How to pass the output of a command as argument in gdb?

  3. 3

    python:How to print the character from a variable with unicode string

  4. 4

    Find files and execute command

  5. 5

    Pulling variable length substring from middle of string

  6. 6

    How to remove � from a String?

  7. 7

    ADODB Command.Execute超时

  8. 8

    How to load bash command history from file

  9. 9

    How to bind a Command to a ContextMenu from within an ItemTemplate?

  10. 10

    相当于lldb中的python gdb.execute('...')

  11. 11

    How to execute a specific plugin/Mojo from a pom.xml programmatically?

  12. 12

    GDB错误安装错误:gdb.execute_unwinders函数丢失

  13. 13

    How to make a Node from a String?

  14. 14

    How to get type from String?

  15. 15

    print in GDB,how to examine a register?

  16. 16

    PHP Variable in a string in a string

  17. 17

    Execute shell command and retrieve stdout in Python

  18. 18

    My FreeMarker method returns a string with ${variable} -- how to force FreeMarker to parse that?

  19. 19

    how to get python installed path from command line

  20. 20

    How to remove junk characters from the file generated by script command in linux

  21. 21

    How to retrieve values from junction table as a String?

  22. 22

    How to Remove JavaScript Remnants from String in PHP

  23. 23

    How to create a list of Tab from a list of String?

  24. 24

    how correctly execute query?

  25. 25

    How do I execute a function after 5 sec from last keyup?

  26. 26

    How to extract value of root variable from kernel commandline

  27. 27

    How to remove / dispose a broadcast variable from heap in Spark?

  28. 28

    jQuery- How to get the GET variable from a URL

  29. 29

    How to update system PATH variable permanently from cmd?

热门标签

归档