summaryrefslogtreecommitdiff
path: root/libbacktrace
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-26 20:08:29 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-26 20:08:29 +0000
commitb60ebf03c39c47a805e3329dd05a075db75487cb (patch)
tree19f70c7335db3f471b050d0ffdf8011662c823c7 /libbacktrace
parent8afb7c4b8a5f9f158e32723a7cf0ed0f514ecea7 (diff)
downloadgcc-b60ebf03c39c47a805e3329dd05a075db75487cb.tar.gz
PR other/55087
* posix.c (backtrace_open): Add does_not_exist parameter. * elf.c (phdr_callback): Do not warn if shared library could not be opened. * fileline.c (fileline_initialize): Update calls to backtrace_open. * internal.h (backtrace_open): Update declaration. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192861 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libbacktrace')
-rw-r--r--libbacktrace/ChangeLog10
-rw-r--r--libbacktrace/elf.c4
-rw-r--r--libbacktrace/fileline.c4
-rw-r--r--libbacktrace/internal.h10
-rw-r--r--libbacktrace/posix.c10
5 files changed, 31 insertions, 7 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 7a39adccecd..4850d9de37b 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,3 +1,13 @@
+2012-10-26 Ian Lance Taylor <iant@google.com>
+
+ PR other/55087
+ * posix.c (backtrace_open): Add does_not_exist parameter.
+ * elf.c (phdr_callback): Do not warn if shared library could not
+ be opened.
+ * fileline.c (fileline_initialize): Update calls to
+ backtrace_open.
+ * internal.h (backtrace_open): Update declaration.
+
2012-10-26 Jack Howarth <howarth@bromo.med.uc.edu>
PR target/55061
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index b396c47ef29..8433a72fcd6 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -810,6 +810,7 @@ phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED,
{
struct phdr_data *pd = (struct phdr_data *) pdata;
int descriptor;
+ int does_not_exist;
fileline elf_fileline_fn;
int found_dwarf;
@@ -821,7 +822,8 @@ phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED,
|| info->dlpi_addr == 0)
return 0;
- descriptor = backtrace_open (info->dlpi_name, pd->error_callback, pd->data);
+ descriptor = backtrace_open (info->dlpi_name, pd->error_callback, pd->data,
+ &does_not_exist);
if (descriptor < 0)
return 0;
diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c
index 4efd19b0595..e577ecc9061 100644
--- a/libbacktrace/fileline.c
+++ b/libbacktrace/fileline.c
@@ -80,9 +80,9 @@ fileline_initialize (struct backtrace_state *state,
/* We have not initialized the information. Do it now. */
if (state->filename != NULL)
- descriptor = backtrace_open (state->filename, error_callback, data);
+ descriptor = backtrace_open (state->filename, error_callback, data, NULL);
else
- descriptor = backtrace_open ("/proc/self/exe", error_callback, data);
+ descriptor = backtrace_open ("/proc/self/exe", error_callback, data, NULL);
if (descriptor < 0)
failed = 1;
diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h
index b1afca0a2d9..5e0dba44a85 100644
--- a/libbacktrace/internal.h
+++ b/libbacktrace/internal.h
@@ -109,10 +109,16 @@ struct backtrace_state
struct backtrace_freelist_struct *freelist;
};
-/* Open a file for reading. Returns -1 on error. */
+/* Open a file for reading. Returns -1 on error. If DOES_NOT_EXIST
+ is not NULL, *DOES_NOT_EXIST will be set to 0 normally and set to 1
+ if the file does not exist. If the file does not exist and
+ DOES_NOT_EXIST is not NULL, the function will return -1 and will
+ not call ERROR_CALLBACK. On other errors, or if DOES_NOT_EXIST is
+ NULL, the function will call ERROR_CALLBACK before returning. */
extern int backtrace_open (const char *filename,
backtrace_error_callback error_callback,
- void *data);
+ void *data,
+ int *does_not_exist);
/* A view of the contents of a file. This supports mmap when
available. A view will remain in memory even after backtrace_close
diff --git a/libbacktrace/posix.c b/libbacktrace/posix.c
index 01afc42b08e..4d6c852b781 100644
--- a/libbacktrace/posix.c
+++ b/libbacktrace/posix.c
@@ -57,14 +57,20 @@ POSSIBILITY OF SUCH DAMAGE. */
int
backtrace_open (const char *filename, backtrace_error_callback error_callback,
- void *data)
+ void *data, int *does_not_exist)
{
int descriptor;
+ if (does_not_exist != NULL)
+ *does_not_exist = 0;
+
descriptor = open (filename, O_RDONLY | O_BINARY | O_CLOEXEC);
if (descriptor < 0)
{
- error_callback (data, filename, errno);
+ if (does_not_exist != NULL && errno == ENOENT)
+ *does_not_exist = 1;
+ else
+ error_callback (data, filename, errno);
return -1;
}