1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3  Copyright (C) 2010 Philip Withnall <philip@tecnocode.co.uk>
4
5  GtkSourceView is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9
10  GtkSourceView is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  Lesser General Public License for more details.
14
15  You should have received a copy of the GNU Lesser General Public License
16  along with this library; if not, see <http://www.gnu.org/licenses/>.
17-->
18<language id="gdb-log" _name="GDB Log" version="2.0" _section="Other">
19  <metadata>
20    <property name="globs">*.gdb</property>
21  </metadata>
22
23  <styles>
24    <style id="thread-action" name="Thread Action" map-to="def:comment"/>
25    <style id="thread-header" name="Thread Header" map-to="def:statement"/>
26    <style id="frame-number" name="Frame Number" map-to="def:keyword"/>
27    <style id="address" name="Address" map-to="def:number"/>
28    <style id="function" name="Function" map-to="def:function"/>
29    <style id="string" name="String" map-to="def:string"/>
30    <style id="filename" name="Filename" map-to="def:statement"/>
31    <style id="optimized-out" name="Optimized Out" map-to="def:special-constant"/>
32    <style id="incomplete-sequence" name="Incomplete Sequence" map-to="def:special-constant"/>
33    <style id="prompt" name="Prompt" map-to="def:comment"/>
34  </styles>
35
36  <definitions>
37    <define-regex id="identifier">[A-Za-z_][A-Za-z0-9_]*(?:@@[A-Za-z0-9_\.]+)?</define-regex>
38    <define-regex id="filename">.+?</define-regex>
39
40    <!-- Either a decimal number (single to multi-digit, signed or unsigned) or a standard hexadecimal number -->
41    <define-regex id="thread-number">(?:-?[1-9][0-9]*|\%{def:hexadecimal})</define-regex>
42
43    <!-- Allow reuse of the frame regexes so we can use them in frame and crash-frame -->
44    <define-regex id="frame-start">((?P&lt;address&gt;\%{def:hexadecimal})\s+in\s+)?(?:(?P&lt;function&gt;\*?\%{identifier})|(?P&lt;badfunction&gt;\?\?))\s+\(</define-regex>
45    <define-regex id="frame-end">(?:(?:at|from)\s+(?P&lt;filename&gt;\%{filename})(?P&lt;linenumber&gt;\:[0-9]+)?|\))$</define-regex>
46
47    <context id="optimized-out" style-ref="optimized-out">
48      <keyword>value optimized out</keyword>
49    </context>
50
51    <context id="incomplete-sequence" style-ref="incomplete-sequence">
52      <keyword>incomplete sequence</keyword>
53    </context>
54
55    <context id="prompt" style-ref="prompt" end-at-line-end="true">
56      <start>\(gdb\)|---|Kill|Using|Program|Starting|No symbol</start>
57      <end>---$</end>
58    </context>
59
60    <context id="thread-action" style-ref="thread-action">
61      <!--[New Thread 0xb73ffb70 (LWP 26323)]
62          [Thread 0xb73ffb70 (LWP 26323) exited]
63          [Switching to Thread 0xb7fe6b70 (LWP 26322)]
64          [New LWP    1        ]-->
65      <match>^\[(?:New |Switching to )?(?:Thread|LWP)\s+(\%{thread-number})?.*\]$</match>
66      <include>
67        <context sub-pattern="1" style-ref="address"/>
68      </include>
69    </context>
70
71    <context id="thread-header" style-ref="thread-header">
72      <!--Thread 4 (Thread 0xb7fe6b70 (LWP 26322)):
73          Thread 10 (LWP    40        ):-->
74      <match>^Thread \d+ \((?:Thread|LWP)\s+(\%{thread-number}).*\):$</match>
75      <include>
76        <context sub-pattern="1" style-ref="address"/>
77      </include>
78    </context>
79
80    <context id="signal-handler-frame">
81      <!--#3  <signal handler called>-->
82      <match>^#(\d+)\s+&lt;(signal handler called)&gt;$</match>
83      <include>
84        <context sub-pattern="1" style-ref="frame-number"/>
85        <context sub-pattern="2" style-ref="def:special-constant"/>
86      </include>
87    </context>
88
89    <context id="crash-frame" end-at-line-end="false" once-only="true">
90      <!--This occurs once only, at the top of the file:
91          0x00110402 in __kernel_vsyscall ()-->
92      <start>^\%{frame-start}</start>
93      <end>\%{frame-end}</end>
94      <include>
95        <context where="start" sub-pattern="address" style-ref="address"/>
96        <context where="start" sub-pattern="function" style-ref="function"/>
97        <context where="start" sub-pattern="badfunction" style-ref="def:error"/>
98        <context where="end" sub-pattern="filename" style-ref="filename"/>
99        <context where="end" sub-pattern="linenumber" style-ref="def:number"/>
100        <context ref="optimized-out"/>
101        <context ref="incomplete-sequence"/>
102        <context ref="prompt"/>
103      </include>
104    </context>
105
106    <context id="frame" end-at-line-end="false">
107      <!--#0  0x0054d422 in __kernel_vsyscall ()
108          #1  0x005002d2 in pthread_cond_timedwait@@GLIBC_2.3.2 ()
109              at ../nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:179
110          #2  0x0043e9f4 in __pthread_cond_timedwait (cond=0xb6401678, mutex=0x88e5e58,
111              abstime=0xb63ff1e8) at forward.c:152
112          #-1 0xfc59f649 in __lwp_park () from /lib/libc.so.1-->
113      <start>^#(?P&lt;framenumber&gt;-?\d+)\s+\%{frame-start}</start>
114      <end>\%{frame-end}</end>
115      <include>
116        <context where="start" sub-pattern="framenumber" style-ref="frame-number"/>
117        <context where="start" sub-pattern="address" style-ref="address"/>
118        <context where="start" sub-pattern="function" style-ref="function"/>
119        <context where="start" sub-pattern="badfunction" style-ref="def:error"/>
120        <context where="end" sub-pattern="filename" style-ref="filename"/>
121        <context where="end" sub-pattern="linenumber" style-ref="def:number"/>
122        <context ref="optimized-out"/>
123        <context ref="incomplete-sequence"/>
124        <context ref="prompt"/>
125      </include>
126    </context>
127
128    <!-- Necessary because some frames put their filename on the next line, after their closing bracket, and since we want to match
129         frames which have no filename (i.e. just a closing bracket) as well as normal frames, we have to deal with this odd case. -->
130    <context id="frame-ending">
131      <!--    at ../nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:179-->
132      <match>^\s+(?:at|from)\s+(?P&lt;filename&gt;\%{filename})(?P&lt;linenumber&gt;\:[0-9]+)?$</match>
133      <include>
134        <context sub-pattern="filename" style-ref="filename"/>
135        <context sub-pattern="linenumber" style-ref="def:number"/>
136      </include>
137    </context>
138
139    <context id="gdb-log">
140      <include>
141        <context ref="prompt"/>
142        <context ref="thread-action"/>
143        <context ref="thread-header"/>
144        <context ref="signal-handler-frame"/>
145        <context ref="crash-frame"/>
146        <context ref="frame"/>
147        <context ref="frame-ending"/>
148      </include>
149    </context>
150  </definitions>
151</language>
152