Struct gdb_command::GdbCommand
source · pub struct GdbCommand<'a> { /* private fields */ }
Expand description
Struct contains information about arguments for gdb
to run.
Implementations§
source§impl<'a> GdbCommand<'a>
impl<'a> GdbCommand<'a>
sourcepub fn new(exec_type: &'a ExecType<'_>) -> GdbCommand<'a>
pub fn new(exec_type: &'a ExecType<'_>) -> GdbCommand<'a>
sourcepub fn stdin<T: Into<Option<&'a PathBuf>>>(
&mut self,
file: T
) -> &'a mut GdbCommand<'_>
pub fn stdin<T: Into<Option<&'a PathBuf>>>(
&mut self,
file: T
) -> &'a mut GdbCommand<'_>
Add stdin for executable.
You should call this method before using r
method.
Arguments
file
- path to stdin file
sourcepub fn ex<T: Into<String>>(&mut self, cmd: T) -> &'a mut GdbCommand<'_>
pub fn ex<T: Into<String>>(&mut self, cmd: T) -> &'a mut GdbCommand<'_>
Examples found in repository?
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
pub fn bt(&mut self) -> &'a mut GdbCommand {
self.ex("bt")
}
/// Add command to get disassembly (-ex 'x/16i $pc')
pub fn disassembly(&mut self) -> &'a mut GdbCommand {
self.ex("x/16i $pc")
}
/// Add command to get registers (-ex 'i r')
pub fn regs(&mut self) -> &'a mut GdbCommand {
self.ex("i r")
}
/// Add command to get mappings (-ex 'info proc mappings')
pub fn mappings(&mut self) -> &'a mut GdbCommand {
self.ex("info proc mappings")
}
/// Add command to get cmd line.
pub fn cmdline(&mut self) -> &'a mut GdbCommand {
self.ex("info proc cmdline")
}
/// Add command to get environment variables
pub fn env(&mut self) -> &'a mut GdbCommand {
self.ex("show environment")
}
/// Add command to get process status
pub fn status(&mut self) -> &'a mut GdbCommand {
self.ex("info proc status")
}
/// Add command to get info
pub fn sources(&mut self) -> &'a mut GdbCommand {
self.ex("info sources")
}
/// Break at main
pub fn bmain(&mut self) -> &'a mut GdbCommand {
self.args.push("-ex".to_string());
self.args.push("b main".to_string());
self
}
/// Print lines from source file
///
/// # Arguments
///
/// * `location` - lines centered around the line specified by location.
/// If None then location is current line.
pub fn list<T: Into<Option<&'a str>>>(&mut self, location: T) -> &'a mut GdbCommand {
if let Some(loc) = location.into() {
self.ex(format!("list {}", loc))
} else {
self.ex("list")
}
}
/// Get memory contents (string of hex bytes)
///
/// # Arguments
///
/// * `expr` - expression that represents the start memory address.
///
/// * `size` - size of memory in bytes to get.
pub fn mem<T: AsRef<str>>(&mut self, expr: T, size: usize) -> &'a mut GdbCommand {
self.ex(format!("x/{}bx {}", size, expr.as_ref()))
}
/// Add command to get siginfo
pub fn siginfo(&mut self) -> &'a mut GdbCommand {
self.ex("p/x $_siginfo")
}
sourcepub fn r(&mut self) -> &'a mut GdbCommand<'_>
pub fn r(&mut self) -> &'a mut GdbCommand<'_>
sourcepub fn c(&mut self) -> &'a mut GdbCommand<'_>
pub fn c(&mut self) -> &'a mut GdbCommand<'_>
Add command to continue execution
sourcepub fn bt(&mut self) -> &'a mut GdbCommand<'_>
pub fn bt(&mut self) -> &'a mut GdbCommand<'_>
Add command to get backtrace (-ex bt)
sourcepub fn disassembly(&mut self) -> &'a mut GdbCommand<'_>
pub fn disassembly(&mut self) -> &'a mut GdbCommand<'_>
Add command to get disassembly (-ex ‘x/16i $pc’)
sourcepub fn regs(&mut self) -> &'a mut GdbCommand<'_>
pub fn regs(&mut self) -> &'a mut GdbCommand<'_>
Add command to get registers (-ex ‘i r’)
sourcepub fn mappings(&mut self) -> &'a mut GdbCommand<'_>
pub fn mappings(&mut self) -> &'a mut GdbCommand<'_>
Add command to get mappings (-ex ‘info proc mappings’)
sourcepub fn cmdline(&mut self) -> &'a mut GdbCommand<'_>
pub fn cmdline(&mut self) -> &'a mut GdbCommand<'_>
Add command to get cmd line.
sourcepub fn env(&mut self) -> &'a mut GdbCommand<'_>
pub fn env(&mut self) -> &'a mut GdbCommand<'_>
Add command to get environment variables
sourcepub fn status(&mut self) -> &'a mut GdbCommand<'_>
pub fn status(&mut self) -> &'a mut GdbCommand<'_>
Add command to get process status
sourcepub fn sources(&mut self) -> &'a mut GdbCommand<'_>
pub fn sources(&mut self) -> &'a mut GdbCommand<'_>
Add command to get info
sourcepub fn bmain(&mut self) -> &'a mut GdbCommand<'_>
pub fn bmain(&mut self) -> &'a mut GdbCommand<'_>
Break at main
sourcepub fn list<T: Into<Option<&'a str>>>(
&mut self,
location: T
) -> &'a mut GdbCommand<'_>
pub fn list<T: Into<Option<&'a str>>>(
&mut self,
location: T
) -> &'a mut GdbCommand<'_>
Print lines from source file
Arguments
location
- lines centered around the line specified by location. If None then location is current line.
sourcepub fn mem<T: AsRef<str>>(
&mut self,
expr: T,
size: usize
) -> &'a mut GdbCommand<'_>
pub fn mem<T: AsRef<str>>(
&mut self,
expr: T,
size: usize
) -> &'a mut GdbCommand<'_>
Get memory contents (string of hex bytes)
Arguments
-
expr
- expression that represents the start memory address. -
size
- size of memory in bytes to get.
sourcepub fn siginfo(&mut self) -> &'a mut GdbCommand<'_>
pub fn siginfo(&mut self) -> &'a mut GdbCommand<'_>
Add command to get siginfo
sourcepub fn launch(&self) -> Result<Vec<String>>
pub fn launch(&self) -> Result<Vec<String>>
Execute gdb and get result for each command.
Return value.
The return value is a vector of strings for each command executed.