Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2292)

Unified Diff: experimental/visual_studio_plugin/src/NaClVsx.Package/DebugSupport/DWARF/DwarfReaderImpl.cs

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: experimental/visual_studio_plugin/src/NaClVsx.Package/DebugSupport/DWARF/DwarfReaderImpl.cs
diff --git a/experimental/visual_studio_plugin/src/NaClVsx.Package/DebugSupport/DWARF/DwarfReaderImpl.cs b/experimental/visual_studio_plugin/src/NaClVsx.Package/DebugSupport/DWARF/DwarfReaderImpl.cs
deleted file mode 100644
index 44f777674d7ac37363a8d052c394874dd0124121..0000000000000000000000000000000000000000
--- a/experimental/visual_studio_plugin/src/NaClVsx.Package/DebugSupport/DWARF/DwarfReaderImpl.cs
+++ /dev/null
@@ -1,292 +0,0 @@
-// Copyright (c) 2011 The Native Client Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#region
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using NaClVsx;
-
-#endregion
-
-namespace Google.NaClVsx.DebugSupport.DWARF {
- /// <summary>
- /// The interface implemented by this class lives in
- /// NaClVsx.DebugHelpers/DwarfParser.h
- /// </summary>
- class DwarfReaderImpl : IDwarfReader {
- public DwarfReaderImpl(SymbolDatabase db) {
- db_ = db;
- }
-
- #region Implementation of IDwarfReader
-
- public void StartCompilationUnit() {
- // File and directory ids are unique only within a compilation unit.
- dirs_.Clear();
- compilationUnitIndex_++;
- }
-
- public void EndCompilationUnit() {}
-
- public void StartDIE(ulong parent, ulong offset, DwarfTag tag) {
- var entry =
- new DebugInfoEntry {
- Key = offset,
- OuterScope = scopeStack_.PeekOrDefault(),
- ParentKey = parent,
- Tag = tag
- };
-
- db_.Entries[offset] = entry;
- }
-
- public void EndDIE(ulong offset) {
- var entry = db_.Entries[offset];
-
- // If this DIE is a scope, it should at this point be at the top of the
- // scope stack.
- if (scopeStack_.PeekOrDefault() == entry) {
- scopeStack_.Pop();
-
- // Add a transition back to the parent scope. This may get overwritten
- // if a sibling scope starts where this one ends, but that's cool.
- //
- // Note: we can only do this if the scope has a high pc value. Labels
- // don't.
- object highpc;
- if (entry.Attributes.TryGetValue(
- DwarfAttribute.DW_AT_high_pc, out highpc)) {
- if (db_.ScopeTransitions.ContainsKey((ulong) highpc)) {
- // This can happen if a parent and child scope end on the same pc
- // value. The parent wins, so overwrite the previous entry.
- db_.ScopeTransitions[(ulong) highpc].Entry = entry.OuterScope;
- } else {
- db_.ScopeTransitions.Add(
- (ulong) highpc,
- new SymbolDatabase.ScopeTransition {
- Address = (ulong) highpc,
- Entry = entry.OuterScope
- });
- }
- }
- }
- }
-
- public void ProcessAttribute(ulong offset,
- ulong parent,
- DwarfAttribute attr,
- object data) {
- var entry = db_.Entries[offset];
-
- var key = attributeIndex_++;
- db_.Attributes.Add(
- key,
- new SymbolDatabase.DebugInfoAttribute {
- Key = key,
- ParentKey = parent,
- Tag = attr,
- Value = data
- });
- entry.Attributes.Add(attr, data);
-
-
- // If we have a PC range, it's time to make a new scope
- if (attr == DwarfAttribute.DW_AT_low_pc) {
- var addr = (ulong) data;
-
- // Add a scope transition for this entry.
- // Replace any existing scope transition at the point where
- // this entry starts. Existing transitions are expected--it
- // just means that this entry starts where its sibling ends.
- if (db_.ScopeTransitions.ContainsKey(addr)) {
- db_.ScopeTransitions[addr].Entry = entry;
- } else {
- db_.ScopeTransitions.Add(
- addr,
- new SymbolDatabase.ScopeTransition {
- Address = addr,
- Entry = entry
- });
- }
- // This entry may already be on the scope track if it has low_pc and
- // ranges.
- if (scopeStack_.PeekOrDefault() != entry) {
- scopeStack_.Push(db_.Entries[parent]);
- }
- } else if (attr == DwarfAttribute.DW_AT_ranges) {
- // We can't make the scope transition because ranges are parsed on a
- // different code path, so we'll handle it during a post-processing
- // step.
- // This entry may already be on the scope track if it has low_pc as
- // well as ranges.
- if (scopeStack_.PeekOrDefault() != entry) {
- scopeStack_.Push(db_.Entries[parent]);
- }
- }
- }
-
- public void DefineDir(string name, uint dirNum) {
- try {
- dirs_[dirNum] = name;
- }
- catch (Exception e) {
- Debug.WriteLine(e.Message);
- }
- }
-
- public void DefineFile(string name,
- int fileNum,
- uint dirNum) {
- var key = MakeFileKey((uint) fileNum);
- string relpath;
- if (!dirs_.TryGetValue(dirNum, out relpath)) {
- relpath = "";
- }
- db_.Files.Add(
- key,
- new SymbolDatabase.SourceFile {
- Key = key,
- Filename = name,
- RelativePath = relpath,
- CurrentAbsolutePath = name
- });
- }
-
- public void AddLine(ulong address,
- ulong length,
- uint fileNum,
- uint lineNum,
- uint columnNum) {
- //
- // There are several cases in the C++ standard library where a line entry
- // has zero length. This appears to happen when a line of code is
- // elided for whatever reason. The problem is that the address might be
- // perfectly valid for a different line of code, which would lead to
- // duplicate entries in our location table. So if length is zero, bail.
- //
- if (length == 0) {
- return;
- }
-
- //
- // Add the address and location to our locations table.
- //
- try {
- var
- sourceLocation = new SymbolDatabase.SourceLocation {
- StartAddress = address,
- Length = length,
- SourceFileKey = MakeFileKey(fileNum),
- Line = lineNum,
- Column = columnNum,
- };
-
- db_.Locations.Add(address, sourceLocation);
- }
- catch (Exception e) {
- Debug.WriteLine(e.Message);
- }
- }
-
- public void AddLocListEntry(ulong offset,
- bool isFirstEntry,
- ulong lowPc,
- ulong highPc,
- byte[] data) {
- if (isFirstEntry) {
- currentLocList_ = offset;
- db_.LocLists.Add(offset, new List<SymbolDatabase.LocListEntry>());
- }
- var list = db_.LocLists[currentLocList_];
- list.Add(
- new SymbolDatabase.LocListEntry {
- StartAddress = lowPc,
- EndAddress = highPc,
- Data = data
- });
- }
-
- public bool BeginCfiEntry(ulong address) {
- currentFrame_ = new SymbolDatabase.CallFrame {Address = address};
- return true;
- }
-
- public bool AddCfiRule(ulong address,
- int reg,
- IDwarfReader.CfiRuleType ruleType,
- int baseRegister,
- int offset,
- byte[] expression) {
- currentFrame_.Rules.Add(
- new SymbolDatabase.CallFrame.Rule {
- Address = address,
- BaseRegister = baseRegister,
- Expression = expression,
- Offset = offset,
- RegisterId = reg,
- RuleType = ruleType
- });
- return true;
- }
-
- public bool EndCfiEntry() {
- if (currentFrame_ == null) {
- throw new DwarfParseException("Mismatched begin/end CFI entries");
- }
- db_.CallFrames.Add(currentFrame_.Address, currentFrame_);
-
- currentFrame_ = null;
- return true;
- }
-
- public void AddRangeListEntry(ulong offset,
- ulong baseAddress,
- ulong lowPC,
- ulong highPC) {
- if (lowPC != highPC) {
- if (!db_.RangeLists.ContainsKey(offset)) {
- db_.RangeLists.Add(offset, new Dictionary<ulong, RangeListEntry>());
- }
- if (!db_.RangeLists[offset].ContainsKey(lowPC)) {
- var entry = new RangeListEntry {
- Offset = offset,
- BaseAddress = baseAddress,
- LowPC = lowPC,
- HighPC = highPC
- };
- db_.RangeLists[offset].Add(lowPC, entry);
- }
- }
- }
-
- private ulong MakeFileKey(uint fileNum) {
- return ((ulong) compilationUnitIndex_ << 32) | fileNum;
- }
-
- #endregion
-
- #region Private Implementation
-
- private readonly SymbolDatabase db_;
-
- private readonly Dictionary<uint, string> dirs_ =
- new Dictionary<uint, string>();
-
- private readonly Stack<DebugInfoEntry> scopeStack_ =
- new Stack<DebugInfoEntry>();
-
- private ulong attributeIndex_;
- private ushort compilationUnitIndex_;
- private SymbolDatabase.CallFrame currentFrame_;
- private ulong currentLocList_;
-
- #endregion
- }
-
- internal class DwarfParseException : Exception {
- public DwarfParseException(string msg) : base(msg) {}
- }
-}

Powered by Google App Engine
This is Rietveld 408576698