Search code examples
c++ceclipseprofilingcall-graph

Eclipse CDT error while using Function Callgraph option of Profiling Tools


I'm getting the below error in Eclipse CDT while using Function Callgraph option of Profiling Tools

/tmp/org.eclipse.linuxtools.profiling.launch14272008124383356638983332386495.sh: 2: /tmp/org.eclipse.linuxtools.profiling.launch14272008124383356638983332386495.sh: Syntax error: Bad fd number

I googled this error. I found that the issue is with >&. An answer showed that the issue can be solved by replacing it with &>. But how to do that because eclipse creates the file??

Below is the sample C code on which i'm using profiling tools. But i have a huge code on which i'm facing the same issue.

/*
 ============================================================================
 Name        : hello.c
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>

void abc() {

}

int main(void) {
    puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
    abc();
    return EXIT_SUCCESS;
}

Below is the shell script that is mentioned in the error

#!/bin/sh
exec stap -c '/home/tejus/workspaces/testC/hello/Debug/hello' /home/tejus/workspaces/testC/.metadata/.plugins/org.eclipse.linuxtools.callgraph.core/callgraphGen.stp --runtime=dyninst /home/tejus/workspaces/testC/hello/Debug/hello >& /home/tejus/workspaces/testC/.metadata/.plugins/org.eclipse.linuxtools.callgraph.core/callgraph.out

I'm facing same issue in both C/C++ code.


Solution

  • This is probably because of the different styles in bash and sh. Try this: rename the old link of /bin/sh to bash and create new link of /bin/sh to bash.

    cd /bin
    sudo mv sh sh_orig
    sudo ln -s /bin/bash sh