pub struct Panda { /* private fields */ }Expand description
Builder for creating PANDA instances. Only for use in libpanda mode.
Implementations§
Source§impl Panda
impl Panda
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
More examples
10fn main() {
11 let mut i = 0;
12 let callback = panda::Callback::new();
13 callback.before_block_exec(move |cpu, _| {
14 if i % 2 == 0 {
15 on_every_even_block::trigger(cpu);
16 } else {
17 if on_every_odd_block::trigger(cpu) {
18 callback.disable();
19 }
20 }
21 i += 1;
22 });
23
24 on_every_even_block::add_callback(on_even_test);
25 on_every_odd_block::add_callback(on_odd_test);
26
27 Panda::new().generic("x86_64").replay("test").run();
28}Sourcepub fn args<I, S>(&mut self, args: I) -> &mut Self
pub fn args<I, S>(&mut self, args: I) -> &mut Self
Add a set of extra arguments for PANDA
§Example
Panda::new()
.args(&["-panda", "callstack_instr"])
.run();Sourcepub fn arch(&mut self, arch: Arch) -> &mut Self
pub fn arch(&mut self, arch: Arch) -> &mut Self
Examples found in repository?
More examples
Sourcepub fn configurable(&mut self) -> &mut Self
pub fn configurable(&mut self) -> &mut Self
Examples found in repository?
More examples
Sourcepub fn enable_graphics(&mut self) -> &mut Self
pub fn enable_graphics(&mut self) -> &mut Self
§Example
Panda::new()
.enable_graphics()
.run();Sourcepub fn expect_prompt<S: Into<String>>(&mut self, prompt_regex: S) -> &mut Self
pub fn expect_prompt<S: Into<String>>(&mut self, prompt_regex: S) -> &mut Self
Regular expression describing the prompt exposed by the guest on a serial console. Used in order to know when running a command has finished with its output.
Sourcepub fn mem<S: Into<String>>(&mut self, mem: S) -> &mut Self
pub fn mem<S: Into<String>>(&mut self, mem: S) -> &mut Self
Set the available memory. If restoring from a snapshot or viewing a replay, this must be the same as when the replay/snapshot was taken.
Sourcepub fn generic<S: Into<String>>(&mut self, generic: S) -> &mut Self
pub fn generic<S: Into<String>>(&mut self, generic: S) -> &mut Self
Examples found in repository?
More examples
10fn main() {
11 let mut i = 0;
12 let callback = panda::Callback::new();
13 callback.before_block_exec(move |cpu, _| {
14 if i % 2 == 0 {
15 on_every_even_block::trigger(cpu);
16 } else {
17 if on_every_odd_block::trigger(cpu) {
18 callback.disable();
19 }
20 }
21 i += 1;
22 });
23
24 on_every_even_block::add_callback(on_even_test);
25 on_every_odd_block::add_callback(on_odd_test);
26
27 Panda::new().generic("x86_64").replay("test").run();
28}5fn main() {
6 // Callbacks can capture state
7 let mut count = 1;
8 let bb_callback = Callback::new();
9 bb_callback.before_block_exec(move |cpu, _| {
10 println!("Block: {} | PC: {:#x?}", count, panda::regs::get_pc(cpu));
11 count += 1;
12 if count > 5 {
13 // callbacks can disable themselves by capturing a copy
14 // of the `Callback` reference to it
15 bb_callback.disable();
16 }
17 });
18
19 // If you don't need to enable and disable the callback, you can just
20 // use method chaining instead of assigning to a variable
21 PppCallback::new().on_rec_auxv(|_, _, auxv| {
22 // print out the auxillary vector when any process starts
23 dbg!(auxv);
24 });
25
26 Panda::new().generic("x86_64").replay("test").run();
27}Sourcepub fn replay<S: Into<String>>(&mut self, replay: S) -> &mut Self
pub fn replay<S: Into<String>>(&mut self, replay: S) -> &mut Self
Run the given replay in the PANDA instance. Equivalent to -replay [name] from the PANDA
command line.
§Example
Panda::new()
.replay("grep_recording")
.run();Examples found in repository?
More examples
10fn main() {
11 let mut i = 0;
12 let callback = panda::Callback::new();
13 callback.before_block_exec(move |cpu, _| {
14 if i % 2 == 0 {
15 on_every_even_block::trigger(cpu);
16 } else {
17 if on_every_odd_block::trigger(cpu) {
18 callback.disable();
19 }
20 }
21 i += 1;
22 });
23
24 on_every_even_block::add_callback(on_even_test);
25 on_every_odd_block::add_callback(on_odd_test);
26
27 Panda::new().generic("x86_64").replay("test").run();
28}5fn main() {
6 // Callbacks can capture state
7 let mut count = 1;
8 let bb_callback = Callback::new();
9 bb_callback.before_block_exec(move |cpu, _| {
10 println!("Block: {} | PC: {:#x?}", count, panda::regs::get_pc(cpu));
11 count += 1;
12 if count > 5 {
13 // callbacks can disable themselves by capturing a copy
14 // of the `Callback` reference to it
15 bb_callback.disable();
16 }
17 });
18
19 // If you don't need to enable and disable the callback, you can just
20 // use method chaining instead of assigning to a variable
21 PppCallback::new().on_rec_auxv(|_, _, auxv| {
22 // print out the auxillary vector when any process starts
23 dbg!(auxv);
24 });
25
26 Panda::new().generic("x86_64").replay("test").run();
27}Sourcepub fn plugin_args<T: PandaArgs>(&mut self, args: &T) -> &mut Self
pub fn plugin_args<T: PandaArgs>(&mut self, args: &T) -> &mut Self
Load a plugin with args provided by a PandaArgs struct.
§Example
use panda::prelude::*;
#[derive(PandaArgs)]
#[name = "stringsearch"]
struct StringSearch {
str: String
}
fn main() {
Panda::new()
.generic("x86_64")
.replay("test")
.plugin_args(&StringSearch {
str: "test".into()
})
.run();
}Sourcepub fn run(&mut self)
pub fn run(&mut self)
Start the PANDA instance with the given settings. This is a blocking operation.
§Example
Panda::new()
.generic("x86_64")
.run();Examples found in repository?
More examples
10fn main() {
11 let mut i = 0;
12 let callback = panda::Callback::new();
13 callback.before_block_exec(move |cpu, _| {
14 if i % 2 == 0 {
15 on_every_even_block::trigger(cpu);
16 } else {
17 if on_every_odd_block::trigger(cpu) {
18 callback.disable();
19 }
20 }
21 i += 1;
22 });
23
24 on_every_even_block::add_callback(on_even_test);
25 on_every_odd_block::add_callback(on_odd_test);
26
27 Panda::new().generic("x86_64").replay("test").run();
28}Sourcepub fn run_after_init(func: impl FnOnce() + Send + Sync + 'static)
pub fn run_after_init(func: impl FnOnce() + Send + Sync + 'static)
Queue up a function that should run before libpanda has started but after the libpanda has been initialized. If run under a plugin context (e.g. no libpanda), or libpanda is currently running, then the function will run immediately.
This is useful for functions that may require waiting until things like arguments or OS has been set, such as setting up an OSI callback.