- Timestamp:
- 2019-11-29T22:27:25+13:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r33724 r33729 140 140 */ 141 141 static public void printCaller() { 142 int parent = 1;142 //int parent = 1; 143 143 // this function printCaller() itself adds another layer on the callstack since 144 144 // it calls the overloaded method, so need to add 1 more to parent 145 printCaller(parent++); 145 //printCaller(parent++); 146 147 StackTraceElement[] callstack = Thread.currentThread().getStackTrace(); 148 StackTraceElement requestor = callstack[2]; // the calling function, the function that called this one 149 if(callstack.length > 3) { 150 StackTraceElement caller_requested = callstack[3]; // the function requested 151 System.err.println("\n@@@ Function " + requestor + " called by:\n " 152 + caller_requested + " at 1 ancestors back\n"); 153 } else { 154 StackTraceElement caller_requested = callstack[callstack.length-1]; // the function requested 155 System.err.println("\n@@@ Don't have callers beyond requestor function " + requestor + "\n"); 156 } 146 157 } 147 158 … … 159 170 StackTraceElement[] callstack = Thread.currentThread().getStackTrace(); 160 171 StackTraceElement requestor = callstack[2]; // the calling function, the function that called this one 161 StackTraceElement caller_requested = callstack[ancestor+3]; // the function requested 162 System.err.println("@@@ Function " + requestor + " called by:\n " 163 + caller_requested + " at " + ancestor + " ancestors back"); 172 if(callstack.length > (ancestor+3)) { 173 StackTraceElement caller_requested = callstack[ancestor+3]; // the function requested 174 System.err.println("\n@@@ Function " + requestor + " called by:\n " 175 + caller_requested + " at " + ancestor + " ancestors back\n"); 176 } else { 177 StackTraceElement caller_requested = callstack[callstack.length-1]; // the function requested 178 System.err.println("\n@@@ Don't have " + ancestor + " ancestor callers. Function " + requestor + " called by:\n " 179 + caller_requested + " at max " + (callstack.length-1) + " ancestors back\n"); 180 } 164 181 } 165 182
Note:
See TracChangeset
for help on using the changeset viewer.