Click here to Skip to main content
15,885,027 members

__cyg_profile_func_enter segmentation error

steph Zagainov asked:

Open original thread
I want to get function's call stack of the programm with gcc option -finstrument-functions.

Typical code
C++
void __cyg_profile_func_enter (void *, void *) __attribute__((no_instrument_function));
void __cyg_profile_func_exit (void *, void *) __attribute__((no_instrument_function));
int depth = -1;

void __cyg_profile_func_enter (void *func,  void *caller)
{    }

void __cyg_profile_func_exit (void *func, void *caller)
{    }

int main()
{
printf("Hello world");
return 0
}

Compile it with gcc -finstrument-functions test.c

run ./a.out, and all ok.

But when I did it with g++ , I got undefined reference to __cyg_profile_func_enter function. I read that it happens because _cyg functions is part of C code and if I want to use them in C++ I should use extern "C", so there is final code.
C++
extern "C"{
void __cyg_profile_func_enter (void *, void *) __attribute__((no_instrument_function));
void __cyg_profile_func_exit (void *, void *) __attribute__((no_instrument_function));
int depth = -1;

void __cyg_profile_func_enter (void *func,  void *caller)
{    }

void __cyg_profile_func_exit (void *func, void *caller)
{    }
}
int main()
{
printf("Hello world");
return 0
}

It compiles with g++ -finstrument-functions test.c, then try to execute it but got Core dumped error message. I trace dump with gdb and there was Segmentation fault in __cyg_profile_func_enter().

GCC version is 2.95.4. I also tested it on 4.4.3 and all Ok. So are there any posibilities to walk around this problem using 2.95.4 gcc?
Tags: C++, C, Linux, GCC

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900