@@ -106,6 +106,7 @@ bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) {
106
106
constexpr unsigned BUFFER_SIZE = 128 ;
107
107
char objPath[BUFFER_SIZE] = {};
108
108
// Use path /proc/<pid>/object/<object_id> to pass to the symbolizer.
109
+ // TODO: Append the archive member name if it exists.
109
110
internal_snprintf (objPath, BUFFER_SIZE, " /proc/%d/object/%s" ,
110
111
internal_getpid (), mapIter->pr_mapname );
111
112
len = Min ((uptr)internal_strlen (objPath), segment->filename_size - 1 );
@@ -114,6 +115,7 @@ bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) {
114
115
115
116
// We don't have the full path to user libraries, so we use what we have
116
117
// available as the display name.
118
+ // TODO: Append the archive member name if it exists.
117
119
const char *displayPath = data_.proc_self_maps .data + mapIter->pr_pathoff ;
118
120
len =
119
121
Min ((uptr)internal_strlen (displayPath), segment->displayname_size - 1 );
@@ -133,6 +135,38 @@ bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) {
133
135
return true ;
134
136
}
135
137
138
+ void MemoryMappingLayout::DumpListOfModules (
139
+ InternalMmapVectorNoCtor<LoadedModule> *modules) {
140
+ Reset ();
141
+ InternalMmapVector<char > module_name (kMaxPathLength );
142
+ InternalMmapVector<char > module_displayname (kMaxPathLength );
143
+ MemoryMappedSegment segment (module_name.data (), module_name.size (),
144
+ module_displayname.data (),
145
+ module_displayname.size ());
146
+ for (uptr i = 0 ; Next (&segment); i++) {
147
+ const char *cur_name = segment.filename ;
148
+ if (cur_name[0 ] == ' \0 ' )
149
+ continue ;
150
+ // Don't subtract 'cur_beg' from the first entry:
151
+ // * If a binary is compiled w/o -pie, then the first entry in
152
+ // process maps is likely the binary itself (all dynamic libs
153
+ // are mapped higher in address space). For such a binary,
154
+ // instruction offset in binary coincides with the actual
155
+ // instruction address in virtual memory (as code section
156
+ // is mapped to a fixed memory range).
157
+ // * If a binary is compiled with -pie, all the modules are
158
+ // mapped high at address space (in particular, higher than
159
+ // shadow memory of the tool), so the module can't be the
160
+ // first entry.
161
+ uptr base_address = (i ? segment.start : 0 ) - segment.offset ;
162
+ LoadedModule cur_module;
163
+ cur_module.set (cur_name, base_address);
164
+ cur_module.setDisplayName (segment.displayname );
165
+ segment.AddAddressRanges (&cur_module);
166
+ modules->push_back (cur_module);
167
+ }
168
+ }
169
+
136
170
} // namespace __sanitizer
137
171
138
172
#endif // SANITIZER_AIX
0 commit comments