Skip to content

Commit f9a6fc3

Browse files
committed
Merge pull request #175 from abrt/gh174_revert_report_maps
Revert usage of /proc/PID/maps
2 parents 079aea6 + 29a96f4 commit f9a6fc3

File tree

6 files changed

+27
-106
lines changed

6 files changed

+27
-106
lines changed

include/core/unwind.h

-13
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,12 @@ sr_parse_coredump(const char *coredump_filename,
3232
const char *executable_filename,
3333
char **error_message);
3434

35-
struct sr_core_stacktrace *
36-
sr_parse_coredump_maps(const char *coredump_filename,
37-
const char *executable_filename,
38-
const char *maps_filename,
39-
char **error_message);
40-
4135
struct sr_core_stacktrace *
4236
sr_core_stacktrace_from_gdb(const char *gdb_output,
4337
const char *coredump_filename,
4438
const char *executable_filename,
4539
char **error_message);
4640

47-
struct sr_core_stacktrace *
48-
sr_core_stacktrace_from_gdb_maps(const char *gdb_output,
49-
const char *coredump_filename,
50-
const char *executable_filename,
51-
const char *maps_filename,
52-
char **error_message);
53-
5441
#ifdef __cplusplus
5542
}
5643
#endif

lib/abrt.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,15 @@ create_core_stacktrace(const char *directory, const char *gdb_output,
9494
return NULL;
9595

9696
char *coredump_filename = sr_build_path(directory, "coredump", NULL);
97-
char *maps_filename = sr_build_path(directory, "maps", NULL);
9897

9998
struct sr_core_stacktrace *core_stacktrace;
10099

101100
if (gdb_output)
102-
core_stacktrace = sr_core_stacktrace_from_gdb_maps(gdb_output,
103-
coredump_filename, executable_contents, maps_filename,
104-
error_message);
101+
core_stacktrace = sr_core_stacktrace_from_gdb(gdb_output,
102+
coredump_filename, executable_contents, error_message);
105103
else
106-
core_stacktrace = sr_parse_coredump_maps(coredump_filename,
107-
executable_contents, maps_filename, error_message);
104+
core_stacktrace = sr_parse_coredump(coredump_filename,
105+
executable_contents, error_message);
108106

109107
free(executable_contents);
110108
free(coredump_filename);

lib/core_unwind.c

+14-76
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
#if !defined WITH_LIBDWFL && !defined WITH_LIBUNWIND
4545

4646
struct sr_core_stacktrace *
47-
sr_parse_coredump_maps(const char *coredump_filename,
48-
const char *executable_filename,
49-
const char *maps_filename,
50-
char **error_message)
47+
sr_parse_coredump(const char *coredump_filename,
48+
const char *executable_filename,
49+
char **error_message)
5150
{
5251
*error_message = sr_asprintf("satyr is built without unwind support");
5352
return NULL;
@@ -168,7 +167,7 @@ touch_module(Dwfl_Module *mod, void **userdata, const char *name,
168167
}
169168

170169
struct core_handle *
171-
open_coredump(const char *elf_file, const char *exe_file, const char *maps_file, char **error_msg)
170+
open_coredump(const char *elf_file, const char *exe_file, char **error_msg)
172171
{
173172
struct core_handle *ch = sr_mallocz(sizeof(*ch));
174173
struct exe_mapping_data *head = NULL, **tail = &head;
@@ -203,65 +202,20 @@ open_coredump(const char *elf_file, const char *exe_file, const char *maps_file,
203202
goto fail_elf;
204203
}
205204

206-
if (maps_file)
207-
{
208-
executable_file = NULL;
209-
ch->cb.find_elf = dwfl_linux_proc_find_elf;
210-
}
211-
else
212-
{
213-
executable_file = exe_file;
214-
ch->cb.find_elf = find_elf_core;
215-
}
216-
205+
executable_file = exe_file;
206+
ch->cb.find_elf = find_elf_core;
217207
ch->cb.find_debuginfo = find_debuginfo_none;
218208
ch->cb.section_address = dwfl_offline_section_address;
219209
ch->dwfl = dwfl_begin(&ch->cb);
220210

221-
/* Report the addresses at which the shared libraries are loaded to
222-
* elfutils. See libdwfl/libdwfl.h in the elfutils source for documentation
223-
* of the functions used.
224-
*/
225-
if (maps_file)
226-
{
227-
/* The /proc/PID/maps file was provided - get the library information
228-
* from there. */
229-
FILE *maps = fopen(maps_file, "r");
230-
if (!maps)
231-
{
232-
set_error("Unable to open '%s': %s", maps_file, strerror(errno));
233-
goto fail_dwfl;
234-
}
235-
236-
int ret = dwfl_linux_proc_maps_report(ch->dwfl, maps);
237-
fclose(maps);
238-
239-
if (ret < 0)
240-
{
241-
set_error_dwfl("dwfl_linux_proc_maps_report");
242-
goto fail_dwfl;
243-
}
244-
else if (ret > 0)
245-
{
246-
set_error("Failed to parse maps file: %s", strerror(ret));
247-
goto fail_dwfl;
248-
}
249-
}
250-
else
251-
{
252-
/* Elfutils can extract the shared library information from the memory
253-
* of the dynamic linker. Because it was writable part of the proces
254-
* image, it might be damaged.
255-
*/
256211
#if _ELFUTILS_PREREQ(0, 158)
257-
if (dwfl_core_file_report(ch->dwfl, ch->eh, exe_file) == -1)
212+
if (dwfl_core_file_report(ch->dwfl, ch->eh, exe_file) == -1)
258213
#else
259-
if (dwfl_core_file_report(ch->dwfl, ch->eh) == -1)
214+
if (dwfl_core_file_report(ch->dwfl, ch->eh) == -1)
260215
#endif
261-
{
262-
set_error_dwfl("dwfl_core_file_report");
263-
goto fail_dwfl;
264-
}
216+
{
217+
set_error_dwfl("dwfl_core_file_report");
218+
goto fail_dwfl;
265219
}
266220

267221
if (dwfl_report_end(ch->dwfl, NULL, NULL) != 0)
@@ -428,15 +382,14 @@ get_signal_number(Elf *e, const char *elf_file)
428382
}
429383

430384
struct sr_core_stacktrace *
431-
sr_core_stacktrace_from_gdb_maps(const char *gdb_output, const char *core_file,
432-
const char *exe_file, const char *maps_file,
433-
char **error_msg)
385+
sr_core_stacktrace_from_gdb(const char *gdb_output, const char *core_file,
386+
const char *exe_file, char **error_msg)
434387
{
435388
/* Initialize error_msg to 'no error'. */
436389
if (error_msg)
437390
*error_msg = NULL;
438391

439-
struct core_handle *ch = open_coredump(core_file, exe_file, maps_file, error_msg);
392+
struct core_handle *ch = open_coredump(core_file, exe_file, error_msg);
440393
if (*error_msg)
441394
return NULL;
442395

@@ -490,18 +443,3 @@ sr_core_stacktrace_from_gdb_maps(const char *gdb_output, const char *core_file,
490443
sr_gdb_stacktrace_free(gdb_stacktrace);
491444
return core_stacktrace;
492445
}
493-
494-
struct sr_core_stacktrace *
495-
sr_core_stacktrace_from_gdb(const char *gdb_output, const char *core_file,
496-
const char *exe_file, char **error_msg)
497-
{
498-
return sr_core_stacktrace_from_gdb_maps(gdb_output, core_file, exe_file, NULL, error_msg);
499-
}
500-
501-
struct sr_core_stacktrace *
502-
sr_parse_coredump(const char *core_file,
503-
const char *exe_file,
504-
char **error_msg)
505-
{
506-
return sr_parse_coredump_maps(core_file, exe_file, NULL, error_msg);
507-
}

lib/core_unwind_elfutils.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,17 @@ unwind_thread(Dwfl_Thread *thread, void *data)
137137
}
138138

139139
struct sr_core_stacktrace *
140-
sr_parse_coredump_maps(const char *core_file,
141-
const char *exe_file,
142-
const char *maps_file,
143-
char **error_msg)
140+
sr_parse_coredump(const char *core_file,
141+
const char *exe_file,
142+
char **error_msg)
144143
{
145144
struct sr_core_stacktrace *stacktrace = NULL;
146145

147146
/* Initialize error_msg to 'no error'. */
148147
if (error_msg)
149148
*error_msg = NULL;
150149

151-
struct core_handle *ch = open_coredump(core_file, exe_file, maps_file, error_msg);
150+
struct core_handle *ch = open_coredump(core_file, exe_file, error_msg);
152151
if (!ch)
153152
goto fail;
154153

lib/core_unwind_libunwind.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,17 @@ get_signal_number_libunwind(struct UCD_info *ui)
127127
}
128128

129129
struct sr_core_stacktrace *
130-
sr_parse_coredump_maps(const char *core_file,
131-
const char *exe_file,
132-
const char *maps_file,
133-
char **error_msg)
130+
sr_parse_coredump(const char *core_file,
131+
const char *exe_file,
132+
char **error_msg)
134133
{
135134
struct sr_core_stacktrace *stacktrace = NULL;
136135

137136
/* Initialize error_msg to 'no error'. */
138137
if (error_msg)
139138
*error_msg = NULL;
140139

141-
struct core_handle *ch = open_coredump(core_file, exe_file, maps_file, error_msg);
140+
struct core_handle *ch = open_coredump(core_file, exe_file, error_msg);
142141
if (*error_msg)
143142
return NULL;
144143

lib/internal_unwind.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct core_handle
8585
/* Gets dwfl handle and executable map data to be used for unwinding. The
8686
* executable map is only used by libunwind. */
8787
struct core_handle *
88-
open_coredump(const char *elf_file, const char *exe_file, const char *maps_file, char **error_msg);
88+
open_coredump(const char *elf_file, const char *exe_file, char **error_msg);
8989

9090
void
9191
core_handle_free(struct core_handle *ch);

0 commit comments

Comments
 (0)