llvm.org GIT mirror llvm / 8c1cc23
Make the Twine pretty-printer work with GDB 7.11 Apparently ::NodeKind is sometimes part of the name in GDB. Without this patch I get the following error message from GDB: `Unhandled NodeKind llvm::Twine::NodeKind::EmptyKind`. Patch by Alexander Richardson! Differential Revision: https://reviews.llvm.org/D32795 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304675 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 2 years ago
1 changed file(s) with 22 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
225225
226226 return s
227227
228 def is_twine_kind(self, kind, expected):
229 if not kind.endswith(expected):
230 return False
231 # apparently some GDB versions add the NodeKind:: namespace
232 # (happens for me on GDB 7.11)
233 return kind in ('llvm::Twine::' + expected,
234 'llvm::Twine::NodeKind::' + expected)
235
228236 def string_from_child(self, child, kind):
229237 '''Return the string representation of the Twine::Child child.'''
230238
231 if kind in ('llvm::Twine::EmptyKind', 'llvm::Twine::NullKind'):
239 if self.is_twine_kind(kind, 'EmptyKind') or self.is_twine_kind(kind, 'NullKind'):
232240 return ''
233241
234 if kind == 'llvm::Twine::TwineKind':
242 if self.is_twine_kind(kind, 'TwineKind'):
235243 return self.string_from_twine_object(child['twine'].dereference())
236244
237 if kind == 'llvm::Twine::CStringKind':
245 if self.is_twine_kind(kind, 'CStringKind'):
238246 return child['cString'].string()
239247
240 if kind == 'llvm::Twine::StdStringKind':
248 if self.is_twine_kind(kind, 'StdStringKind'):
241249 val = child['stdString'].dereference()
242250 return self.string_from_pretty_printer_lookup(val)
243251
244 if kind == 'llvm::Twine::StringRefKind':
252 if self.is_twine_kind(kind, 'StringRefKind'):
245253 val = child['stringRef'].dereference()
246254 pp = StringRefPrinter(val)
247255 return pp.to_string()
248256
249 if kind == 'llvm::Twine::SmallStringKind':
257 if self.is_twine_kind(kind, 'SmallStringKind'):
250258 val = child['smallString'].dereference()
251259 pp = SmallStringPrinter(val)
252260 return pp.to_string()
253261
254 if kind == 'llvm::Twine::CharKind':
262 if self.is_twine_kind(kind, 'CharKind'):
255263 return chr(child['character'])
256264
257 if kind == 'llvm::Twine::DecUIKind':
265 if self.is_twine_kind(kind, 'DecUIKind'):
258266 return str(child['decUI'])
259267
260 if kind == 'llvm::Twine::DecIKind':
268 if self.is_twine_kind(kind, 'DecIKind'):
261269 return str(child['decI'])
262270
263 if kind == 'llvm::Twine::DecULKind':
271 if self.is_twine_kind(kind, 'DecULKind'):
264272 return str(child['decUL'].dereference())
265273
266 if kind == 'llvm::Twine::DecLKind':
274 if self.is_twine_kind(kind, 'DecLKind'):
267275 return str(child['decL'].dereference())
268276
269 if kind == 'llvm::Twine::DecULLKind':
277 if self.is_twine_kind(kind, 'DecULLKind'):
270278 return str(child['decULL'].dereference())
271279
272 if kind == 'llvm::Twine::DecLLKind':
280 if self.is_twine_kind(kind, 'DecLLKind'):
273281 return str(child['decLL'].dereference())
274282
275 if kind == 'llvm::Twine::UHexKind':
283 if self.is_twine_kind(kind, 'UHexKind'):
276284 val = child['uHex'].dereference()
277285 return hex(int(val))
278286