DotPeek PDB generation for assemblies without debug directory - debugging

I'm attempting to use JetBrains dotPeek 1.4 symbol server however I've encountered some 3rd party assemblies that fail, with dotPeek status of:
Pdb has not been generated because assembly does not contain debug directory
Using CFF Explorer I've discovered that these assemblies have empty "Debug Directory" Portable Executable (PE) header values.
Is there an (easy) way to edit the PE to add Debug Directory header values?

de4dot creates invalid .net executable module in the eyes of dotPeek. It's problem of dotPeek, not de4dot, however. But since we do not have sources of dotPeek we ought to modify de4dot instead to achieve interoperability.
Modify: de4dot.code/AssemblyModule.cs module adding
writerOptions.WritePdb = true;
module.CreatePdbState();
to de4dot.code.AssemblyModule.Save function and you fill have valid pdb function in exe module.
To save your time you can use de4dot project with my patch: https://github.com/earnol/de4dot/commit/24c6e696fb9251f7d048ac33c88c710013a649d6
It will add debug directory to the output executable. Just delete resulting PDB and run dotPeek again. It will work flawlessly.
Use something like: de4dot.exe -f filein.exe -o fileout.exe -fpdb

Related

ProGet symbols and source server: download pdb correctly but source not found

I have a problem reguarding the source files and symbols using ProGet and VS2017/VS2019.
My scenario is the following
Develop test assembly on my pc
Push mod files on our git server
Get mod files in our TeamCity (2019.1)
Build source in Release mode, pack and publish the AssemblyTest.symbols.nupkg on ProGet (5.2.3)
In VS2017 I've create a test console app, install the AssemblyTest via Package Reference and I've tried simply to press F12 on the class in my code to show the source code or step in in debug mode.
I've configure VS2017 as the guide suggests here
The nuget pack command was launched with -symbols command line parameter and the symbol.nupkg was created with the following stucture
package
service
metadata
...
lib
net472
TestAssembly.dll
TestAssembly.pdb
TestAssembly.xml
src
Properties
AssemblyInfo.cs
TestClass.cs
Pressing F12 on TestClass in my code the pdb was correctly downloaded in
c:\users\me\appdata\local\temp\symbolcache\testassembly.pdb\bf5be5cd155e4400b9b18c0e1e6a05941\testassembly.pdb
and selecting ReSharper item form the drop down list on the output window in Visual Studio I see
PdbNavigator: Downloader: http://srv.symbolsource.org/pdb/Public/testassembly.pdb/bf5be5cd155e4400b9b18c0e1e6a05941/testassembly.pdb -> The remote server returned an error: (500) Internal Server Error.
--OK, it's MS symbol server
PdbNavigator: Downloader: http://myproget/symbols/dev/testassembly.pdb/bf5be5cd155e4400b9b18c0e1e6a05941/testassembly.pdb -> ok, 15.5 KB
-- OK, it's our ProGet server
PdbNavigator: Searching for 'TestAssembly.TestClass' type sources in C:\Users\me\AppData\Local\Temp\SymbolCache\TestAssembly.pdb\bf5be5cd155e4400b9b18c0e1e6a05941\TestAssembly.pdb
PdbNavigator: Downloader: http://myproget/source-files/dev/TestAssembly/1.0.0.10/TestClass.cs -> The remote server returned an error: (404) Not Found.
-- Here we come :(
PdbNavigator: No sources found in debugging information for 'TestAssembly.TestClass' in assembly 'TestAssembly, Version=1.0.0.10, Culture=neutral, PublicKeyToken=null'
In my symbolcache folder there is a subfolder with this path
C:\Users\me\AppData\Local\Temp\SymbolCache\src\source-files\dev\TestAssembly\1.0.0.10
but there's no source file instead.
Taking a look inside the pdb file and I've found
SRCSRV: ini ------------------------------------------------
VERSION=2
INDEXVERSION=2
VERCTRL=http
SRCSRV: variables ------------------------------------------
SRCSRVVERCTRL=http
PGSERVER=http://myproget/source-files
PGFEED=dev
PGPKGID=TestAssembly
PGPKGVER=1.0.0.10
HTTP_EXTRACT_TARGET=%pgserver%/%pgfeed%/%pgpkgid%/%pgpkgver%/%var2%
SRCSRVTRG=%http_extract_target%
SRCSRVCMD=
SRCSRV: source files ---------------------------------------
c:\buildagent\work\b5cfc05c815c43d9\testassembly\testclass.cs*TestClass.cs
SRCSRV: end ------------------------------------------------
So, my question is: how can I download correctly the source file from ProGet?
What's wrong in my scenario?
Thank you!
Fabrizio
From ProGet's perspective, a 404 is returned by the /source-files/* endpoint in any of the following cases:
the feed name (i.e. dev in your example) is not found
the feed is not a NuGet feed
the symbol server is not enabled for the feed
the package version is missing from the /source-files URL
the package version is not a valid NuGet version (1.0.0.10 looks OK)
the file itself (i.e. TestClass.cs in your example) is not found under the /src folder within the package
That being said, can you verify in the feed itself that those source files are present using the Files tab for version 1.0.0.10 of this package? I know if the normal, non-symbols package is pushed after the symbols one, it can overwrite it which effectively removes those files.

A matching symbol file was not found (Cannot find/open pdb file)

The debug point is not getting enabled when this module gets loaded. So I thought of manually loading its debug symbols .pdb file from "Debug/obj" folder.
In this case I am getting below error "A matching symbol" file was not found in this folder though that folder contains currently build file.
And also the "Symbol Load Information" contains these many directory paths.
Cannot find or open the PDB file.
PDB does not match
Screenshot:
This problem is fixed by the following steps-
1) Close all the instances of VISUAL STUDIO if running and open a single instance of Visual Studio
2) Close the solution (nothing but your project) If it's already open and then re-open again
3) Clean the whole project and rebuild it.
4) and also build the project if you are getting any errors like "___.dll not found"
5) Now you are good to go and run your project
After breaking my head on this, for me it happened when I configured my project to seperate binaries from objects that way:
For Output directory:
$(SolutionDir)build\bin\$(PlatformTarget)-$(Configuration)\
For Intermediate Directory:
$(SolutionDir)build\obj\$(PlatformTarget)-$(Configuration)\$(ProjectName)\
Even though the I still had the generated .pdb where my exe or trying to even load it manually, it didn't work.
So I went again to Configuration Properties -> Linker -> Debugging and where the property Generate Program Database File I changed from $(OutDir)$(TargetName).pdb to $(IntDir)$(TargetName).pdb so it will throw the desired database file into the place where the objects(Intermediate Directory) are instead of where the .exe(Output directory). Hopefully that helped someone :)

.lib file not working in visula studio 2010 C++

My client provide me a dll file without any lib file for the project, so I create a lib file from this link.
Now after successfully generating a lib file I follow the answer of this link
Now after following these two links, I simply build my code in which I have not define any thing till now.My code build successfully, but when I build my code after calling a function from my lib file I got this:-
error C3861: 'upgStop': identifier not found
where upgStop is the function that I call.
It seems something went wrong while linking the lib file. So, guys please tell the exact solution of this problem.
'Identifier not found' is a compiler error (not linker error) which implies the header file which specifies upgStop() hasn't been #included in the file from which the function is being called.
Do you have a header file which contains the declaration/prototype of ugpStop()?
Once this is resolved, you may have linker errors isntead - as you either need to link against the dll/lib, or load it dynamically using "LoadLibrary()" (and then find functions within the loaded library by their string name.

Removing all symbols from EXE file with Visual Studio

I'm linking an executable file with several static libraries (projects in my solution), and want to remove all internal function names from the final .exe file.
Which settings do I have to use for that, and do I have to do that in the library or executable project settings?
Simply building in Release mode doesn't strip the names out of the binary.
Go to Project -> Properties -> Configuration properties -> Linker and in the Debugging section set Generate Debug Info to "No".
Remove them using hex editor, they aren't used inside a code

How to handle "Cannot find or open the PDB file" at VS 2010?

I am trying to debug a project, that has libs files, libs files and exe files, If I run this project without debugging it compiles well and execute well.
But its debugging doesn’t work, It says : [Cannot find or open the PDB file]
* tvctrlpt.exe is the name of exe on which I am working now.
Seems I am making mistakes in project build debugger settings ?
Do I need to consider anything specific on this ?
[for your information – I am doing the windows debugging for following : http://sourceforge.net/projects/pupnp/forums/forum/569833/topic/5409226]
See below log:
tvctrlpt.exe': Loaded 'D:\libupnp\build\vc10\out.vc10.Win32\Debug\bin\tvctrlpt.exe', Cannot find or open the PDB file
EDIT
Here I am using the http://pupnp.sourceforge.net/ [ libupnp 1.6.17] , it compile well, and run as usual, but while running the debugger - it says - Cannot find or open the PDB file.
searched all across internet, and tried all the ways for various settings, but it didn't work, seems it require little more deep knowledge to do that.
Or some settings etc..

Resources