OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #region | |
6 | |
7 using System.Collections.Generic; | |
8 using System.Windows.Forms; | |
9 using Google.NaClVsx.DebugSupport.DWARF; | |
10 using NaClVsx; | |
11 | |
12 #endregion | |
13 | |
14 namespace SymbolDBViewer { | |
15 /// <summary> | |
16 /// Extends DictionaryLoader with some functionality that comes in handy for | |
17 /// loaders that have to parse DIE entries. | |
18 /// </summary> | |
19 /// <typeparam name = "TEntryType">The dictionary entry type to be parsed. | |
20 /// </typeparam> | |
21 public class DIECapableLoader<TEntryType> : DictionaryLoader<TEntryType> { | |
22 /// <summary> | |
23 /// Builds a TreeNode representation of a DIE's Attributes. This | |
24 /// function lives in the base class because it is used multiple times. | |
25 /// </summary> | |
26 /// <param name = "attributes">The attributes to depict.</param> | |
27 /// <returns>The new TreeNode.</returns> | |
28 protected static TreeNode GetDIEAttributesNode( | |
29 Dictionary<DwarfAttribute, object> attributes) { | |
30 var attributesNode = new TreeNode("Attributes"); | |
31 if (attributes != null) { | |
32 foreach (var attribute in attributes) { | |
33 var name = GetString(attribute.Key); | |
34 var value = GetString(attribute.Value); | |
35 attributesNode.Nodes.Add(name, string.Format("{0}: {1}", name, value))
; | |
36 } | |
37 } | |
38 return attributesNode; | |
39 } | |
40 | |
41 /// <summary> | |
42 /// Builds a TreeNode representation of a DIE's values. This function | |
43 /// lives in the base class because it is used multiple times. | |
44 /// </summary> | |
45 /// <param name = "entry">The DIE whose values to depict.</param> | |
46 /// <returns>A new TreeNode</returns> | |
47 protected static TreeNode GetDIEValuesNode(DebugInfoEntry entry) { | |
48 var valuesNode = new TreeNode("null"); | |
49 if (entry != null) { | |
50 var valuesString = string.Format( | |
51 "Values: Key: {0} Outer Scope: {1} Parent: {2} Tag: {3}", | |
52 entry.Key, | |
53 entry.OuterScope, | |
54 entry.ParentKey, | |
55 entry.Tag); | |
56 valuesNode.Name = valuesString; | |
57 valuesNode.Text = valuesString; | |
58 } | |
59 return valuesNode; | |
60 } | |
61 } | |
62 } | |
OLD | NEW |