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”
What command traces a specific syscall(s)?
“strace -e syscall_name(s)”
What are the commands to set breakpoints in GDB?
“break [address]”
“break [function name]”
“break [line #}”
How can you view the breakpoints previously set?
“info breakpoints”
How can you examine a specific address?
“x/[format letter]”
Ex: x/s (string) 0x80490a4 => “Another World!”
What does “stepi” do?
It steps through each instruction within the code.
What does “step” do?
It steps through the code per source line.
What command changes the value registers or data within the running code?
“set [$eax] = 0xbffff272”
“set argv[1] = D”
What are convenience variables commands?
“set $demo = 10”
“set argv[1] = $demo”
print argv[1]= 10
call Funtion_name [add argu]
What can the command “strings” do?
Display strings contained in a program. Maybe useful to discover poorly coded information.
What are conditional breaks in GDB?
Conditional breaks are used to break only when a condition is met. These are great for loops.