backtrace.c: Revert last two changes.

* backtrace.c: Revert last two changes.  Don't call mmap
	directly.

From-SVN: r259440
This commit is contained in:
Ian Lance Taylor 2018-04-17 17:58:05 +00:00 committed by Ian Lance Taylor
parent c36af1b4da
commit 21070494d8
2 changed files with 16 additions and 34 deletions

View File

@ -1,3 +1,8 @@
2018-04-17 Ian Lance Taylor <iant@golang.org>
* backtrace.c: Revert last two changes. Don't call mmap
directly.
2018-04-17 Ian Lance Taylor <iant@golang.org> 2018-04-17 Ian Lance Taylor <iant@golang.org>
* backtrace.c: Include backtrace-supported.h before checking * backtrace.c: Include backtrace-supported.h before checking

View File

@ -32,27 +32,12 @@ POSSIBILITY OF SUCH DAMAGE. */
#include "config.h" #include "config.h"
#include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include "backtrace-supported.h"
#if !BACKTRACE_USES_MALLOC
#include <sys/mman.h>
#endif
#include "unwind.h" #include "unwind.h"
#include "backtrace.h" #include "backtrace.h"
#include "internal.h" #include "internal.h"
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#endif
/* The main backtrace_full routine. */ /* The main backtrace_full routine. */
/* Data passed through _Unwind_Backtrace. */ /* Data passed through _Unwind_Backtrace. */
@ -119,6 +104,7 @@ backtrace_full (struct backtrace_state *state, int skip,
backtrace_error_callback error_callback, void *data) backtrace_error_callback error_callback, void *data)
{ {
struct backtrace_data bdata; struct backtrace_data bdata;
void *p;
bdata.skip = skip + 1; bdata.skip = skip + 1;
bdata.state = state; bdata.state = state;
@ -127,25 +113,16 @@ backtrace_full (struct backtrace_state *state, int skip,
bdata.data = data; bdata.data = data;
bdata.ret = 0; bdata.ret = 0;
#if !BACKTRACE_USES_MALLOC /* If we can't allocate any memory at all, don't try to produce
{ file/line information. */
size_t pagesize; p = backtrace_alloc (state, 4096, NULL, NULL);
void *page; if (p == NULL)
bdata.can_alloc = 0;
/* If we can't allocate any memory at all, don't try to produce else
file/line information. */ {
pagesize = getpagesize (); backtrace_free (state, p, 4096, NULL, NULL);
page = mmap (NULL, pagesize, PROT_READ | PROT_WRITE, bdata.can_alloc = 1;
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); }
if (page == MAP_FAILED)
bdata.can_alloc = 0;
else
{
munmap (page, pagesize);
bdata.can_alloc = 1;
}
}
#endif
_Unwind_Backtrace (unwind, &bdata); _Unwind_Backtrace (unwind, &bdata);
return bdata.ret; return bdata.ret;