Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jvns/500lines
base: 3c6c16123b
...
head fork: jvns/500lines
compare: ed7418633c
Checking mergeability… Don't worry, you can still create the pull request.
  • 9 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
View
4 debugger/Makefile
@@ -0,0 +1,4 @@
+all:
+ gcc -o debug debug.c
+ gcc -g -o helloworld helloworld.c
+ ./debug helloworld
View
48 debugger/debug.c
@@ -0,0 +1,48 @@
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ptrace.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define BREAKPOINT 0x00000000004004f4
+#define ADDR 0x610c
+
+int main(int argc, char **argv) {
+ // execv() needs a NULL-terminated array, so we copy from argv into
+ // child_argv.
+ char **child_argv = calloc(argc, sizeof(char));
+ int i;
+ for(i = 0; i < argc - 1; ++i) {
+ child_argv[i] = argv[i+1];
+ }
+
+ if (argc < 2) {
+ return -1;
+ }
+ pid_t child_pid = fork();
+ if (child_pid == -1) { //error
+ return -1;
+ }
+
+ if (child_pid == 0) { // child
+ if (ptrace(PTRACE_TRACEME, 0, NULL, 0) == -1) {
+ printf("ptrace: error %d", errno);
+ return -1;
+ }
+ if (execv(argv[1], child_argv) == -1) {
+ printf("execv: error %d", errno);
+ return -1;
+ }
+ }
+
+ // will be parent here!
+ printf("we are in control!\n");
+ sleep(2);
+
+ ptrace(PTRACE_CONT, child_pid, NULL, 0);
+
+ return 0;
+}
View
8 debugger/helloworld.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main(void) {
+ char *hi = "hello world\n";
+ printf("%s", hi);
+
+ return 0;
+}
View
6 graph-layout/README.md
@@ -1,6 +0,0 @@
-# Graph layout engine
-
-A graph layout engine.
-Author: Julia Evans
-
-TODO: Everything.

No commit comments for this range

Something went wrong with that request. Please try again.