Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
laomaolaile opened this issue Mar 28, 2024 · 1 comment
Open

Comments

@laomaolaile
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants