Changeset 3105f50
- Timestamp:
- 05/28/15 21:36:03 (10 years ago)
- Branches:
- master
- Children:
- 081a0fa
- Parents:
- 430548b
- git-author:
- Hal Finkel <hfinkel@…> (05/28/15 21:36:03)
- git-committer:
- Hal Finkel <hfinkel@…> (05/28/15 21:36:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
memlog.c
r430548b r3105f50 29 29 // sure this does not cause an infinite loop. 30 30 static __thread int in_malloc = 0; 31 static char self_path[PATH_MAX+1] = { '\0' }; 31 32 32 33 __attribute__((__constructor__)) … … 35 36 uname(&u); 36 37 37 char log_name[PATH_MAX ];38 snprintf(log_name, PATH_MAX , "%s.%d.memlog", u.nodename, getpid());38 char log_name[PATH_MAX+1]; 39 snprintf(log_name, PATH_MAX+1, "%s.%d.memlog", u.nodename, getpid()); 39 40 log_file = fopen(log_name, "w"); 40 41 if (!log_file) 41 42 fprintf(stderr, "fopen failed for '%s': %m\n", log_name); 43 44 const char *link_name = "/proc/self/exe"; 45 readlink(link_name, self_path, PATH_MAX); 42 46 } 43 47 … … 110 114 file_name = dlinfo.dli_fname; 111 115 } else { 112 off = pc; 113 relpc = pc; 116 // We don't know these... 117 off = 0; 118 relpc = 0; 114 119 proc_name = "?"; 115 file_name = "?"; 120 121 // If we can't determine the file, assume it is the base executable 122 // (which does the right thing for statically-linked binaries). 123 file_name = self_path; 116 124 } 117 125
Note: See TracChangeset
for help on using the changeset viewer.