How to script gdb (with python)? Example add breakpoints, run . . . In this case, gdb interprets the script as being a gdb script, i e with gdb commands - and that means, that whatever Python code you may want to write in here, must be wrapped in " python " as a starting line and " end " at end of the Python code
Run a python command with run on GDB - Reverse Engineering . . . I don't know of any way to run a script as a run argument A common solution is to redirect your input from a file You first need to run the script and save the result: python -c "print 'A'*50" > my_file and redirect it to gdb run r < my_file also, from the help run command: Input and output redirection with ">", "<", or ">>" are also allowed which means you can also redirect output if needed
DebuggingWithGdb - Python Wiki run python under gdb from the start Note: the python executable needs to have debug symbols in it which may be another exe python2 7-dbg depending on your system