我如何知道哪个函数或文件以及哪个行调用了函数?

时间:2015-10-21 15:11:36

标签: c++ c function

例如

@Projection(name = "virtual", types = { Person.class })
public interface VirtualProjection {

  @Value("#{target.firstName} #{target.lastName} ${id}") 
  String getFullName();

}

1 个答案:

答案 0 :(得分:0)

在Linux上,您可以使用backtrace转储堆栈:

   backtrace() returns a backtrace for the calling program, in the array
   pointed to by buffer.  A backtrace is the series of currently active
   function calls for the program.  Each item in the array pointed to by
   buffer is of type void *, and is the return address from the
   corresponding stack frame.  The size argument specifies the maximum
   number of addresses that can be stored in buffer.  If the backtrace
   is larger than size, then the addresses corresponding to the size
   most recent function calls are returned; to obtain the complete
   backtrace, make sure that buffer and size are large enough.