OLD | NEW |
1 # Copyright (C) 2008-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2008-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 3 # This program is free software; you can redistribute it and/or modify |
4 # it under the terms of the GNU General Public License as published by | 4 # it under the terms of the GNU General Public License as published by |
5 # the Free Software Foundation; either version 3 of the License, or | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 def __init__(self, val): | 168 def __init__(self, val): |
169 self.val = val | 169 self.val = val |
170 | 170 |
171 def to_string(self): | 171 def to_string(self): |
172 return 'hint_error_val' | 172 return 'hint_error_val' |
173 | 173 |
174 def display_hint (self): | 174 def display_hint (self): |
175 raise Exception("hint failed") | 175 raise Exception("hint failed") |
176 | 176 |
| 177 class pp_children_as_list: |
| 178 "Throw error from display_hint" |
| 179 |
| 180 def __init__(self, val): |
| 181 self.val = val |
| 182 |
| 183 def to_string(self): |
| 184 return 'children_as_list_val' |
| 185 |
| 186 def children (self): |
| 187 return [('one', 1)] |
| 188 |
177 class pp_outer: | 189 class pp_outer: |
178 "Print struct outer" | 190 "Print struct outer" |
179 | 191 |
180 def __init__ (self, val): | 192 def __init__ (self, val): |
181 self.val = val | 193 self.val = val |
182 | 194 |
183 def to_string (self): | 195 def to_string (self): |
184 return "x = %s" % self.val['x'] | 196 return "x = %s" % self.val['x'] |
185 | 197 |
186 def children (self): | 198 def children (self): |
187 yield 's', self.val['s'] | 199 yield 's', self.val['s'] |
188 yield 'x', self.val['x'] | 200 yield 'x', self.val['x'] |
189 | 201 |
190 class MemoryErrorString: | 202 class MemoryErrorString: |
191 "Raise an error" | 203 "Raise an error" |
192 | 204 |
193 def __init__(self, val): | 205 def __init__(self, val): |
194 self.val = val | 206 self.val = val |
195 | 207 |
196 def to_string(self): | 208 def to_string(self): |
197 raise gdb.MemoryError ("Cannot access memory."); | 209 raise gdb.MemoryError ("Cannot access memory."); |
198 | 210 |
199 def display_hint (self): | 211 def display_hint (self): |
200 return 'string' | 212 return 'string' |
201 | 213 |
| 214 class pp_eval_type: |
| 215 def __init__(self, val): |
| 216 self.val = val |
| 217 |
| 218 def to_string(self): |
| 219 gdb.execute("bt", to_string=True) |
| 220 return "eval=<" + str(gdb.parse_and_eval("eval_func (123456789, 2, 3, 4,
5, 6, 7, 8)")) + ">" |
| 221 |
202 def lookup_function (val): | 222 def lookup_function (val): |
203 "Look-up and return a pretty-printer that can print val." | 223 "Look-up and return a pretty-printer that can print val." |
204 | 224 |
205 # Get the type. | 225 # Get the type. |
206 type = val.type | 226 type = val.type |
207 | 227 |
208 # If it points to a reference, get the reference. | 228 # If it points to a reference, get the reference. |
209 if type.code == gdb.TYPE_CODE_REF: | 229 if type.code == gdb.TYPE_CODE_REF: |
210 type = type.target () | 230 type = type.target () |
211 | 231 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 287 |
268 pretty_printers_dict[re.compile ('^struct lazystring$')] = pp_ls | 288 pretty_printers_dict[re.compile ('^struct lazystring$')] = pp_ls |
269 pretty_printers_dict[re.compile ('^lazystring$')] = pp_ls | 289 pretty_printers_dict[re.compile ('^lazystring$')] = pp_ls |
270 | 290 |
271 pretty_printers_dict[re.compile ('^struct outerstruct$')] = pp_outer | 291 pretty_printers_dict[re.compile ('^struct outerstruct$')] = pp_outer |
272 pretty_printers_dict[re.compile ('^outerstruct$')] = pp_outer | 292 pretty_printers_dict[re.compile ('^outerstruct$')] = pp_outer |
273 | 293 |
274 pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error | 294 pretty_printers_dict[re.compile ('^struct hint_error$')] = pp_hint_error |
275 pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error | 295 pretty_printers_dict[re.compile ('^hint_error$')] = pp_hint_error |
276 | 296 |
| 297 pretty_printers_dict[re.compile ('^struct children_as_list$')] = pp_childre
n_as_list |
| 298 pretty_printers_dict[re.compile ('^children_as_list$')] = pp_children_as_li
st |
| 299 |
277 pretty_printers_dict[re.compile ('^memory_error$')] = MemoryErrorString | 300 pretty_printers_dict[re.compile ('^memory_error$')] = MemoryErrorString |
278 | 301 |
| 302 pretty_printers_dict[re.compile ('^eval_type_s$')] = pp_eval_type |
| 303 |
279 pretty_printers_dict = {} | 304 pretty_printers_dict = {} |
280 | 305 |
281 register_pretty_printers () | 306 register_pretty_printers () |
282 gdb.pretty_printers.append (lookup_function) | 307 gdb.pretty_printers.append (lookup_function) |
OLD | NEW |