~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/stacktrace.cc

Moved the last of the libdrizzleclient calls into Protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
#include "drizzled/stacktrace.h"
22
 
#include <cstddef>
 
20
#include "drizzled/global.h"
 
21
#include "stacktrace.h"
23
22
 
24
23
#include <signal.h>
25
 
#include "drizzled/internal/my_pthread.h"
26
 
#include "drizzled/internal/m_string.h"
 
24
#include <mysys/my_pthread.h>
 
25
#include <mystrings/m_string.h>
27
26
#ifdef HAVE_STACKTRACE
28
27
#include <unistd.h>
29
28
#include <strings.h>
32
31
#include <execinfo.h>
33
32
#endif
34
33
 
35
 
#include <cstring>
36
 
#include <cstdio>
37
 
#include <algorithm>
38
 
 
39
 
#include "drizzled/definitions.h"
40
 
 
41
 
using namespace std;
42
 
 
43
 
namespace drizzled
44
 
{
45
 
 
46
34
#define PTR_SANE(p) ((p) && (char*)(p) >= heap_start && (char*)(p) <= heap_end)
47
35
 
48
36
char *heap_start;
159
147
 
160
148
  if (!stack_bottom || (unsigned char*) stack_bottom > (unsigned char*) &fp)
161
149
  {
162
 
    ulong tmp= min((size_t)0x10000,thread_stack);
 
150
    ulong tmp= cmin(0x10000,thread_stack);
163
151
    /* Assume that the stack starts at the previous even 65K */
164
152
    stack_bottom= (unsigned char*) (((ulong) &fp + tmp) &
165
153
                          ~(ulong) 0xFFFF);
177
165
  fprintf(stderr, "Stack range sanity check OK, backtrace follows:\n");
178
166
 
179
167
  /* We are 1 frame above signal frame with NPTL and 2 frames above with LT */
180
 
  sigreturn_frame_count = internal::thd_lib_detected == THD_LIB_LT ? 2 : 1;
 
168
  sigreturn_frame_count = thd_lib_detected == THD_LIB_LT ? 2 : 1;
181
169
 
182
170
  while (fp < (unsigned char**) stack_bottom)
183
171
  {
207
195
          "problem, so please do resolve it\n");
208
196
}
209
197
#endif /* TARGET_OS_LINUX */
210
 
 
211
 
} /* namespace drizzled */
212
 
 
213
198
#endif /* HAVE_STACKTRACE */
214
199
 
215
200
/* Produce a core for the thread */
216
201
 
217
 
namespace drizzled
218
 
{
219
 
 
220
202
void write_core(int sig)
221
203
{
222
204
  signal(sig, SIG_DFL);
235
217
  sigsend(P_PID,P_MYID,sig);
236
218
#endif
237
219
}
238
 
 
239
 
} /* namespace drizzled */