Skip to content

Instantly share code, notes, and snippets.

@laijs
Created December 6, 2017 02:15
Show Gist options
  • Save laijs/10a9ec476cf5875d2ba75c3071769128 to your computer and use it in GitHub Desktop.
Save laijs/10a9ec476cf5875d2ba75c3071769128 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
void main(void) {
int pid = getpid();
char *cmd;
// asprintf(&cmd, "cat /proc/%d/maps", pid);
asprintf(&cmd, "pmap -x %d", pid);
system(cmd);
free(cmd);
}
package main
/*
#cgo CFLAGS: -Wall
#define _GNU_SOURCE
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
void __attribute__((constructor)) contructor_map(void) {
int pid = getpid();
char *cmd;
// asprintf(&cmd, "cat /proc/%d/maps", pid);
asprintf(&cmd, "pmap -x %d", pid);
system(cmd);
free(cmd);
}
*/
import "C"
//import "io"
import "os"
import "fmt"
import "os/exec"
import "syscall"
func main() {
//maps, _ := os.Open("/proc/self/maps")
//io.Copy(os.Stdout, maps)
cmd := exec.Command("pmap", "-x", fmt.Sprintf("%d", syscall.Getpid()))
cmd.Stdout = os.Stdout
cmd.Run()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment