Call stack

来自MudWiki

名称

   call_stack - 返回调用此函数的函数相关信息

语法

   string *call_stack(int default: 0);

描述

   If the int argument is 0, call_stack() returns an array of the names of the on the call stack, with the first one being the most recent (i.e. the currently running program).  If the int argument is 1, call_stack returns the objects in which that program is executing.  If it is 2, the name of the functions are returned.  If it is 3, the value of origin() in that frame is returned. If it is 4, the value will be the full file path and the line number.
   如果参数为0,call_stack()将返回一个包含调用栈中函数名称的数组,其中第一个函数是最近的(即当前正在运行的程序)。如果参数为1,则返回执行该程序的对象。如果为2,则返回函数的名称。如果为3,则返回该帧中origin()的值。如果为4,则返回完整的文件路径和行号。

示例

[728|728]eval return call_stack()
Result = ({ /* sizeof() == 3 */
  "/tmp/debug_eval_file.c",
  "/cmds/cmd/eval.c",
  "/inherit/living.c"
})
[728|728]eval return call_stack(0)
Result = ({ /* sizeof() == 3 */
  "/tmp/debug_eval_file.c",
  "/cmds/cmd/eval.c",
  "/inherit/living.c"
})
[728|728]eval return call_stack(1)
Result = ({ /* sizeof() == 3 */
  /tmp/debug_eval_file ("/tmp/debug_eval_file"),
  /cmds/cmd/eval ("/cmds/cmd/eval"),
  /inherit/user5#2 ("杨宇(test)")
})
[728|728]eval return call_stack(2)
Result = ({ /* sizeof() == 3 */
  "eval",
  "main",
  "command_hook"
})
[728|728]eval return call_stack(3)
Result = ({ /* sizeof() == 3 */
  "call_other",
  "call_other",
  "driver"
})
[728|728]eval return call_stack(4)
Result = ({ /* sizeof() == 3 */
  "/tmp/debug_eval_file.c:2",
  "/cmds/cmd/eval.c:23",
  "/inherit/living.c:56"
})
[728|728]eval return call_stack(5)
*First argument of call_stack() must be 0, 1, 2, 3, or 4.

参考

  dump_trace(3), all_previous_objects(3), previous_object(3), origin(3)