OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """GDB support for Chrome types. | 5 """GDB support for Chrome types. |
6 | 6 |
7 Add this to your gdb by amending your ~/.gdbinit as follows: | 7 Add this to your gdb by amending your ~/.gdbinit as follows: |
8 python | 8 python |
9 import sys | 9 import sys |
10 sys.path.insert(0, "/path/to/tools/gdb/") | 10 sys.path.insert(0, "/path/to/tools/gdb/") |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 pp_set.add_printer('base::Time', '^base::Time$', TimePrinter) | 187 pp_set.add_printer('base::Time', '^base::Time$', TimePrinter) |
188 | 188 |
189 | 189 |
190 class IpcMessagePrinter(Printer): | 190 class IpcMessagePrinter(Printer): |
191 def header(self): | 191 def header(self): |
192 return self.val['header_'].cast( | 192 return self.val['header_'].cast( |
193 gdb.lookup_type('IPC::Message::Header').pointer()) | 193 gdb.lookup_type('IPC::Message::Header').pointer()) |
194 | 194 |
195 def to_string(self): | 195 def to_string(self): |
196 message_type = self.header()['type'] | 196 message_type = self.header()['type'] |
| 197 try: |
| 198 type = self.val.dynamic_type |
| 199 except: |
| 200 type = self.val.type |
197 return '%s of kind %s line %s' % ( | 201 return '%s of kind %s line %s' % ( |
198 self.val.dynamic_type, | 202 type, |
199 (message_type >> 16).cast(gdb.lookup_type('IPCMessageStart')), | 203 (message_type >> 16).cast(gdb.lookup_type('IPCMessageStart')), |
200 message_type & 0xffff) | 204 message_type & 0xffff) |
201 | 205 |
202 def children(self): | 206 def children(self): |
203 yield ('header_', self.header().dereference()) | 207 yield ('header_', self.header().dereference()) |
204 yield ('capacity_', self.val['capacity_']) | 208 yield ('capacity_', self.val['capacity_']) |
205 yield ('variable_buffer_offset_', self.val['variable_buffer_offset_']) | 209 yield ('variable_buffer_offset_', self.val['variable_buffer_offset_']) |
206 for field in self.val.type.fields(): | 210 for field in self.val.type.fields(): |
207 if field.is_base_class: | 211 if field.is_base_class: |
208 continue | 212 continue |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 yield ('sudden_termination_allowed_', | 292 yield ('sudden_termination_allowed_', |
289 self.val['sudden_termination_allowed_']) | 293 self.val['sudden_termination_allowed_']) |
290 yield ('ignore_input_events_', self.val['ignore_input_events_']) | 294 yield ('ignore_input_events_', self.val['ignore_input_events_']) |
291 yield ('is_guest_', self.val['is_guest_']) | 295 yield ('is_guest_', self.val['is_guest_']) |
292 pp_set.add_printer('content::RenderProcessHostImpl', | 296 pp_set.add_printer('content::RenderProcessHostImpl', |
293 '^content::RenderProcessHostImpl$', | 297 '^content::RenderProcessHostImpl$', |
294 RenderProcessHostImplPrinter) | 298 RenderProcessHostImplPrinter) |
295 | 299 |
296 | 300 |
297 gdb.printing.register_pretty_printer(gdb, pp_set, replace=_DEBUGGING) | 301 gdb.printing.register_pretty_printer(gdb, pp_set, replace=_DEBUGGING) |
OLD | NEW |