Skip to content

Instantly share code, notes, and snippets.

@Mic92

Mic92/foo.cpp Secret

Last active August 13, 2018 07:29
Show Gist options
  • Save Mic92/bbc883220a7b43867dec32d39fa183aa to your computer and use it in GitHub Desktop.
Save Mic92/bbc883220a7b43867dec32d39fa183aa to your computer and use it in GitHub Desktop.
better debugging
void foo(const char** const& argv, int const& argc, int const& r, std::string const& s) {
// gdb can now access everything (no optimized out variables)
__asm__("int3");
}
#include <cstdio>
#include <unistd.h>
#include <string>
int main(int argc, const char** argv) {
std::string s = "abc";
int r = write(fileno(stderr), "foo", sizeof("foo"));
// auto generate function that captures references to all variables
void foo(const char** const& argv, int const& argc, int const& r, std::string const& s);
foo(argv, argc, r, s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment