71 #include <sys/types.h> 91 static unsigned long hex2ul(
char *s);
92 static uint64_t
hex2u64(
char *s);
102 #define bhl ((int)(sizeof(long)*2+2)) 104 #define MAXLINELEN (PATH_MAX + 80) 120 char filename[PATH_MAX];
123 pid_t
pid = getpid();
128 sprintf(filename,
"/proc/%d/maps", pid);
129 fs = fopen(filename,
"r");
162 static char* cmd =
NULL;
164 char filenm[PATH_MAX];
165 char cmdline[PATH_MAX];
167 pid_t
pid = getpid();
168 char* space, *basenm;
172 sprintf(filenm,
"/proc/%d/cmdline", pid);
173 fs = fopen(filenm,
"r");
174 fgets(cmdline, PATH_MAX, fs);
179 space = strchr(cmdline,
' ');
186 cmd =
malloc(
sizeof(
const char*) * (strlen(basenm) + 1));
234 char *blank = strchr(line, (
int)
' ');
235 char *slash = strchr(line, (
int)
'/');
236 return (blank && *(blank + 3) ==
'x' && slash);
277 char *name = strchr(line, (
int)
'/');
278 char *
newline = strchr(line, (
int)
'\n');
279 if (newline) *newline = 0;
292 char *minus = strchr(line, (
int)
'-');
299 unsigned long res = 0;
300 sscanf(s,
"%lx", &res);
308 sscanf(s,
"%"SCNx64
"", &res);
319 fprintf(stderr,
"Dumping currently mapped load modules (%d):\n",
321 for (i = 0; i < rtloadmap.
count; i++) {
322 fprintf(stderr,
" [%d] offset=%#0*"PRIx64
" ",
325 fprintf(stderr,
"name=%s\n", rtloadmap.
module[i].
name);
void MONITOR_EXT_WRAP_NAME() free(void *ptr)
static char * get_beg_addr(char *line)
static char * get_name(char *line)
static const char * newline
const char * hpcrun_get_cmd(int dbglvl)
rtloadmap_t * hpcrun_get_rtloadmap(int dbglvl)
static uint64_t hex2u64(char *s)
static int iscodeline(char *line)
static char * get_line_slot(void)
static void finalizelines(void)
static rtloadmap_t rtloadmap
static unsigned long hex2ul(char *s)
static void dumplines(void)
int main(int argc, char *argv[])
static char * get_end_addr(char *line)
rtloadmod_desc_t * module
void *MONITOR_EXT_WRAP_NAME() realloc(void *ptr, size_t bytes)
void *MONITOR_EXT_WRAP_NAME() malloc(size_t bytes)
static void dumprtloadmap(void)
string basename(const char *fName)
static void reset_slots()