0

I'm trying to dump memory from a process on my Linux machine using GDB, but I'm trying to automate this using a script.

So far I've been using the following commands (example):

$ gdb --pid [pid] (gdb) dump memory dump_file 0x00621000 0x00622000 

Is there a way to do this using only one command that I can implement in a shell script? Or is there a way to perform gdb commands using shell scripts?

Any help would be greatly appreciated :)

1 Answer 1

1

Create a file in /usr/local/bin and make it executable afterwards:

#!/bin/sh if [ $# -eq 3 ]; then tf=$(tempfile) echo -e "dump memory dump_file ${2} ${3}" > $tf gdb -p $1 -x $tf else echo "Pass me a PID MEM_START MEM_END" fi 

If you name it memory-dump-gdb or mdg for short then you make it executable like so:

chmod 750 /usr/local/bin/mdg 

Then you can run "mdg 1234 0x00621000 0x00622000"

2
  • How does your script do the memory dump? Commented Jan 13, 2022 at 15:23
  • Oh. Oups .. must've been distracted and thought I was doing a shell-script 101 .. heh .. the new solution should do what was asked. Commented Jan 13, 2022 at 15:47

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.