Skip to content

Commit ec1f779

Browse files
committed
Allow non-code symbol, fix sort
1 parent 86f5af0 commit ec1f779

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

EatPdb/EatPdb.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
6-
<Version>0.0.2</Version>
6+
<Version>0.0.3</Version>
77
<Authors>CodeHz</Authors>
88
<Company>CodeHz</Company>
99
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>

EatPdb/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ private static bool FilterName(string name) {
4646
return false;
4747
if (name.StartsWith("??@"))
4848
return false;
49+
if (name.StartsWith("?$TSS"))
50+
return false;
4951
if (name.Contains("std@@Q"))
5052
return false;
5153
if (name.Contains("std@@U"))
@@ -71,7 +73,7 @@ private static void RealMain(Options options) {
7173
var symdb = new SymbolDatabase();
7274

7375
// Collect all symbols
74-
foreach (var item in pdb.PublicSymbols.Where(item => item.IsCode && FilterName(item.Name)))
76+
foreach (var item in pdb.PublicSymbols.Where(item => FilterName(item.Name)))
7577
symdb.Add((uint) item.RelativeVirtualAddress, item.Name);
7678

7779
// Exclude imported symbols

EatPdb/SymbolDatabase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Diagnostics.CodeAnalysis;
45
using System.Linq;
56

67
namespace EatPdb {
78

89
internal class SymbolDatabase : IEnumerable<KeyValuePair<uint, SortedSet<string>>> {
910
private readonly SortedDictionary<uint, SortedSet<string>> fullmap = new SortedDictionary<uint, SortedSet<string>>();
10-
private readonly SortedDictionary<string, uint> revmap = new SortedDictionary<string, uint>();
11+
private readonly SortedDictionary<string, uint> revmap = new SortedDictionary<string, uint>(StringComparer.Ordinal);
1112

1213
public void Add(uint RVA, string name) {
1314
if (fullmap.TryGetValue(RVA, out var set))
@@ -35,7 +36,7 @@ public KeyValuePair<string, ushort>[] Build() {
3536
ushort idx = 0;
3637
foreach (var (key, _) in fullmap)
3738
tempid.Add(key, idx++);
38-
var ret = new SortedDictionary<string, ushort>();
39+
var ret = new SortedDictionary<string, ushort>(StringComparer.Ordinal);
3940
foreach (var (name, rva) in revmap) {
4041
if (tempid.TryGetValue(rva, out var id)) {
4142
ret.Add(name, id);

PdbReader/PdbReader.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<NeutralLanguage>English (United States)</NeutralLanguage>
7-
<Version>0.0.1</Version>
7+
<Version>0.0.2</Version>
88
<Authors>CodeHz</Authors>
99
<Product>EatPdb</Product>
1010
<Copyright>CodeHz</Copyright>

PdbReader/Program.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,17 @@ private static void RealMain(Options options) {
3535
try {
3636
using var reader = new PdbFileReader(options.InputFile);
3737
if (options.Verbose)
38-
foreach (var item in from item in reader.PublicSymbols where item.IsCode && !item.Name.StartsWith("_") orderby item.RelativeVirtualAddress select item)
38+
foreach (var item in from item in reader.PublicSymbols where !item.Name.StartsWith("_") orderby item.RelativeVirtualAddress select item)
3939
Console.WriteLine("{0}:{1:X8} {2}", item.Segment, item.RelativeVirtualAddress, options.Demangle ? item.GetUndecoratedName() : item.Name);
4040
else {
41-
var items = from item in reader.PublicSymbols
42-
where item.IsCode && !item.Name.StartsWith("_")
41+
var syms = from item in reader.PublicSymbols
42+
where !item.Name.StartsWith("_")
4343
select item;
44-
Console.WriteLine("FullCount: {0}", items.Count());
45-
Console.WriteLine("DistinctCount: {0}", items.Distinct(new SymbolEqualityComparer()).Count());
44+
Console.WriteLine("Symbol FullCount: {0}", syms.Count());
45+
Console.WriteLine("Symbol DistinctCount: {0}", syms.Distinct(new SymbolEqualityComparer()).Count());
46+
47+
var functions = reader.Functions;
48+
Console.WriteLine("Functions FullCount: {0}", functions.Count());
4649
}
4750
} catch (Exception e) {
4851
Console.WriteLine(e.ToString());

0 commit comments

Comments
 (0)