summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2009-02-18 09:29:39 -0600
committerDavid Smith <dsmith@redhat.com>2009-02-18 09:29:39 -0600
commit321b13b9ac2a395db1c7591cfe86bddfc0944e25 (patch)
tree60f7c5d5acb2c26ad6640e818cfbea3baa8da85a
parent912907c362c919c33802104c0cd04c467c3e64cc (diff)
downloadsystemtap-steved-321b13b9ac2a395db1c7591cfe86bddfc0944e25.tar.gz
systemtap-steved-321b13b9ac2a395db1c7591cfe86bddfc0944e25.tar.xz
systemtap-steved-321b13b9ac2a395db1c7591cfe86bddfc0944e25.zip
Removed unused functions and variables.
2009-02-18 David Smith <dsmith@redhat.com> * io.c (_stp_log): Removed unused function. * map.c (_stp_cmp): Replace _stp_log() with dbug(). * mempool.c (_stp_mempool_resize): Removed unused function. * print.c (next_fmt): Removed unused function. * procfs.c: Removed unused variable '_stp_num_procfs_files'. * regs.c (_stp_ret_addr): Removed unused function. * string.c (_stp_text_str): Removed unused variable 'len'. * string.h: Removed unused variable '_stdout_' and function declaration for deleted function '_stp_vsprintf'. * sym.c: Removed unused variables. * unwind.c (_stp_create_unwind_hdr): Removed unused function. 2009-02-18 David Smith <dsmith@redhat.com> * control.c: Removed unused variable '_stp_current_buffers'. * procfs.c (_stp_set_buffers): Removed unused function. (_stp_register_ctl_channel_fs): Removed unused variables and label. * symbols.c (u32_swap): Removed unused function. (generic_swap): Ditto. (_stp_sort): Ditto. (_stp_section_is_interesting): Ditto. * transport.c (_stp_transport_init): Removed unused variable 'ret'.
-rw-r--r--runtime/ChangeLog14
-rw-r--r--runtime/io.c20
-rw-r--r--runtime/map.c4
-rw-r--r--runtime/mempool.c37
-rw-r--r--runtime/print.c36
-rw-r--r--runtime/procfs.c1
-rw-r--r--runtime/regs.c37
-rw-r--r--runtime/string.c3
-rw-r--r--runtime/string.h6
-rw-r--r--runtime/sym.c4
-rw-r--r--runtime/transport/ChangeLog13
-rw-r--r--runtime/transport/control.c2
-rw-r--r--runtime/transport/procfs.c18
-rw-r--r--runtime/transport/symbols.c95
-rw-r--r--runtime/transport/transport.c2
-rw-r--r--runtime/unwind.c125
16 files changed, 43 insertions, 374 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog
index d6019cb1..c531007c 100644
--- a/runtime/ChangeLog
+++ b/runtime/ChangeLog
@@ -1,3 +1,17 @@
+2009-02-18 David Smith <dsmith@redhat.com>
+
+ * io.c (_stp_log): Removed unused function.
+ * map.c (_stp_cmp): Replace _stp_log() with dbug().
+ * mempool.c (_stp_mempool_resize): Removed unused function.
+ * print.c (next_fmt): Removed unused function.
+ * procfs.c: Removed unused variable '_stp_num_procfs_files'.
+ * regs.c (_stp_ret_addr): Removed unused function.
+ * string.c (_stp_text_str): Removed unused variable 'len'.
+ * string.h: Removed unused variable '_stdout_' and function
+ declaration for deleted function '_stp_vsprintf'.
+ * sym.c: Removed unused variables.
+ * unwind.c (_stp_create_unwind_hdr): Removed unused function.
+
2009-02-17 Mark Wielaard <scox@redhat.com>
* sdt.h: Move to ../includes/sys.
diff --git a/runtime/io.c b/runtime/io.c
index c7223fb0..8ddb53ac 100644
--- a/runtime/io.c
+++ b/runtime/io.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* I/O for printing warnings, errors and debug messages
- * Copyright (C) 2005-2008 Red Hat Inc.
+ * Copyright (C) 2005-2009 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -56,24 +56,6 @@ static void _stp_vlog (enum code type, const char *func, int line, const char *f
put_cpu();
}
-/** Logs Data.
- * This function sends the message immediately to staprun. It
- * will also be sent over the bulk transport (relayfs) if it is
- * being used. If the last character is not a newline, then one
- * is added. This function is not as efficient as _stp_printf()
- * and should only be used for urgent messages. You probably want
- * dbug(), or _stp_warn().
- * @param fmt A variable number of args.
- * @todo Evaluate if this function is necessary.
- */
-static void _stp_log (const char *fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- _stp_vlog (INFO, NULL, 0, fmt, args);
- va_end(args);
-}
-
/** Prints warning.
* This function sends a warning message immediately to staprun. It
* will also be sent over the bulk transport (relayfs) if it is
diff --git a/runtime/map.c b/runtime/map.c
index 56f67dfb..de25d6f3 100644
--- a/runtime/map.c
+++ b/runtime/map.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* Map Functions
- * Copyright (C) 2005, 2006, 2007, 2008 Red Hat Inc.
+ * Copyright (C) 2005-2009 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -444,7 +444,7 @@ static int _stp_cmp (struct list_head *a, struct list_head *b, int keynum, int d
ret = 1;
else
ret = 0;
- //_stp_log ("comparing %s and %s and returning %d\n", _stp_get_str(m1), _stp_get_str(m2), ret);
+ //dbug ("comparing %s and %s and returning %d\n", _stp_get_str(m1), _stp_get_str(m2), ret);
return ret;
} else {
int64_t a,b;
diff --git a/runtime/mempool.c b/runtime/mempool.c
index 0fbb4326..f8831428 100644
--- a/runtime/mempool.c
+++ b/runtime/mempool.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* Preallocated memory pools
- * Copyright (C) 2008 Red Hat Inc.
+ * Copyright (C) 2008-2009 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -72,41 +72,6 @@ err:
return NULL;
}
-/* Resize a memory pool */
-static int _stp_mempool_resize(_stp_mempool_t *pool, size_t num)
-{
- int i;
- unsigned long flags;
- struct _stp_mem_buffer *m;
-
- if (unlikely(num == 0 || num == pool->num))
- return pool->num;
-
- if (num > pool->num) {
- for (i = 0; i < num - pool->num; i++) {
- m = (struct _stp_mem_buffer *)_stp_kmalloc(pool->size);
- if (unlikely(m == NULL))
- goto done;
- m->pool = pool;
- pool->num++;
- spin_lock_irqsave(&pool->lock, flags);
- list_add((struct list_head *)m, &pool->free_list);
- spin_unlock_irqrestore(&pool->lock, flags);
- }
- } else {
- for (i = 0; i < pool->num - num; i++) {
- spin_lock_irqsave(&pool->lock, flags);
- m = (struct _stp_mem_buffer *)pool->free_list.next;
- list_del(&m->list);
- spin_unlock_irqrestore(&pool->lock, flags);
- _stp_kfree(m);
- }
- pool->num = num;
- }
-done:
- return num;
-}
-
/* allocate a buffer from a memory pool */
static void *_stp_mempool_alloc(_stp_mempool_t *pool)
{
diff --git a/runtime/print.c b/runtime/print.c
index 54919876..2c84d3c9 100644
--- a/runtime/print.c
+++ b/runtime/print.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* Print Functions
- * Copyright (C) 2007-2008 Red Hat Inc.
+ * Copyright (C) 2007-2009 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -41,7 +41,7 @@ typedef struct __stp_pbuf {
static void *Stp_pbuf = NULL;
-/** private buffer for _stp_log() */
+/** private buffer for _stp_vlog() */
#define STP_LOG_BUF_LEN 256
typedef char _stp_lbuf[STP_LOG_BUF_LEN];
@@ -233,7 +233,6 @@ static void _stp_print (const char *str)
static void _stp_print_char (const char c)
{
- char *buf;
_stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id());
int size = STP_BUFFER_SIZE - pb->len;
if (unlikely(1 >= size))
@@ -243,37 +242,6 @@ static void _stp_print_char (const char c)
pb->len ++;
}
-/* This function is used when printing maps or stats. */
-/* Probably belongs elsewhere, but is here for now. */
-/* It takes a format specification like those used for */
-/* printing maps and stats. It prints chars until it sees */
-/* a special format char (beginning with '%'. Then it */
-/* returns a pointer to that. */
-static char *next_fmt(char *fmt, int *num)
-{
- char *f = fmt;
- int in_fmt = 0;
- *num = 0;
- while (*f) {
- if (in_fmt) {
- if (*f == '%') {
- _stp_print_char('%');
- in_fmt = 0;
- } else if (*f > '0' && *f <= '9') {
- *num = *f - '0';
- f++;
- return f;
- } else
- return f;
- } else if (*f == '%')
- in_fmt = 1;
- else
- _stp_print_char(*f);
- f++;
- }
- return f;
-}
-
static void _stp_print_kernel_info(char *vstr, int ctx, int num_probes)
{
#ifdef DEBUG_MEM
diff --git a/runtime/procfs.c b/runtime/procfs.c
index 7e3c8352..d6b75336 100644
--- a/runtime/procfs.c
+++ b/runtime/procfs.c
@@ -19,7 +19,6 @@
#define STP_MAX_PROCFS_FILES 16
static int _stp_num_pde = 0;
-static int _stp_num_procfs_files = 0;
static struct proc_dir_entry *_stp_pde[STP_MAX_PROCFS_FILES];
static struct proc_dir_entry *_stp_procfs_files[STP_MAX_PROCFS_FILES];
static struct proc_dir_entry *_stp_proc_stap = NULL;
diff --git a/runtime/regs.c b/runtime/regs.c
index 2f7c741d..e963affa 100644
--- a/runtime/regs.c
+++ b/runtime/regs.c
@@ -23,43 +23,6 @@
* @{
*/
-
-/** Get the current return address.
- * Call from kprobes (not jprobes).
- * @param regs The pt_regs saved by the kprobe.
- * @return The return address saved in the stack pointer.
- * @note i386 and x86_64 only so far.
- */
-
-static unsigned long _stp_ret_addr (struct pt_regs *regs)
-{
-#if defined (STAPCONF_X86_UNIREGS) && (defined (__x86_64__) || defined (__i386__))
- unsigned long *ra = (unsigned long *)regs->sp;
- if (ra)
- return *ra;
- else
- return 0;
-#elif defined (__x86_64__)
- unsigned long *ra = (unsigned long *)regs->rsp;
- if (ra)
- return *ra;
- else
- return 0;
-#elif defined (__i386__)
- return regs->esp;
-#elif defined (__powerpc64__) || defined (__arm__)
- return REG_LINK(regs);
-#elif defined (__ia64__)
- return regs->b0;
-#elif defined (__s390__) || defined (__s390x__)
- return regs->gprs[14];
-#elif defined (__arm__)
- return regs->ARM_r0;
-#else
- #error Unimplemented architecture
-#endif
-}
-
/** Get the current return address for a return probe.
* Call from kprobe return probe.
* @param ri Pointer to the struct kretprobe_instance.
diff --git a/runtime/string.c b/runtime/string.c
index c087c783..cdafbf64 100644
--- a/runtime/string.c
+++ b/runtime/string.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* String Functions
- * Copyright (C) 2005, 2006, 2007 Red Hat Inc.
+ * Copyright (C) 2005, 2006, 2007, 2009 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -62,7 +62,6 @@ static int _stp_vscnprintf(char *buf, size_t size, const char *fmt, va_list args
*/
static void _stp_text_str(char *outstr, char *in, int len, int quoted, int user)
{
- const int length = len;
char c, *out = outstr;
if (len == 0 || len > MAXSTRINGLEN-1)
diff --git a/runtime/string.h b/runtime/string.h
index c955da6c..f4d4cc05 100644
--- a/runtime/string.h
+++ b/runtime/string.h
@@ -1,5 +1,5 @@
/* -*- linux-c -*-
- * Copyright (C) 2005, 2007 Red Hat Inc.
+ * Copyright (C) 2005, 2007, 2009 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -9,11 +9,7 @@
#ifndef _STRING_H_
#define _STRING_H_
-/* set up a special stdout string */
-static char _stp_stdout[] = "_stdout_";
-
#define to_oct_digit(c) ((c) + '0')
-static void _stp_vsprintf (char *str, const char *fmt, va_list args);
static void _stp_text_str(char *out, char *in, int len, int quoted, int user);
/*
diff --git a/runtime/sym.c b/runtime/sym.c
index 62c9f3ce..1d88a862 100644
--- a/runtime/sym.c
+++ b/runtime/sym.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* Symbolic Lookup Functions
- * Copyright (C) 2005-2008 Red Hat Inc.
+ * Copyright (C) 2005-2009 Red Hat Inc.
* Copyright (C) 2006 Intel Corporation.
*
* This file is part of systemtap, and is free software. You can
@@ -25,7 +25,6 @@ static unsigned long _stp_module_relocate(const char *module, const char *sectio
{
static struct _stp_module *last = NULL;
static struct _stp_section *last_sec;
- unsigned long flags;
unsigned i, j;
/* if module is -1, we invalidate last. _stp_del_module calls this when modules are deleted. */
@@ -114,7 +113,6 @@ static const char *_stp_kallsyms_lookup(unsigned long addr, unsigned long *symbo
struct _stp_module *m = NULL;
struct _stp_section *sec = NULL;
struct _stp_symbol *s = NULL;
- unsigned long flags;
unsigned end, begin = 0;
m = _stp_mod_sec_lookup(addr, &sec);
diff --git a/runtime/transport/ChangeLog b/runtime/transport/ChangeLog
index efaee102..14abee41 100644
--- a/runtime/transport/ChangeLog
+++ b/runtime/transport/ChangeLog
@@ -1,3 +1,16 @@
+2009-02-18 David Smith <dsmith@redhat.com>
+
+ * control.c: Removed unused variable '_stp_current_buffers'.
+ * procfs.c (_stp_set_buffers): Removed unused function.
+ (_stp_register_ctl_channel_fs): Removed unused variables and
+ label.
+ * symbols.c (u32_swap): Removed unused function.
+ (generic_swap): Ditto.
+ (_stp_sort): Ditto.
+ (_stp_section_is_interesting): Ditto.
+ * transport.c (_stp_transport_init): Removed unused variable
+ 'ret'.
+
2009-02-17 David Smith <dsmith@redhat.com>
* control.c: Contains generic control channel functions.
diff --git a/runtime/transport/control.c b/runtime/transport/control.c
index da2a180c..edde244d 100644
--- a/runtime/transport/control.c
+++ b/runtime/transport/control.c
@@ -9,8 +9,6 @@
* later version.
*/
-static int _stp_current_buffers = STP_DEFAULT_BUFFERS;
-
static _stp_mempool_t *_stp_pool_q;
static struct list_head _stp_ctl_ready_q;
static DEFINE_SPINLOCK(_stp_ctl_ready_lock);
diff --git a/runtime/transport/procfs.c b/runtime/transport/procfs.c
index 5a8e4238..6afbdea1 100644
--- a/runtime/transport/procfs.c
+++ b/runtime/transport/procfs.c
@@ -81,13 +81,6 @@ inline static int _stp_ctl_write_fs(int type, void *data, unsigned len)
return 0;
}
-/* set the number of buffers to use to 'num' */
-static int _stp_set_buffers(int num)
-{
- dbug_trans(1, "stp_set_buffers %d\n", num);
- return _stp_mempool_resize(_stp_pool_q, num);
-}
-
static int _stp_ctl_read_bufsize(char *page, char **start, off_t off, int count, int *eof, void *data)
{
int len = sprintf(page, "%d,%d\n", _stp_nsubbufs, _stp_subbuf_size);
@@ -104,13 +97,13 @@ static int _stp_ctl_read_bufsize(char *page, char **start, off_t off, int count,
static int _stp_register_ctl_channel_fs(void)
{
- int i;
- const char *dirname = "systemtap";
- char buf[32];
#ifdef STP_BULKMODE
+ int i;
int j;
+ char buf[32];
+ struct proc_dir_entry *bs = NULL;
#endif
- struct proc_dir_entry *de, *bs = NULL;
+ struct proc_dir_entry *de;
if (!_stp_mkdir_proc_module())
goto err0;
@@ -144,8 +137,7 @@ static int _stp_register_ctl_channel_fs(void)
de->proc_fops = &_stp_ctl_fops_cmd;
return 0;
-err2:
- remove_proc_entry(".cmd", _stp_proc_root);
+
err1:
#ifdef STP_BULKMODE
for (de = _stp_proc_root->subdir; de; de = de->next)
diff --git a/runtime/transport/symbols.c b/runtime/transport/symbols.c
index b9458ada..a329effe 100644
--- a/runtime/transport/symbols.c
+++ b/runtime/transport/symbols.c
@@ -1,26 +1,18 @@
/* -*- linux-c -*-
* symbols.c - stp symbol and module functions
*
- * Copyright (C) Red Hat Inc, 2006-2008
+ * Copyright (C) Red Hat Inc, 2006-2009
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
* Public License (GPL); either version 2, or (at your option) any
* later version.
- *
- * The u32_swap(), generic_swap(), and sort() functions were adapted from
- * lib/sort.c of kernel 2.6.22-rc5. It was written by Matt Mackall.
*/
#ifndef _STP_SYMBOLS_C_
#define _STP_SYMBOLS_C_
#include "../sym.h"
-
-
-static void _stp_create_unwind_hdr(struct _stp_module *m);
-
-
static void _stp_do_relocation(const char __user *buf, size_t count)
{
struct _stp_msg_relocation msg;
@@ -68,89 +60,4 @@ static void _stp_do_relocation(const char __user *buf, size_t count)
} /* loop over modules */
}
-
-static void u32_swap(void *a, void *b, int size)
-{
- u32 t = *(u32 *)a;
- *(u32 *)a = *(u32 *)b;
- *(u32 *)b = t;
-}
-
-static void generic_swap(void *a, void *b, int size)
-{
- char *aa = a;
- char *bb = b;
- do {
- char t = *aa;
- *aa++ = *bb;
- *bb++ = t;
- } while (--size > 0);
-}
-
-/**
- * sort - sort an array of elements
- * @base: pointer to data to sort
- * @num: number of elements
- * @size: size of each element
- * @cmp_func: pointer to comparison function
- * @swap_func: pointer to swap function or NULL
- *
- * This function does a heapsort on the given array. You may provide a
- * swap function optimized to your element type.
- *
- * Sorting time is O(n log n) both on average and worst-case. While
- * qsort is about 20% faster on average, it suffers from exploitable
- * O(n*n) worst-case behavior and extra memory requirements that make
- * it less suitable for kernel use.
-*/
-static void _stp_sort(void *_base, size_t num, size_t size,
- int (*cmp_func) (const void *, const void *), void (*swap_func) (void *, void *, int size))
-{
- char *base = (char*) _base;
- /* pre-scale counters for performance */
- int i = (num / 2 - 1) * size, n = num * size, c, r;
-
- if (!swap_func)
- swap_func = (size == 4 ? u32_swap : generic_swap);
-
- /* heapify */
- for (; i >= 0; i -= size) {
- for (r = i; r * 2 + size < n; r = c) {
- c = r * 2 + size;
- if (c < n - size && cmp_func(base + c, base + c + size) < 0)
- c += size;
- if (cmp_func(base + r, base + c) >= 0)
- break;
- swap_func(base + r, base + c, size);
- }
- }
-
- /* sort */
- for (i = n - size; i >= 0; i -= size) {
- swap_func(base, base + i, size);
- for (r = 0; r * 2 + size < i; r = c) {
- c = r * 2 + size;
- if (c < i - size && cmp_func(base + c, base + c + size) < 0)
- c += size;
- if (cmp_func(base + r, base + c) >= 0)
- break;
- swap_func(base + r, base + c, size);
- }
- }
-}
-
-/* filter out section names we don't care about */
-static int _stp_section_is_interesting(const char *name)
-{
- int ret = 1;
- if (!strncmp("__", name, 2)
- || (!strncmp(".note", name, 5)
- && strncmp(".note.gnu.build-id", name, 18))
- || !strncmp(".gnu", name, 4)
- || !strncmp(".mod", name, 4))
- ret = 0;
- return ret;
-}
-
-
#endif /* _STP_SYMBOLS_C_ */
diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
index 81c5702c..0755781e 100644
--- a/runtime/transport/transport.c
+++ b/runtime/transport/transport.c
@@ -217,8 +217,6 @@ static struct utt_trace *_stp_utt_open(void)
*/
static int _stp_transport_init(void)
{
- int ret;
-
dbug_trans(1, "transport_init\n");
_stp_init_pid = current->pid;
#ifdef STAPCONF_TASK_UID
diff --git a/runtime/unwind.c b/runtime/unwind.c
index c1362237..9c704e28 100644
--- a/runtime/unwind.c
+++ b/runtime/unwind.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* kernel stack unwinding
- * Copyright (C) 2008 Red Hat Inc.
+ * Copyright (C) 2008-2009 Red Hat Inc.
*
* Based on old kernel code that is
* Copyright (C) 2002-2006 Novell, Inc.
@@ -42,129 +42,6 @@ static void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)
e2->fde = v;
}
-/* Build a binary-searchable unwind header. Also do some
- * validity checks. In the future we might use */
-/* .eh_frame_hdr if it is already present. */
-static void _stp_create_unwind_hdr(struct _stp_module *m)
-{
- const u8 *ptr;
- unsigned long tableSize, hdrSize, last;
- unsigned n = 0;
- const u32 *fde;
- int bad_order = 0;
- struct {
- u8 version;
- u8 eh_frame_ptr_enc;
- u8 fde_count_enc;
- u8 table_enc;
- unsigned long eh_frame_ptr;
- unsigned int fde_count;
- struct eh_frame_hdr_table_entry table[];
- } __attribute__ ((__packed__)) * header = NULL;
-
- /* already did this or no data? */
- if (m->unwind_hdr || m->unwind_data_len == 0)
- return;
-
- tableSize = m->unwind_data_len;
- if (tableSize & (sizeof(*fde) - 1)) {
- dbug_unwind(1, "tableSize=0x%x not a multiple of 0x%x\n", (int)tableSize, (int)sizeof(*fde));
- goto bad;
- }
-
- /* count the FDEs */
- for (fde = m->unwind_data;
- tableSize > sizeof(*fde) && tableSize - sizeof(*fde) >= *fde;
- tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
- signed ptrType;
- const u32 *cie;
-
- /* check for extended length */
- if ((*fde & 0xfffffff0) == 0xfffffff0) {
- dbug_unwind(1, "Module %s has extended-length CIE or FDE.");
- dbug_unwind(1, "This is not supported at this time.");
- goto bad;
- }
- cie = cie_for_fde(fde, m);
- if (cie == &not_fde)
- continue; /* fde was a CIE. That's OK, just skip it. */
- if (cie == NULL || cie == &bad_cie || (ptrType = fde_pointer_type(cie)) < 0)
- goto bad;
- /* we have a real FDE */
- ptr = (const u8 *)(fde + 2);
- if (!read_pointer(&ptr, (const u8 *)(fde + 1) + *fde, ptrType))
- goto bad;
- ++n;
- }
-
- if (tableSize || !n) {
- dbug_unwind(1, "%s: tableSize=%ld, n=%d\n", m->name, tableSize, n);
- goto bad;
- }
-
- hdrSize = 4 + sizeof(unsigned long) + sizeof(unsigned int) + 2 * n * sizeof(unsigned long);
- header = _stp_kmalloc(hdrSize);
- if (header == NULL) {
- header = _stp_vmalloc(hdrSize);
- if (header == NULL)
- return;
- }
-
- header->version = 1;
- header->eh_frame_ptr_enc = DW_EH_PE_absptr;
- header->fde_count_enc = DW_EH_PE_data4;
- header->table_enc = DW_EH_PE_absptr;
- _stp_put_unaligned((unsigned long)m->unwind_data, &header->eh_frame_ptr);
-
- BUILD_BUG_ON(offsetof(typeof(*header), fde_count)
- % __alignof(typeof(header->fde_count)));
- header->fde_count = n;
-
- BUILD_BUG_ON(offsetof(typeof(*header), table) % __alignof(typeof(*header->table)));
-
- n = 0;
- last = 0;
- tableSize = m->unwind_data_len;
- for (fde = m->unwind_data; tableSize; tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
- const u32 *cie = cie_for_fde(fde, m);
- if (cie == &not_fde)
- continue;
- if (cie == NULL || cie == &bad_cie)
- goto bad;
- /* we have a real FDE */
- ptr = (const u8 *)(fde + 2);
- header->table[n].start = read_pointer(&ptr, (const u8 *)(fde + 1) + *fde, fde_pointer_type(cie));
- header->table[n].fde = (unsigned long)fde;
- if (header->table[n].start < last)
- bad_order++;
- last = header->table[n].start;
- ++n;
- }
- WARN_ON(n != header->fde_count);
-
- /* Is sort ever necessary? */
- if (bad_order)
- _stp_sort(header->table, n, sizeof(*header->table), cmp_eh_frame_hdr_table_entries,
- swap_eh_frame_hdr_table_entries);
-
- m->unwind_hdr_len = hdrSize;
- m->unwind_hdr = header;
- return;
-
- /* unwind data is not acceptable. free it and return */
-bad:
- dbug_unwind(1, "unwind data for %s is unacceptable. Freeing.", m->name);
- if (header) {
- _stp_vfree(header);
- }
- if (m->unwind_data) {
- _stp_vfree(m->unwind_data);
- m->unwind_data = NULL;
- m->unwind_data_len = 0;
- }
- return;
-}
-
static uleb128_t get_uleb128(const u8 **pcur, const u8 *end)
{
const u8 *cur = *pcur;