Skip to content

Commit

Permalink
TS-41003 Add executable Bummer
Browse files Browse the repository at this point in the history
  • Loading branch information
snowbagoly committed Dec 12, 2024
1 parent 19c98cb commit 843e596
Show file tree
Hide file tree
Showing 30 changed files with 218 additions and 7 deletions.
6 changes: 6 additions & 0 deletions BummerExe/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
66 changes: 66 additions & 0 deletions BummerExe/BummerExe.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{19C457D5-6780-4480-94CB-ED7E055402B8}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Bummer</RootNamespace>
<AssemblyName>Bummer</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentCommandLineParser, Version=1.4.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FluentCommandLineParser.1.4.3\lib\net35\FluentCommandLineParser.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BummerLib\BummerLib.csproj">
<Project>{721fdfc9-6da9-4159-a54e-e448dfb9097d}</Project>
<Name>BummerLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
113 changes: 113 additions & 0 deletions BummerExe/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//------------------------------------------------------------------------------
// <copyright company="CQSE GmbH">
// Copyright (c) CQSE GmbH
// </copyright>
// <license>
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </license>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using Fclp;
using Newtonsoft.Json;
using System.Linq;

namespace Cqse.ConQAT.Dotnet.Bummer
{
/// <summary>
/// Entry point class to the binary-source mapper.
/// </summary>
internal class Program
{

/// <summary>
/// The entry point of the program, where the program control
/// starts and ends.
/// </summary>
/// <param name="args">The command-line arguments.</param>
public static int Main(string[] args)
{
var commandLineParser = new FluentCommandLineParser();

var filenames = new List<string>();
var assemblyNames = new List<string>();

commandLineParser.Setup<List<string>>('f', "files")
.Callback(items => filenames = items)
.WithDescription("Path(s) to symbol file(s) that should be analyzed.")
.Required();
commandLineParser.Setup<List<string>>('a', "assemblyNames")
.Callback(items => assemblyNames = items)
.WithDescription("Assembly name(s) to be used in the AssemblyMethodMapping(s). Must have the same order and number of elements as the files parameter.")
.Required();

commandLineParser.SetupHelp("?", "help")
.Callback(text => Console.WriteLine(text));

var commandLineParseResult = commandLineParser.Parse(args);

if (!filenames.Count.Equals(assemblyNames.Count))
{
Console.WriteLine("The parameters <files> and <assemblyNames> had different lengths. Aborting analysis.");
return -1;
}
if (!commandLineParseResult.HasErrors)
{
List<AssemblyMethodMappings> methodMappings = GetMethodMappings(filenames, assemblyNames);
OutputMethodMappings(methodMappings);
}
else
{
Console.WriteLine(commandLineParseResult.ErrorText);
commandLineParser.HelpOption.ShowHelp(commandLineParser.Options);
}
return 0;
}

/// <summary>
/// Gets the method mappings for the specified list of file names.
/// </summary>
/// <param name="filenames">The list of symbol filenames to analyze.</param>
private static List<AssemblyMethodMappings> GetMethodMappings(List<string> filenames, List<string> assemblyNames)
{
var methodMappings = new List<AssemblyMethodMappings>();
var methodMapper = new MethodMapper();
// TODO (FS) please don't use 1-letter variable names

Check warning on line 87 in BummerExe/Program.cs

View check run for this annotation

cqse.teamscale.io / teamscale-findings

BummerExe/Program.cs#L87

[New] TODO (FS) please don't use 1-letter variable names https://cqse.teamscale.io/findings/details/teamscale-net-profiler?t=ts%2F41003_move_bummer_to_profiler%3AHEAD&id=AF55AF9ACBF4F175C1718C3A00F2C90F
foreach (var pair in filenames.Zip(assemblyNames, (f, s) => new { filename = f, assemblyName = s }))
{
if (!File.Exists(pair.filename))
{
Console.WriteLine("File does not exist: " + pair.filename);
continue;
}

methodMappings.Add(methodMapper.GetMethodMappings(pair.filename, pair.assemblyName));
}
return methodMappings;
}

/// <summary>
/// Prints the specified list of method mappings on the console as JSON.
/// </summary>
/// <param name="methodMappings">The method mappings to save.</param>
private static void OutputMethodMappings(List<AssemblyMethodMappings> methodMappings)
{
var settings = new JsonSerializerSettings();
settings.Formatting = Formatting.None;
var serializer = JsonSerializer.Create(settings);
serializer.Serialize(Console.Out, methodMappings);
}
}
}
7 changes: 7 additions & 0 deletions BummerExe/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.Reflection;

[assembly: AssemblyTitle("Bummer")]
[assembly: AssemblyProduct("Bummer")]
[assembly: AssemblyCompany("CQSE GmbH")]
[assembly: AssemblyCopyright("Copyright © CQSE GmbH")]
[assembly: AssemblyDescription("Creates mappings between binary and source file methods based on .pdb or .mdb symbol files.")]
5 changes: 5 additions & 0 deletions BummerExe/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentCommandLineParser" version="1.4.3" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
</packages>
File renamed without changes.
2 changes: 1 addition & 1 deletion Bummer/Bummer.csproj → BummerLib/BummerLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Bummer</RootNamespace>
<AssemblyName>Bummer</AssemblyName>
<AssemblyName>BummerLib</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
<Content Include="TestData\UnusedLibraryRenamedInVersion8.pdb" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bummer\Bummer.csproj">
<ProjectReference Include="..\BummerLib\BummerLib.csproj">
<Project>{721fdfc9-6da9-4159-a54e-e448dfb9097d}</Project>
<Name>Bummer</Name>
<Name>BummerLib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 16 additions & 2 deletions Cqse.Teamscale.Profiler.Dotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DumpPdb", "DumpPdb\DumpPdb.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample_Debugging_App", "Sample_Debugging_App\Sample_Debugging_App.csproj", "{084AB86B-40EA-40B1-9B30-43D2619DEF21}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bummer", "Bummer\Bummer.csproj", "{721FDFC9-6DA9-4159-A54E-E448DFB9097D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BummerLib", "BummerLib\BummerLib.csproj", "{721FDFC9-6DA9-4159-A54E-E448DFB9097D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bummer_Test", "Bummer_Test\Bummer_Test.csproj", "{DD23760A-176C-4151-9E71-7F3642FFFACE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BummerLib_Test", "BummerLib_Test\BummerLib_Test.csproj", "{DD23760A-176C-4151-9E71-7F3642FFFACE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BummerExe", "BummerExe\BummerExe.csproj", "{19C457D5-6780-4480-94CB-ED7E055402B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -143,6 +145,18 @@ Global
{DD23760A-176C-4151-9E71-7F3642FFFACE}.Release|Win32.Build.0 = Release|Any CPU
{DD23760A-176C-4151-9E71-7F3642FFFACE}.Release|x64.ActiveCfg = Release|Any CPU
{DD23760A-176C-4151-9E71-7F3642FFFACE}.Release|x64.Build.0 = Release|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Debug|Win32.ActiveCfg = Debug|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Debug|Win32.Build.0 = Debug|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Debug|x64.ActiveCfg = Debug|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Debug|x64.Build.0 = Debug|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Release|Any CPU.Build.0 = Release|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Release|Win32.ActiveCfg = Release|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Release|Win32.Build.0 = Release|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Release|x64.ActiveCfg = Release|Any CPU
{19C457D5-6780-4480-94CB-ED7E055402B8}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions DumpPdb/DumpPdb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bummer\Bummer.csproj">
<ProjectReference Include="..\BummerLib\BummerLib.csproj">
<Project>{721fdfc9-6da9-4159-a54e-e448dfb9097d}</Project>
<Name>Bummer</Name>
<Name>BummerLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down

0 comments on commit 843e596

Please sign in to comment.