When modifying your own format strings, it is useful
to start with the default values for the frame and
thread format strings. These can be accessed with the
"settings show"
command:
(lldb)
settings show thread-format
thread-format (string) = 'thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{, stop reason = ${thread.stop-reason}}{, name = ${thread.name}}{, queue = ${thread.queue}}\n'
(lldb) settings show frame-format
frame-format (string) = 'frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n'
When making thread formats, you will need surround any
of the information that comes from a stack frame with scopes ({ frame-content })
as the thread format doesn't always want to show frame information.
When displaying the backtrace for a thread, we don't need to duplicate
the information for frame zero in the thread information:
(lldb) thread backtrace
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1 2.1
frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19
frame #1: 0x0000000100000e40 a.out`start + 52
The frame related variables are:
${file.*}
${frame.*}
${function.*}
${line.*}
${module.*}
Looking at the default format for the thread, and underlining
the frame information:
'thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{, stop reason = ${thread.stop-reason}}{, name = ${thread.name}}{, queue = ${thread.queue}}\n'
We can see that all frame information is contained in scopes so
that when the thread information is displayed in a context where
we only want to show thread information, we can do so.