2

I have a function, say f(args), that is being called from many places in my code.

When args is undefined f() throws an exception.

I would like to identify who called f() with the undefined parameter.

What would be the easiest way to find the exact line (file name + line number) that called f() ?

Is that possible to see the caller in Firebug ?

Kara
  • 6,115
  • 16
  • 50
  • 57
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
  • 4
    possible duplicate of [Javascript how do you find the caller function?](http://stackoverflow.com/questions/280389/javascript-how-do-you-find-the-caller-function) – Daniel Vandersluis Sep 13 '10 at 14:53
  • 3
    Nope, not a duplicate. The OP specifically mentions Firebug, so this is about the execution environment, not the Javascript language. – Jason S Sep 13 '10 at 18:55

3 Answers3

6

yes. When you breakpoint it. In stack. between watch and breakpoints

Falcon
  • 1,461
  • 3
  • 15
  • 29
1

If you need this information without any tool, with a piece of code:

Check out this question

Also,

HERE's an example of writing a backtrace. You could use this for getting the whole trace. (for example if you need the caller of the caller)

Community
  • 1
  • 1
Máthé Endre-Botond
  • 4,826
  • 2
  • 29
  • 48
0

If you set a breakpoint in IE developer toolbar, when the breakpoint is hit, you can see the call stack from th script tab, then select the call stack tab on the right. you can click on each stage of the call stack to navigate and inspect all the callers, etc.

David
  • 2,785
  • 1
  • 16
  • 8