mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-23 03:53:43 +01:00
Print normal output only if "verbose" mode is requested.
(Logical change 1.104)
This commit is contained in:
parent
27c3d57b90
commit
587bba5c1f
1 changed files with 8 additions and 4 deletions
|
@ -32,7 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
#include <libunwind.h>
|
#include <libunwind.h>
|
||||||
|
|
||||||
int errors;
|
int verbose, errors;
|
||||||
|
|
||||||
#define panic(args...) \
|
#define panic(args...) \
|
||||||
{ ++errors; fprintf (stderr, args); return; }
|
{ ++errors; fprintf (stderr, args); return; }
|
||||||
|
@ -64,6 +64,7 @@ backtrace (void)
|
||||||
if (unw_get_proc_name (&cursor, name, sizeof (name), &offset) == 0
|
if (unw_get_proc_name (&cursor, name, sizeof (name), &offset) == 0
|
||||||
&& off > 0)
|
&& off > 0)
|
||||||
snprintf (off, sizeof (off), "+0x%lx", (long) offset);
|
snprintf (off, sizeof (off), "+0x%lx", (long) offset);
|
||||||
|
if (verbose)
|
||||||
printf (" [%lx] <%s%s>\n", (long) ip, name, off);
|
printf (" [%lx] <%s%s>\n", (long) ip, name, off);
|
||||||
if (++count > 32)
|
if (++count > 32)
|
||||||
panic ("FAILURE: didn't reach beginning of unwind-chain\n");
|
panic ("FAILURE: didn't reach beginning of unwind-chain\n");
|
||||||
|
@ -83,6 +84,7 @@ b (void)
|
||||||
static void
|
static void
|
||||||
a (void)
|
a (void)
|
||||||
{
|
{
|
||||||
|
if (verbose)
|
||||||
printf ("backtrace() from atexit()-handler:\n");
|
printf ("backtrace() from atexit()-handler:\n");
|
||||||
b();
|
b();
|
||||||
if (errors)
|
if (errors)
|
||||||
|
@ -91,6 +93,7 @@ a (void)
|
||||||
|
|
||||||
Test_Class::Test_Class (void)
|
Test_Class::Test_Class (void)
|
||||||
{
|
{
|
||||||
|
if (verbose)
|
||||||
printf ("backtrace() from constructor:\n");
|
printf ("backtrace() from constructor:\n");
|
||||||
b();
|
b();
|
||||||
}
|
}
|
||||||
|
@ -98,5 +101,6 @@ Test_Class::Test_Class (void)
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
verbose = argc > 1;
|
||||||
return atexit (a);
|
return atexit (a);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue