Last active
March 3, 2016 07:30
-
-
Save habnabit/60e847753534ccf0c2e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> import struct | |
| >>> struct.pack('<II', 0x6c6c6162, 0x73) | |
| 'balls\x00\x00\x00' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[no_mangle] | |
| pub extern fn main() { | |
| panic!("balls"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (gdb) p *args | |
| $33 = {pieces = {data_ptr = 0x2001d148 <str1542>, length = 5}, fmt = {RUST$ENCODED$ENUM$0$0$None = {__0 = {data_ptr = 0x200187a8, length = 1}}}, args = {data_ptr = 0x0 <__pbl_app_info>, length = 0}} | |
| (gdb) p (unsigned char*)0x2001d148 | |
| $34 = (unsigned char *) 0x2001d148 <str1542> "balls" | |
| (gdb) ptype args->pieces | |
| type = struct &[&str] { | |
| struct &str *data_ptr; | |
| usize length; | |
| } | |
| (gdb) p/x *(int*)&args->pieces@4 | |
| $39 = {0x2001d148, 0x5, 0x200187a8, 0x1} | |
| (gdb) p/x **(int**)(&args->pieces)@4 | |
| $42 = {0x6c6c6162, 0x73, 0x0, 0x6573552f} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// This structure represents a safely precompiled version of a format string | |
| /// and its arguments. This cannot be generated at runtime because it cannot | |
| /// safely be done so, so no constructors are given and the fields are private | |
| /// to prevent modification. | |
| /// | |
| /// The `format_args!` macro will safely create an instance of this structure | |
| /// and pass it to a function or closure, passed as the first argument. The | |
| /// macro validates the format string at compile-time so usage of the `write` | |
| /// and `format` functions can be safely performed. | |
| #[stable(feature = "rust1", since = "1.0.0")] | |
| #[derive(Copy, Clone)] | |
| pub struct Arguments<'a> { | |
| // Format string pieces to print. | |
| pieces: &'a [&'a str], | |
| // Placeholder specs, or `None` if all specs are default (as in "{}{}"). | |
| fmt: Option<&'a [rt::v1::Argument]>, | |
| // Dynamic arguments for interpolation, to be interleaved with string | |
| // pieces. (Every argument is preceded by a string piece.) | |
| args: &'a [ArgumentV1<'a>], | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment