cuitao2046 / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

backtrace_symbols is in a separate library in FreeBSD #401

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.install FreeBSD 9.0
2.install devel/libexecinfo from ports
3.download gperftools and compile

What is the expected output? What do you see instead?
stacktrace_unittest can't be linked,because backtrace_symbols is in a separate 
library in FreeBSD,and we do not link it.
#ifdef HAVE_EXECINFO_H
  {
    char **strings = backtrace_symbols(stack, size);
    printf("Obtained %d stack frames.\n", size);
    for (int i = 0; i < size; i++)
      printf("%s %p\n", strings[i], stack[i]);
    printf("CheckStackTrace() addr: %p\n", &CheckStackTrace);
    free(strings);
  }
#endif

What version of the product are you using? On what operating system?
FreeBSD 9.0
FreeBSD test27.localdomain 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 
07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC 
 amd64

Please provide any additional information below.
So we should modify Makefile.am at the top source directory.
Test if we are in FreeBSD ,add  "-lexecinfo" to stacktrace_unittest_LDADD

Original issue reported on code.google.com by snnn119 on 2 Feb 2012 at 3:08

GoogleCodeExporter commented 9 years ago
I guess what's happening is that most freebsd users don't have libexecinfo 
installed via ports, so they HAVE_EXECINFO_H is false for them?  The test 
certainly compiles on my freebsd system.

} Test if we are in FreeBSD ,add  "-lexecinfo" to stacktrace_unittest_LDADD

Well, I think it would be 'test if -lexecinfo succeeds in linking, and add it 
to stacktrace_unittest_LDADD if so'.  Would you like to write up a patch?

Original comment by csilv...@gmail.com on 2 Feb 2012 at 7:01

GoogleCodeExporter commented 9 years ago
Just looking for an update here. If you do not have time to submit a patch 
could I trouble you to provide a proposal of what the patch is? I may be able 
to find someone to do the work :)

Original comment by chapp...@gmail.com on 2 Mar 2012 at 5:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi Chapp,I'm sorry I can not help you. I'm not familiar with autoconf checks, 
so please ask somebody else. :-( 

Original comment by me@sunchangming.com on 3 Mar 2012 at 3:55

GoogleCodeExporter commented 9 years ago
Looking it over, for optional functionality like this I think it's best to 
change the code in the test to use HAVE_BACKTRACE_SYMBOLS rather than 
HAVE_EXECINFO_H.  You can then just add a line in configure.ac using 
AC_CHECK_FUNCS.  You may need to pass in <execinfo.h> as an arg for 
AC_CHECK_FUNCS.

Original comment by csilv...@gmail.com on 6 Mar 2012 at 10:31

GoogleCodeExporter commented 9 years ago

Original comment by chapp...@gmail.com on 23 Dec 2012 at 3:19

GoogleCodeExporter commented 9 years ago
In NetBSD, backtrace() is in libexecinfo.
I've modified configure.ac to check for backtrace() in that library as well.
I think this will also improve the FreeBSD situation (if the execinfo package 
is already installed).

Original comment by tk@giga.or.at on 25 Feb 2014 at 8:43

Attachments:

GoogleCodeExporter commented 9 years ago
Merged Thomas' fix. Going to assume its fixing FreeBSD as well.

Please reopen if that's not the case.

Original comment by alkondratenko on 1 Mar 2014 at 7:35