Debugging shared library

Sysprogs forums Forums VisualGDB Debugging shared library

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #9120
    sidprice
    Participant

    I am using VisualGDB to build an application and a shared library from VS2015. The build server is a Linux computer and the target device is an ARM board. Before adding the shared library I was able to build the application on the build server and debug it on my target hardware, all worked very well.

    Now, I need to move some of the code from my application to begin developing a shared library. I added a new VisualGDB project and configured it to build in the same way.

    I added a reference to my application for the library project but when I try to rebuild the solution I get an error from g++ saying “TSN_NIC.so: file not recognized: File format not recognized”.

    I guess the error is because it is trying to statically link to the library. (.so)

    My question is how can I setup the build so that I can build this solution and then debug the class library using the application

    Thanks,

    Sid

    #9123
    support
    Keymaster

    Hi,

    Our best guess is that the library is built using a different compiler (e.g. using native g++ instead of a cross-compiler for your ARM board). You can check that by running “readelf -h <file>” for the main application and the .so file. If the “Machine” field is mismatching, please double-check the compiler you are using.

    #9129
    sidprice
    Participant

    Thank you, that was the issue. A simple newbie mistake, I had not configured my remote cross compiler correctly. Now my small test works great and I have debugger access to the shared library.

    Love this product!

    Sid

    #9131
    sidprice
    Participant

    I have one more issue with my shared library project, it appears that CLang Intellisense is not working correctly. My code compiles and runs fine but CLang Intellisense reports errors on things in the std namespace. For example:

    std::ifstream inputFile;

    inputFile.open(“theFile”) ;

    There is a red mark under the dot between inputFile and open and the tooltip says “std::fstream (aka int) is not a structure or union”

    I have checked the Intellisense directories in my library project and they look the same the main application which does not have this problem.

    Is there something special I need to add for a library?

    Sid

    #9138
    support
    Keymaster

    Hi,

    First of all, please try VisualGDB 5.2 Beta 1. We have resolved a lot of IntelliSense-related issues there. If the problem occurs there as well, please check if it reports any missing header files and use the automatic header discovery feature to locate them.

    #9142
    sidprice
    Participant

    I have downloaded and installed 5.2 Beta 1 and I have the same problem. However now CLang reports that it cannot find file “gnu\stubs-soft.h”. I have no idea what this header is for. Would that prevent the correct intellisense for such things as “fstream” and “string”?

    Severity Code Description Project File Line Suppression State
    Error [Clang IntelliSense] Error: member reference base type ‘std::ifstream’ (aka ‘int’) is not a structure or union TSN_NIC c:\dataroot\projects\tsn\tsn_nic\TSN_NIC.cpp 28
    Error [Clang IntelliSense] Error: member reference base type ‘std::ifstream’ (aka ‘int’) is not a structure or union TSN_NIC c:\dataroot\projects\tsn\tsn_nic\TSN_NIC.cpp 33
    Error [Clang IntelliSense] Error: member reference base type ‘std::ifstream’ (aka ‘int’) is not a structure or union TSN_NIC c:\dataroot\projects\tsn\tsn_nic\TSN_NIC.cpp 35
    Error [Clang IntelliSense] Error: member reference base type ‘string’ (aka ‘int’) is not a structure or union TSN_NIC c:\dataroot\projects\tsn\tsn_nic\TSN_NIC.cpp 38
    Error [Clang IntelliSense] Error: ‘string’ (aka ‘int’) is not a class, namespace, or enumeration TSN_NIC c:\dataroot\projects\tsn\tsn_nic\TSN_NIC.cpp 38

    Plus, there is a new warning for a simple stream operation “inputFile >> inputLine”, it says:

    Severity Code Description Project File Line Suppression State
    Warning [Clang IntelliSense] Warning: expression result unused TSN_NIC c:\dataroot\projects\tsn\tsn_nic\TSN_NIC.cpp 37

    Sid

    #9146
    support
    Keymaster

    Hi,

    Yes, the missing file can easily declare some functions or types related to the ifstream and break IntelliSense for it. Please try clicking at the error to see which file includes the file.

    Perhaps your compiler inserts some implicit preprocessor macro that VisualGDB does not catch, i.e.:

    #ifdef SOMEMACRO
    #include <somefile.h>
    #else
    #include <gnu/stubs.h>
    #endif

    So the compiler includes <somefile.h> and succeeds, but IntelliSense tries to include gnu/stubs.h and fails. Searching your target include directories for stubs.h and checking the code around the relevant #include<> statement should help clarify this.

    • This reply was modified 8 years, 2 months ago by support.
    #9149
    sidprice
    Participant

    I do not think the “stubs-soft.h” is the issue, that file is missing from my system, however “stubs-hard.h” is there and it does not include other fiels nor does it have anything to do with fstream, string, or any of the other errors. CLang reports that “string” is not a class!

    Don’t forget that the main application in the solution has the same intellisense directories and works just fine.

    Sid

    #9151
    support
    Keymaster

    Sorry about that, it may be a bug of the Clang IntelliSense. If it reports that ‘string’ is not a class, please try including <string> explicitly and checking if it still complains about it. If yes, please copy the definition of the ‘string’ class from the <string> file to the source file and check if it ignores it again or complains about another missing class.

    Alternatively if you could reproduce it on a small separate example (it should include your toolchain’s include directories) and send it to us, we could investigate it on our side.

    #9164
    sidprice
    Participant

    I tried to implicitly include “string”:

    #include <string>

    This made no difference, so I copied the definition of ‘string’ from ‘stringfwd.h’:

    typedef basic_string<char>    string;

    This stopped Clang saying ‘string’ is not a class but there is no intellisense for the members of the string class, I assume because ‘basic_string’ remains unknown to Clang.

    What is odd here is that the same Intellisense settings in the main application work, it is only in the class library project that CLang fails, maybe that is a clue!

    I can send you this small library project, however the target OS is Yocto, so I am not sure fi it would help you.

    Sid

    #9177
    support
    Keymaster

    Hi,

    Sending a repro project should be the easiest. Are you using a Windows cross-toolchain or compiling on the Linux side?

    In case of a cross-toolchain we will also need the toolchain archive; in case of Linux compilation we will need a snapshot of %LOCALAPPDATA%\RemoteSourceCache\<machine> in order to reproduce this.

    #9189
    sidprice
    Participant

    Should I send this data to support @ sysprogs.com ??

    Sid

    #9193
    support
    Keymaster

    Hi,

    Yes, that should do. Please upload the files to a file hosting service like dropbox, as our ticket system has an attachment size limit.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.