Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 581470
Collapse All | Expand All

(-)a/Makefile (+5 lines)
Lines 205-210 ifdef HAVE_MACOS Link Here
205
  CFLAGS += -DHAVE_MACOS -Wno-deprecated-declarations
205
  CFLAGS += -DHAVE_MACOS -Wno-deprecated-declarations
206
endif
206
endif
207
207
208
# Musl doesn't have execinfo.h.
209
ifndef HAVE_MUSL
210
  CFLAGS += -DHAVE_EXECINFO_H
211
endif
212
208
# And a few more default utilities
213
# And a few more default utilities
209
LD = ${CC}
214
LD = ${CC}
210
CXX ?= g++
215
CXX ?= g++
(-)a/firmware/stub/vboot_api_stub_sf.c (+15 lines)
Lines 5-11 Link Here
5
 * Stub implementations of firmware-provided API functions.
5
 * Stub implementations of firmware-provided API functions.
6
 */
6
 */
7
7
8
/* Musl doesn't have execinfo.h.
9
   TODO(dje): Add a replacement (libunwind) if/when fnl needs it.  */
10
#ifdef HAVE_EXECINFO_H
8
#include <execinfo.h>
11
#include <execinfo.h>
12
#endif
13
9
#include <stdint.h>
14
#include <stdint.h>
10
15
11
#define _STUB_IMPLEMENTATION_
16
#define _STUB_IMPLEMENTATION_
Lines 26-37 struct alloc_node { Link Here
26
	struct alloc_node *next;
31
	struct alloc_node *next;
27
	void *ptr;
32
	void *ptr;
28
	size_t size;
33
	size_t size;
34
#ifdef HAVE_EXECINFO_H
29
	void *bt_buffer[MAX_STACK_LEVELS];
35
	void *bt_buffer[MAX_STACK_LEVELS];
30
	int bt_levels;
36
	int bt_levels;
37
#endif
31
};
38
};
32
39
33
static struct alloc_node *alloc_head;
40
static struct alloc_node *alloc_head;
34
41
42
#ifdef HAVE_EXECINFO_H
35
static void print_stacktrace(void)
43
static void print_stacktrace(void)
36
{
44
{
37
	void *buffer[MAX_STACK_LEVELS];
45
	void *buffer[MAX_STACK_LEVELS];
Lines 40-45 static void print_stacktrace(void) Link Here
40
	// print to stderr (fd = 2), and remove this function from the trace
48
	// print to stderr (fd = 2), and remove this function from the trace
41
	backtrace_symbols_fd(buffer + 1, levels - 1, 2);
49
	backtrace_symbols_fd(buffer + 1, levels - 1, 2);
42
}
50
}
51
#endif
43
52
44
void *VbExMalloc(size_t size)
53
void *VbExMalloc(size_t size)
45
{
54
{
Lines 57-63 void *VbExMalloc(size_t size) Link Here
57
	node->next = alloc_head;
66
	node->next = alloc_head;
58
	node->ptr = p;
67
	node->ptr = p;
59
	node->size = size;
68
	node->size = size;
69
#ifdef HAVE_EXECINFO_H
60
	node->bt_levels = backtrace(node->bt_buffer, MAX_STACK_LEVELS);
70
	node->bt_levels = backtrace(node->bt_buffer, MAX_STACK_LEVELS);
71
#endif
61
	alloc_head = node;
72
	alloc_head = node;
62
73
63
	return p;
74
	return p;
Lines 86-92 void VbExFree(void *ptr) Link Here
86
	} else {
97
	} else {
87
		fprintf(stderr, "\n>>>>>> Invalid VbExFree() %p\n", ptr);
98
		fprintf(stderr, "\n>>>>>> Invalid VbExFree() %p\n", ptr);
88
		fflush(stderr);
99
		fflush(stderr);
100
#ifdef HAVE_EXECINFO_H
89
		print_stacktrace();
101
		print_stacktrace();
102
#endif
90
		/*
103
		/*
91
		 * Fall through and do the free() so we get normal error
104
		 * Fall through and do the free() so we get normal error
92
		 * handling.
105
		 * handling.
Lines 118-125 int vboot_api_stub_check_memory(void) Link Here
118
		next = node->next;
131
		next = node->next;
119
		fprintf(stderr, "\nptr=%p, size=%zd\n", node->ptr, node->size);
132
		fprintf(stderr, "\nptr=%p, size=%zd\n", node->ptr, node->size);
120
		fflush(stderr);
133
		fflush(stderr);
134
#ifdef HAVE_EXECINFO_H
121
		backtrace_symbols_fd(node->bt_buffer + 1, node->bt_levels - 1,
135
		backtrace_symbols_fd(node->bt_buffer + 1, node->bt_levels - 1,
122
				     2);
136
				     2);
137
#endif
123
		free(node);
138
		free(node);
124
	}
139
	}
125
140

Return to bug 581470