@@ -24,57 +24,10 @@ functions:
2424 the call of the function calling `Library.debug.traceback()`, and so on.
2525 See the code sample below for an example of sequential function calls.
2626
27- Note that this function will often return inaccurate results (compared to
28- the original source code) and that the format of the returned traceback
29- may change at any time. You should **not** parse the return value for
30- specific information such as script names or line numbers.
31-
32- The following example includes sequential function calls; `fnB()` is
33- called, and it calls `fnA()` which then calls `Library.debug.traceback()`.
34-
35- ```lua
36- local function fnA()
37- print(debug.traceback("Specific moment during fnA()"))
38- end
39-
40- local function fnB()
41- fnA()
42- end
43-
44- -- Call function fnB() to begin traceback
45- fnB()
46- ```
47- parameters :
48- - name : message
49- type : string
50- default : ' '
51- summary : |
52- The first line of the returned string.
53- - name : level
54- type : number
55- default : 1
56- summary : |
57- The number of calls "up" the call stack to return.
58- returns :
59- - type : string
60- summary : |
61- Traceback of the current function call stack.
62- tags :
63- code_samples :
64- - name : debug.traceback
65- summary : |
66- Returns a string of undefined format that describes the current function
67- call stack.
68- description : |
69- Returns a traceback of the current function call stack as a string; in
70- other words, a description of the functions that have been called up to
71- this point. During debugging, this behaves like an error stack trace but
72- does not stop execution of the script.
27+ This function can accept two variations in its parameters:
7328
74- The `level` parameter specifies what level of the call stack to consider,
75- with `1` being the call of `Library.debug.traceback()` itself, `2` being
76- the call of the function calling `Library.debug.traceback()`, and so on.
77- See the code sample below for an example of sequential function calls.
29+ - `debug.traceback(message, level)`
30+ - `debug.traceback(thread, message, level)` — Similar except the first parameter is a thread as returned by `Library.coroutine.create()`.
7831
7932 Note that this function will often return inaccurate results (compared to
8033 the original source code) and that the format of the returned traceback
@@ -98,10 +51,10 @@ functions:
9851 ```
9952 parameters :
10053 - name : thread
101- type : thread
54+ type : thread?
10255 default :
10356 summary : |
104- A thread as returned by `Library.coroutine.create()`.
57+ Optional thread as returned by `Library.coroutine.create()`.
10558 - name : message
10659 type : string
10760 default : ' '
@@ -129,91 +82,49 @@ functions:
12982 as well as for sending the data to systems expecting structured input,
13083 such as crash aggregation.
13184
132- ```lua
133- local function fnA()
134- -- Output source identifier ("s") and line ("l") at levels 1 and 2
135- print(debug.info(1, "sl")) --> fnA() 3
136- print(debug.info(2, "sl")) --> fnA() 7
137- end
85+ This function can accept three variations in its parameters:
13886
139- fnA()
140- ```
87+ - `debug.info(level, options)`
14188
142- ```lua
143- local function fnA()
89+ ```lua
90+ local function fnA()
91+ -- Output source identifier ("s") and line ("l") at levels 1 and 2
92+ print(debug.info(1, "sl")) --> fnA() 3
93+ print(debug.info(2, "sl")) --> fnA() 7
94+ end
14495
145- end
96+ fnA()
97+ ```
14698
147- local function fnB()
99+ - `debug.info(thread, level, options)` — Similar to above except the first parameter is a thread as returned by `Library.coroutine.create()`.
148100
149- end
101+ - `debug.info(function, options)`
150102
151- -- Output line ("l"), name ("n"), and identifier ("f") for both fnA() and fnB()
152- print(debug.info(fnA, "lnf")) --> 1 fnA function: 0x75e3d3c398a81252
153- print(debug.info(fnB, "lnf")) --> 5 fnB function: 0x6022a6dc5ccf4ab2
154- ```
103+ ```lua
104+ local function fnA()
105+ end
155106
156- Note that this function is similar to
157- [debug.getinfo](https://www.lua.org/pil/23.1.html), an unavailable part of
158- the standard Lua library which serves a similar purpose.
159- parameters :
160- - name : level
161- type : number
162- default :
163- summary : |
164- Determines at what level of the call stack the information returned
165- should describe. A value of `1` represents the function which is
166- calling `Library.debug.info()`, a value of `2` represents the function
167- that called that function, and so on.
168- - name : options
169- type : string
170- default :
171- summary : |
172- A string that describes what the returned information should
173- represent. It must only contain 0 or 1 instances of the characters
174- `slnaf`, each representing a piece of information:
107+ local function fnB()
108+ end
175109
176- - `s` ([string](/luau/strings.md)) — The function source identifier,
177- equal to the full name of the script the function is defined in.
178- - `l` ([number](/luau/numbers.md)) — The line number of the function
179- call represented by `level`.
180- - `n` ([string](/luau/strings.md)) — The name of the function; may be
181- `nil` for anonymous functions and C functions without an assigned
182- debug name.
183- - `a` ([number](/luau/numbers.md), [boolean](/luau/booleans.md)) —
184- Arity of the function, which refers to the parameter count and
185- whether the function is variadic.
186- - `f` ([function](/luau/functions.md)) — The function which was
187- inspected.
188- returns :
189- - type : Tuple
190- summary : ' '
191- tags :
192- code_samples :
193- - name : debug.info
194- summary : |
195- Traverses the entire stack of target thread and returns a string
196- containing the call stack of target level details.
197- description : |
198- Allows programmatic inspection of the call stack. This function differs
199- from `Library.debug.traceback()` in that it guarantees the format of the
200- data it returns. This is useful for general logging and filtering purposes
201- as well as for sending the data to systems expecting structured input,
202- such as crash aggregation.
203-
204-
205-
206- Note that this function is similar to
207- [debug.getinfo](https://www.lua.org/pil/23.1.html), an unavailable part of
208- the standard Lua library which serves a similar purpose.
110+ -- Output line ("l"), name ("n"), and identifier ("f") for both fnA() and fnB()
111+ print(debug.info(fnA, "lnf")) --> 1 fnA function: 0x75e3d3c398a81252
112+ print(debug.info(fnB, "lnf")) --> 5 fnB function: 0x6022a6dc5ccf4ab2
113+ ```
209114 parameters :
210115 - name : thread
211- type : thread
116+ type : thread?
212117 default :
213118 summary : |
214- A thread as returned by `Library.coroutine.create()`.
119+ Optional thread as returned by `Library.coroutine.create()`.
120+ - name : function
121+ type : function?
122+ default :
123+ summary : |
124+ The function of the call stack which the information returned should
125+ describe.
215126 - name : level
216- type : number
127+ type : number?
217128 default :
218129 summary : |
219130 Determines at what level of the call stack the information returned
0 commit comments