Y
Y
Yasuro2019-04-29 14:31:39
Java
Yasuro, 2019-04-29 14:31:39

How to view full call stack in idea?

Is there any way to get information about called methods in intellij idea?
If we put a break in some method, then we will see in the stack trace where it is called. Is there any way to see which methods were called on the way to the break?
Let's say the code is like this:

public static void main(String[] args) {
бла
бла
бла
бла

        testMethod();

        System.out.println("тут установили бряку");
    }

    private static void testMethod(){
        System.out.println("i am from testmethod");
    }

and I want to see in the stack trace that the testMethod method was called or it is not necessary to look at runtime, it can be logged somewhere.
I know visual studio has a call stack, but does idea have it?
p.s. why do you need it? if the project is large and you need to find out how the code works, what is called for what. There is no way to write something in the code, the project is large and not mine)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2019-04-29
@zagayevskiy

The stack (precisely the stack) of calls is in the Frames window of the debugger. But of course it won't show all the calls that were BEFORE the breakpoint. Will show only those that are higher in the call stack. If you set the breakpoint to "i am from testmethod" - it will show.

N
Narryel, 2019-06-18
@narryel

You can get an array of StackTraceElements and then iterate over them foreach
StackTraceElement[] ste= Thread.currentThread().getStackTrace();
for (StackTraceElement element : ste)
{
System.out.println(element.getMethodName()); // here you can display what you need
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question