我正在尝试2分析cpp代码。我使用-pg标志进行编译,在对其进行分析以获得输出后,我得到了一些非常奇怪的函数名。这是我正在使用的make文件:
# Makefile for parallel simulated annealer
PREFIX=${PARSECDIR}/pkgs/kernels/canneal/inst/${PARSECPLAT}
TARGET=canneal
LIBS:=$(LIBS) -lm
CXXFLAGS+=-pg
ifdef version
ifeq "$(version)" "pthreads"
CXXFLAGS+=-DENABLE_THREADS -pthread
endif
endif
all:
$(CXX) $(CXXFLAGS) annealer_thread.cpp -c -o annealer_thread.o
$(CXX) $(CXXFLAGS) rng.cpp -c -o rng.o
$(CXX) $(CXXFLAGS) netlist.cpp -c -o netlist.o
$(CXX) $(CXXFLAGS) main.cpp -c -o main.o
$(CXX) $(CXXFLAGS) netlist_elem.cpp -c -o netlist_elem.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) *.o $(LIBS) -o $(TARGET)
clean:
rm -f *.o $(TARGET)
install:
mkdir -p $(PREFIX)/bin
cp -f $(TARGET) $(PREFIX)/bin/$(TARGET)以下是gprof输出的示例:
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
11.21 0.73 0.73 2800002 0.00 0.00 std::_Rb_tree<std::string, std::pair<std::string const, netlist_elem*>, std::_Select1st<std::pair<std::string const, netlist_elem*> >, std::less<std::string>, std::allocator<std::pair<std::string const, netlist_elem*> > >::_M_lower_bound(std::_Rb_tree_node<std::pair<std::string const, netlist_elem*> >*, std::_Rb_tree_node<std::pair<std::string const, netlist_elem*> >*, std::string const&)
10.45 1.41 0.68 5856992 0.00 0.00 atomic_load_acq_int(unsigned int volatile*)
8.76 1.98 0.57 400001 0.00 0.00 netlist_elem::routing_cost_given_loc(location_t)以下是文件中的真实函数名:
void annealer_thread::Run()有没有我忘了的旗帜?为什么概要分析还会显示函数的参数?是因为它们是类吗?是因为它是cpp吗?我熟悉gprof和c,但这是我第一次接触cpp。
欢迎任何帮助:) cheers=)
发布于 2011-01-26 00:24:24
在C++中,函数名包括它们所属的类、它们的返回类型以及它们的所有参数类型。这是通过“破坏”名字来实现的。这是因为函数可以用不同的参数类型重载。gprof意识到了这一点,并可以消除它们。
您在平面配置文件中看到的是,PC通常在一些类库例程中被捕获。只有当它为您提供了在那些例程中结束的代码中的调用路径是什么的线索时,这才是有用的。调用图(插装)在这方面提供了一些帮助。
当然,它对您不希望执行的任何I/O都是视而不见的。程序可能会花费99%的时间在库中执行I/O,而您并不知道它正在发生,gprof也不知道。
看看Zoom吧。
https://stackoverflow.com/questions/4793665
复制相似问题