backtrace_test.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2009, 2013, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: backtrace_test.c,v 1.4 2009/09/02 23:48:01 tbox Exp $ */
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <isc/backtrace.h>
const char *expected_symbols[] = {
"func3",
"func2",
"func1",
"main"
};
static int
func3() {
void *tracebuf[16];
int i, nframes;
int error = 0;
const char *fname;
unsigned long offset;
if (result != ISC_R_SUCCESS) {
printf("isc_backtrace_gettrace failed: %s\n",
return (1);
}
if (nframes < 4)
error++;
for (i = 0; i < 4 && i < nframes; i++) {
if (result != ISC_R_SUCCESS) {
error++;
continue;
}
error++;
}
if (error) {
printf("Unexpected result:\n");
printf(" symbols:\n");
for (i = 0; i < nframes; i++) {
&offset);
if (result == ISC_R_SUCCESS)
else {
printf(" [%d] %p getsymbol failed: %s\n", i,
}
}
}
return (error);
}
static int
func2() {
return (func3());
}
static int
func1() {
return (func2());
}
int
main() {
return (func1());
}