Discussion:
Modifying the pdb file to match with the modified assembly
Gábor Kozár
2011-03-28 14:24:36 UTC
Permalink
Hey guys,

I'm writing a tiny little post compiler, which simply makes some basic
transformations based on the attributes of the user code elements.
Now the assembly is modified correctly, and produces the expected result
when run, however, I would like to be able to debug the assembly as well.

VS says that "The breakpoint will not currently be hit. No symbols have been
loaded for this document." when trying to place a breakpoint into the source
code - I take it as an indicating of the debugger realizing that the
assembly has been modified and the symbol file has been not.

As far as I know Mono.Cecil is capable of altering symbol files. Could
somebody point me into the right direction with this? I have absolutely no
knowledge regarding the symbol files, or how the VS debugger works.
Any help would be greatly appreciated!

Thank you!
--
--
mono-cecil
Jb Evain
2011-03-28 14:31:03 UTC
Permalink
Hi,
Post by Gábor Kozár
As far as I know Mono.Cecil is capable of altering symbol files. Could
somebody point me into the right direction with this?
https://github.com/jbevain/cecil/wiki/Debug-symbols

Jb
--
--
mono-cecil
Gábor Kozár
2011-03-28 14:54:38 UTC
Permalink
I've tried that, but the result is the same. I mean, literally: getting no
pdb file generated, even though I've set both the ReadSymbols and
WriteSymbols properties, and I have Mono.Cecil.Mdb.dll referenced. The
output .exe is written fine, but no pdb. I get no errors or exceptions.

My corresponding lines are exactly the same as on your wiki. Any hints?
Post by Jb Evain
Hi,
Post by Gábor Kozár
As far as I know Mono.Cecil is capable of altering symbol files. Could
somebody point me into the right direction with this?
https://github.com/jbevain/cecil/wiki/Debug-symbols
Jb
--
--
mono-cecil
--
--
mono-cecil
Jb Evain
2011-03-28 15:33:24 UTC
Permalink
Post by Gábor Kozár
My corresponding lines are exactly the same as on your wiki. Any hints?
Yes, you probably don't have Mono.Cecil.Pdb.dll deployed with Mono.Cecil.dll

Jb
--
--
mono-cecil
Gábor Kozár
2011-03-28 15:35:10 UTC
Permalink
Oh, nevermind that last, I'm just dumb. I missed the part that
Mono.Cecil.Pdb will be tried to be used under Windows, and Mono.Cecil just
apparently failed silently when I didn't have dll referenced. Really should
cause an exception!

Thanks for your help! Works perfectly now!

(Haha, just received your e-mail telling the same. Thanks for coping with
stupid users like myself. :))
Post by Gábor Kozár
I've tried that, but the result is the same. I mean, literally: getting no
pdb file generated, even though I've set both the ReadSymbols and
WriteSymbols properties, and I have Mono.Cecil.Mdb.dll referenced. The
output .exe is written fine, but no pdb. I get no errors or exceptions.
My corresponding lines are exactly the same as on your wiki. Any hints?
Post by Jb Evain
Hi,
Post by Gábor Kozár
As far as I know Mono.Cecil is capable of altering symbol files. Could
somebody point me into the right direction with this?
https://github.com/jbevain/cecil/wiki/Debug-symbols
Jb
--
--
mono-cecil
--
--
mono-cecil
Xiao Qu
2012-07-27 13:42:53 UTC
Permalink
"modifying the pdb file to match with the modified assembly" is exactly
what I am looking for. I tried the solution in the given link and I was
able to create a matched pair of assembly and pdb (checked by a tool called
"chkmatch").

However, I have some "follow-up" problems:

1. I did nothing in the "make required changes" section (as shown in the
code snippet below) --- in other words, I just read the assembly and write
it back without making any change to the assembly. But, the new pdb file is
smaller than the original one (though the size of modified assembly doesn't
change). What is missing inside of the new pdb?

var readerParameters = new ReaderParameters { ReadSymbols = true };
var assemblyDefinition = AssemblyDefinition.ReadAssembly (fileName,
readerParameters);

// make required changes.

var writerParameters = new WriterParameters { WriteSymbols = true };
assemblyDefinition.Write (outputFile, writerParameters);

2. I tried to collect coverage information by running a test suite on the
new assembly along with the new pdb, in a test project of VS2010 (MSTest),
but I failed to add the new assembly when I set up the test configuration.
The error message is "Cannot obtain the symbols information for the binary
... Please ensure that both the binary and the symbols files are
accessible."... I doubt this was caused by the first problem I had.

Could anyone help on this?

Thanks in advance!
Post by Gábor Kozár
Oh, nevermind that last, I'm just dumb. I missed the part that
Mono.Cecil.Pdb will be tried to be used under Windows, and Mono.Cecil just
apparently failed silently when I didn't have dll referenced. Really should
cause an exception!
Thanks for your help! Works perfectly now!
(Haha, just received your e-mail telling the same. Thanks for coping with
stupid users like myself. :))
Post by Gábor Kozár
I've tried that, but the result is the same. I mean, literally: getting
no pdb file generated, even though I've set both the ReadSymbols and
WriteSymbols properties, and I have Mono.Cecil.Mdb.dll referenced. The
output .exe is written fine, but no pdb. I get no errors or exceptions.
My corresponding lines are exactly the same as on your wiki. Any hints?
Post by Jb Evain
Hi,
Post by Gábor Kozár
As far as I know Mono.Cecil is capable of altering symbol files. Could
somebody point me into the right direction with this?
https://github.com/jbevain/cecil/wiki/Debug-symbols
Jb
--
--
mono-cecil
--
--
mono-cecil
Xiao Qu
2012-07-27 16:10:19 UTC
Permalink
"modifying the pdb file to match with the modified assembly" is exactly
what I am looking for. I tried the solution in the given link and I was
able to create a matched pair of assembly and pdb file (checked by a tool
called "chkmatch").

However, I have some "follow-up" problems:

First, I did nothing in the "make required changes" section (as shown in
the following code snippet) --- in other words, I just read the assembly
and write it back without making any change to it. But the new pdb file is
smaller than the original one (although the size of modified assembly does
not change). What is missing inside?

var readerParameters = new ReaderParameters { ReadSymbols = true };
var assemblyDefinition = AssemblyDefinition.ReadAssembly (fileName,
readerParameters);

// make required changes.

var writerParameters = new WriterParameters { WriteSymbols = true };
assemblyDefinition.Write (outputFile, writerParameters);

Second, I tried to collect coverage information by running a test suite on
the new assembly along with the new pdb, in a VS2010 test project using
MSTest, but I failed to add the new assembly when I setting up the test
configuration. The error message is "Cannot obtain the symbols information
for the binary ... Please ensure that both the binary and the symbols files
are accessible."... -- I doubt this was caused by the first issue.

Could anyone help on this?

Thanks in advance!
Post by Gábor Kozár
Oh, nevermind that last, I'm just dumb. I missed the part that
Mono.Cecil.Pdb will be tried to be used under Windows, and Mono.Cecil just
apparently failed silently when I didn't have dll referenced. Really should
cause an exception!
Thanks for your help! Works perfectly now!
(Haha, just received your e-mail telling the same. Thanks for coping with
stupid users like myself. :))
Post by Gábor Kozár
I've tried that, but the result is the same. I mean, literally: getting
no pdb file generated, even though I've set both the ReadSymbols and
WriteSymbols properties, and I have Mono.Cecil.Mdb.dll referenced. The
output .exe is written fine, but no pdb. I get no errors or exceptions.
My corresponding lines are exactly the same as on your wiki. Any hints?
Post by Jb Evain
Hi,
Post by Gábor Kozár
As far as I know Mono.Cecil is capable of altering symbol files. Could
somebody point me into the right direction with this?
https://github.com/jbevain/cecil/wiki/Debug-symbols
Jb
--
--
mono-cecil
--
--
mono-cecil
Loading...