~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/stacktrace.cc

  • Committer: Brian Aker
  • Date: 2009-08-21 18:46:31 UTC
  • mto: This revision was merged to the branch mainline in revision 1123.
  • Revision ID: brian@gaz-20090821184631-e11gja79070fvhk4
Cleanup around page checksum removal

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 "drizzled/global.h"
20
21
#include "stacktrace.h"
21
22
 
22
23
#include <signal.h>
30
31
#include <execinfo.h>
31
32
#endif
32
33
 
 
34
#include <algorithm>
 
35
 
 
36
using namespace std;
 
37
 
33
38
#define PTR_SANE(p) ((p) && (char*)(p) >= heap_start && (char*)(p) <= heap_end)
34
39
 
35
40
char *heap_start;
118
123
#endif
119
124
 
120
125
 
121
 
void  print_stacktrace(unsigned char* stack_bottom, ulong thread_stack)
 
126
void  print_stacktrace(unsigned char* stack_bottom, size_t thread_stack)
122
127
{
123
128
#if HAVE_BACKTRACE
124
129
  backtrace_current_thread();
146
151
 
147
152
  if (!stack_bottom || (unsigned char*) stack_bottom > (unsigned char*) &fp)
148
153
  {
149
 
    ulong tmp= cmin(0x10000,thread_stack);
 
154
    ulong tmp= min((size_t)0x10000,thread_stack);
150
155
    /* Assume that the stack starts at the previous even 65K */
151
156
    stack_bottom= (unsigned char*) (((ulong) &fp + tmp) &
152
157
                          ~(ulong) 0xFFFF);
156
161
      fp < (unsigned char**) stack_bottom - thread_stack)
157
162
  {
158
163
    fprintf(stderr, "Bogus stack limit or frame pointer,\
159
 
 fp=%p, stack_bottom=%p, thread_stack=%ld, aborting backtrace.\n",
160
 
            (void *)fp, (void *)stack_bottom, thread_stack);
 
164
 fp=%p, stack_bottom=%p, thread_stack=%"PRIu64", aborting backtrace.\n",
 
165
            (void *)fp, (void *)stack_bottom, (uint64_t)thread_stack);
161
166
    return;
162
167
  }
163
168