eclipse-linuxtools / org.eclipse.linuxtools

Eclipse plugins integrating Linux technologies - Docker, SystemTap, Kernel Perf, Valgrind, GGov, GProf, Vagrant, RPM, ...
Eclipse Public License 2.0
12 stars 17 forks source link

When checking the program's call relationships, there is an issue. #351

Open laomaolaile opened 5 months ago

laomaolaile commented 5 months ago

I have a gmon.out file generated by an assembly project. When I try to open it with gprof, I encounter an issue. When analyzing with gprof itself, the results I see appear correct. However, upon opening with gprof, I've noticed that the call relationships for a few functions are incorrect. Upon reviewing the code,

In gprof, when I inspect the data, observe the following:

image

When analyzing with the tool, notice the following:

image

I found that when these functions search for parent-child relationships in the elf file, the size of the parentSymbol they find is 0, and the program promptly returns. In reality, I would like to have the complete call relationships. Could you please advise on how to resolve this situation?

        IAddressFactory addressFactory = program.getAddressFactory();
        IAddress parentAddress = addressFactory.createAddress(Long.toString(from_pc));
        ISymbol parentSymbol = program.getSymbol(parentAddress);

        IAddress childAddress  = addressFactory.createAddress(Long.toString(self_pc));
        ISymbol childSymbol = program.getSymbol(childAddress);
        if (childSymbol == null || parentSymbol == null) {
            return;
        }
@Override
    public ISymbol getSymbol(IAddress addr) {
        ISymbol[] syms = getSymbols();
        int insertion = Arrays.binarySearch(syms, addr);
        if (insertion >= 0) {
            return syms[insertion];
        }
        if (insertion == -1) {
            return null;
        }
        insertion = -insertion - 1;
        ISymbol symbol = syms[insertion - 1];
        if (addr.compareTo(symbol.getAddress().add(symbol.getSize())) < 0) {
            return syms[insertion - 1];
        }
        return null;
    }
jjohnstn commented 3 months ago

Hi @laomaolaile without the gmon.out and elf file to look at, it is difficult to help. As you are aware, the symbol info is retrieved from CDT classes. I would suggest you debug the CDT code that loads the symbols and see if it is doing something wrong to set the size. Beyond that, you should debug the gprof tool code to see what it does with the symbols in question that are 0 length. Zero length represents unknown size. Perhaps, there is additional logic in gprof which calculates the size dynamically and that can be added to the CDT.