~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/signal_handler.cc

  • Committer: Monty Taylor
  • Date: 2010-10-19 21:58:26 UTC
  • mfrom: (1861.3.7 ld-version-script)
  • mto: This revision was merged to the branch mainline in revision 1863.
  • Revision ID: mordred@inaugust.com-20101019215826-ofh15co6vp47vndb
Merge Monty - Fixed the valgrind errors, made it so that haildb works in trunk with no extra magic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "drizzled/plugin.h"
30
30
#include "drizzled/plugin/scheduler.h"
31
31
 
32
 
#include "drizzled/util/backtrace.h"
 
32
#ifdef __GNUC__
 
33
#ifdef HAVE_BACKTRACE
 
34
#include <execinfo.h>
 
35
#include <cxxabi.h>
 
36
#endif // HAVE_BACKTRACE
 
37
#endif // __GNUC__
33
38
 
34
39
using namespace drizzled;
35
40
 
96
101
#endif
97
102
}
98
103
 
 
104
#define BACKTRACE_STACK_SIZE 50
99
105
void drizzled_handle_segfault(int sig)
100
106
{
101
107
  time_t curr_time;
145
151
                    "Hope that's ok; if not, decrease some variables in the "
146
152
                    "equation.\n\n"));
147
153
 
148
 
  drizzled::util::custom_backtrace();
 
154
#ifdef __GNUC__
 
155
#ifdef HAVE_BACKTRACE
 
156
  {
 
157
    void *array[BACKTRACE_STACK_SIZE];
 
158
    size_t size;
 
159
    char **strings;
 
160
 
 
161
    size= backtrace(array, BACKTRACE_STACK_SIZE);
 
162
    strings= backtrace_symbols(array, size);
 
163
 
 
164
    std::cerr << "Number of stack frames obtained: " << size <<  std::endl;
 
165
 
 
166
    for (size_t x= 1; x < size; x++) 
 
167
    {
 
168
      size_t sz= 200;
 
169
      char *function= (char *)malloc(sz);
 
170
      char *begin= 0;
 
171
      char *end= 0;
 
172
 
 
173
      for (char *j = strings[x]; *j; ++j)
 
174
      {
 
175
        if (*j == '(') {
 
176
          begin = j;
 
177
        }
 
178
        else if (*j == '+') {
 
179
          end = j;
 
180
        }
 
181
      }
 
182
      if (begin && end)
 
183
      {
 
184
        begin++;
 
185
        *end= '\0';
 
186
 
 
187
        int status;
 
188
        char *ret = abi::__cxa_demangle(begin, function, &sz, &status);
 
189
        if (ret) 
 
190
        {
 
191
          function= ret;
 
192
        }
 
193
        else
 
194
        {
 
195
          std::strncpy(function, begin, sz);
 
196
          std::strncat(function, "()", sz);
 
197
          function[sz-1] = '\0';
 
198
        }
 
199
        std::cerr << function << std::endl;
 
200
      }
 
201
      else
 
202
      {
 
203
        std::cerr << strings[x] << std::endl;
 
204
      }
 
205
      free(function);
 
206
    }
 
207
 
 
208
 
 
209
    free (strings);
 
210
  }
 
211
#endif // HAVE_BACKTRACE
 
212
#endif // __GNUC__
149
213
 
150
214
  write_core(sig);
151
215