Linux / GDB Commands Flashcards
Understand Linux commands that help with gaining info on Linux machines for assembly learning as well as GDB commands
What commands can be used to view the system CPU info on Linux?
cat proc/cpuinfo or lscpu
How do you run a program in GDB on a Linux system?
The following syntax runs a program in GDB: "gdb /bin/bash" "break main" "run" (gdb has started at this point)
What commands allow viewing of registers for a program from Linux GDB?
The following will display registers:
“info registers” or “display /x $eax”
“info all-registers” -> (displays ALL registers)
What command disassembles a register?
“disassemble $eip” as an example
What command changes the syntax of a GDB disassembler to Intel syntax?
“set disassembly-flavor intel”
How do you add debug symbols while compiling a program?
“gcc -ggdb main.c -o main”
What command displays the functions within a file/program?
“info functions”
What command displays all the sources for a file?
“info sources”
What command displays the global variables for a file?
“info variables”
What command displays the local variables of a function?
“info scope function_name”
What command allows you to copy debug symbols from a binary file to a new file?
“objcopy –only-keep-debug File_w_symbols New_symbols_file”
What command allows you to remove debug symbols from a binary file?
“strip –strip-debug File_w_symbols”
What is the command strace?
Traces system calls made by a program and arguments passed by the program.
What strace command attaches to a running program?
“strace -p [PID]”
How to print the statistics for the syscalls in a program?
“strace -s Program_Name”