Giter VIP home page Giter VIP logo

gdbshellpipe's Introduction

Shell-Pipe Command

This gdb extension allows the piping of internal gdb commands to external commands, as described in this Stackoverflow question.

Suppose one wanted to find all the mov instructions in the current function.

(gdb) disas
Dump of assembler code for function foo:
0x0000000000400526 <+0>:     push   %rbp
0x0000000000400527 <+1>:     mov    %rsp,%rbp
0x000000000040052a <+4>:     sub    $0x10,%rsp
0x000000000040052e <+8>:     movq   $0x4005e4,-0x8(%rbp)
=> 0x0000000000400536 <+16>:    mov    -0x8(%rbp),%rax
0x000000000040053a <+20>:    mov    %rax,%rdi
0x000000000040053d <+23>:    callq  0x400400 <puts@plt>
0x0000000000400542 <+28>:    nop
0x0000000000400543 <+29>:    leaveq
0x0000000000400544 <+30>:    retq

One can source the file ShellPipeCommand.py in their $HOME/.gdb_init file, and then invoke the following command.

    (gdb) shell-pipe disas | grep mov
    0x0000000000400527 <+1>:     mov    %rsp,%rbp
    0x000000000040052e <+8>:     movq   $0x4005e4,-0x8(%rbp)
 => 0x0000000000400536 <+16>:    mov    -0x8(%rbp),%rax
    0x000000000040053a <+20>:    mov    %rax,%rdi

Note that the native gdb shell command already handles shell pipelines which do not involve internal gdb commands. This extension is intended for the case where the first command in the pipeline is a gdb internal command. If the first command in the pipeline is a valid gdb command as well as a valid external command, it will be interpreted as the former rather than the latter.

gdbshellpipe's People

Contributors

as-j avatar hq6 avatar jwilk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.