~ubuntu-branches/ubuntu/vivid/mariadb-5.5/vivid-proposed

« back to all changes in this revision

Viewing changes to .pc/22_hppa_invalid_operands.diff/storage/xtradb/os/os0stacktrace.c

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2014-11-14 21:04:24 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20141114210424-xlyna0ozl11647o5
Tags: 5.5.40-0ubuntu0.14.10.1
* SECURITY UPDATE: Update to 5.5.40 to fix security issues (LP: #1391676)
  - CVE-2014-6507
  - CVE-2014-6491
  - CVE-2014-6500
  - CVE-2014-6469
  - CVE-2014-6555
  - CVE-2014-6559
  - CVE-2014-6494
  - CVE-2014-6496
  - CVE-2014-6464
* Add bsdutils as mariadb-server dependency like upstream does in 5.5.40.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 2013 SkySQL Ab. All Rights Reserved.
4
 
 
5
 
 
6
 
This program is free software; you can redistribute it and/or modify it under
7
 
the terms of the GNU General Public License as published by the Free Software
8
 
Foundation; version 2 of the License.
9
 
 
10
 
This program is distributed in the hope that it will be useful, but WITHOUT
11
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
 
 
14
 
You should have received a copy of the GNU General Public License along with
15
 
this program; if not, write to the Free Software Foundation, Inc.,
16
 
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
 
 
18
 
*****************************************************************************/
19
 
 
20
 
#include "os0thread.h"
21
 
 
22
 
#if defined (__linux__) && HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS
23
 
 
24
 
#if HAVE_EXECINFO_H
25
 
#include <execinfo.h>
26
 
#endif
27
 
 
28
 
#include <signal.h>
29
 
#include <stdio.h>
30
 
#include <stdlib.h>
31
 
#include <string.h>
32
 
#include <unistd.h>
33
 
 
34
 
#ifndef _GNU_SOURCE
35
 
#define _GNU_SOURCE
36
 
#endif
37
 
#ifndef __USE_GNU
38
 
#define __USE_GNU
39
 
#endif
40
 
#ifndef _XOPEN_SOURCE
41
 
#define _XOPEN_SOURCE
42
 
#endif
43
 
 
44
 
/* Since kernel version 2.2 the undocumented parameter to the signal handler has been declared
45
 
obsolete in adherence with POSIX.1b. A more correct way to retrieve additional information is
46
 
to use the SA_SIGINFO option when setting the handler */
47
 
#undef USE_SIGCONTEXT
48
 
 
49
 
#ifndef USE_SIGCONTEXT
50
 
/* get REG_EIP / REG_RIP from ucontext.h */
51
 
#include <ucontext.h>
52
 
 
53
 
        #ifndef EIP
54
 
        #define EIP     14
55
 
        #endif
56
 
 
57
 
        #if (defined (__x86_64__))
58
 
                #ifndef REG_RIP
59
 
                #define REG_RIP REG_INDEX(rip) /* seems to be 16 */
60
 
                #endif
61
 
        #endif
62
 
 
63
 
#endif
64
 
 
65
 
#define OS_STACKTRACE_MAX_DEPTH 128
66
 
 
67
 
/***************************************************************//**
68
 
Prints stacktrace for this thread.
69
 
*/
70
 
void
71
 
os_stacktrace_print(
72
 
/*================*/
73
 
        int        sig_num,
74
 
        siginfo_t* info,
75
 
        void*      ucontext)
76
 
{
77
 
        void*      array[OS_STACKTRACE_MAX_DEPTH];
78
 
        char**     messages;
79
 
        int        size, i;
80
 
        void*      caller_address = NULL;
81
 
 
82
 
        /* Get the address at the time the signal was raised */
83
 
#if defined(__x86_64__)
84
 
        ucontext_t* uc = (ucontext_t*) ucontext;
85
 
        caller_address = (void*) uc->uc_mcontext.gregs[REG_RIP] ;
86
 
#elif defined(__hppa__)
87
 
        ucontext_t* uc = (ucontext_t*) ucontext;
88
 
        caller_address = (void*) uc->uc_mcontext.sc_iaoq[0] & ~0x3UL ;
89
 
#elif (defined (__ppc__)) || (defined (__powerpc__))
90
 
        ucontext_t* uc = (ucontext_t*) ucontext;
91
 
        caller_address = (void*) uc->uc_mcontext.regs->nip ;
92
 
#elif defined(__sparc__)
93
 
        struct sigcontext* sc = (struct sigcontext*) ucontext;
94
 
#if __WORDSIZE == 64
95
 
        caller_address = (void*) sc->sigc_regs.tpc ;
96
 
#else
97
 
        caller_address = (void*) sc->si_regs.pc ;
98
 
#endif
99
 
#elif defined(__i386__)
100
 
        ucontext_t* uc = (ucontext_t*) ucontext;
101
 
        caller_address = (void*) uc->uc_mcontext.gregs[REG_EIP] ;
102
 
#else
103
 
        /* Unsupported return */
104
 
        return;
105
 
#endif
106
 
 
107
 
        fprintf(stderr, "InnoDB: signal %d (%s), address is %p from %p\n",
108
 
                sig_num, strsignal(sig_num), info->si_addr,
109
 
                (void *)caller_address);
110
 
 
111
 
        size = backtrace(array, OS_STACKTRACE_MAX_DEPTH);
112
 
 
113
 
        /* overwrite sigaction with caller's address */
114
 
        array[1] = caller_address;
115
 
 
116
 
        messages = backtrace_symbols(array, size);
117
 
 
118
 
        fprintf(stderr,
119
 
                "InnoDB: Stacktrace for Thread %lu \n",
120
 
                (ulong) os_thread_pf(os_thread_get_curr_id()));
121
 
 
122
 
        /* skip first stack frame (points here) */
123
 
        for (i = 1; i < size && messages != NULL; ++i)
124
 
        {
125
 
                fprintf(stderr, "InnoDB: [bt]: (%d) %s\n", i, messages[i]);
126
 
        }
127
 
 
128
 
        free(messages);
129
 
}
130
 
 
131
 
#endif /* __linux__ */