|
View:
New views
17 Messages
—
Rating Filter:
Alert me
|
|
|
Change debugging information questionHi, is there a way to change the source file and line of a generated class? We have a template system which generates a c# class code and compiles it to an assembly, similar to the way as asp.net works. If now an exception in the generated code occurs, the stack traces shows the generated class and line of the generated code. What i want know is that i change the debugging informations of the class to the path of the original template file and the original line in template files. And as addition and with a little bit luck, i hope that vs then opens the file and jump to the line if a exception occurs while debugging the application. The assembly is currently generated in memory. Did you have tips or advice how can i do this? Greets, Steve --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information questionHey Steve, On 11/26/08, Steve Wagner <lists@...> wrote: > Hi, is there a way to change the source file and line of a generated class? Sure. Well, the debugging informations are actually tied to methods bodies, not classes, but it should not prevent you to modify them the way you want. > We have a template system which generates a c# class code and compiles > it to an assembly, similar to the way as asp.net works. If now an > exception in the generated code occurs, the stack traces shows the > generated class and line of the generated code. What i want know is that > i change the debugging informations of the class to the path of the > original template file and the original line in template files. And as > addition and with a little bit luck, i hope that vs then opens the file > and jump to the line if a exception occurs while debugging the > application. The assembly is currently generated in memory. > > Did you have tips or advice how can i do this? First you have to build the assemblies which support reading and writing debugging informations for Cecil. The one for writing pdbs on .net is located in Mono's svn in: /cecil/pdb While the one for Mono's symbol file format is in: /mcs/class/Mono.Cecil.Mdb When you have them compiled, just make sure they are along Mono.Cecil.dll. Then pretty much all you have to do is to call module.LoadSymbols () just after the GetAssembly () call, and module.SaveSymbols () just before actually saving the assembly. In between, what you can modify are the .SequencePoints of the instruction, which hold the debugging information (file and location in the file). Best, -- Jb Evain <jb@...> --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information questionHi Jb thanks for the answer! I will try this, but can i open and change an assembly which is compiled into memory this way? Steve Jb Evain schrieb: > Hey Steve, > > On 11/26/08, Steve Wagner <lists@...> wrote: >> Hi, is there a way to change the source file and line of a generated class? > > Sure. Well, the debugging informations are actually tied to methods > bodies, not classes, but it should not prevent you to modify them the > way you want. > >> We have a template system which generates a c# class code and compiles >> it to an assembly, similar to the way as asp.net works. If now an >> exception in the generated code occurs, the stack traces shows the >> generated class and line of the generated code. What i want know is that >> i change the debugging informations of the class to the path of the >> original template file and the original line in template files. And as >> addition and with a little bit luck, i hope that vs then opens the file >> and jump to the line if a exception occurs while debugging the >> application. The assembly is currently generated in memory. >> >> Did you have tips or advice how can i do this? > > First you have to build the assemblies which support reading and > writing debugging informations for Cecil. > > The one for writing pdbs on .net is located in Mono's svn in: > > /cecil/pdb > > While the one for Mono's symbol file format is in: > > /mcs/class/Mono.Cecil.Mdb > > When you have them compiled, just make sure they are along Mono.Cecil.dll. > > Then pretty much all you have to do is to call > > module.LoadSymbols () > > just after the GetAssembly () call, and > > module.SaveSymbols () > > just before actually saving the assembly. > > In between, what you can modify are the .SequencePoints of the > instruction, which hold the debugging information (file and location > in the file). > > Best, > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information questionHey, On 11/26/08, Steve Wagner <lists@...> wrote: > Hi Jb thanks for the answer! I will try this, but can i open and change > an assembly which is compiled into memory this way? You can not modify an already loaded assembly and load it back in its AppDomain. -- Jb Evain <jb@...> --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information questionHi Jb, thanks it works as i want it. :-) The only problem now is that i dont need the resulting assembly anymore when i am done. Is there a way to load the assembly from file into memory and then removing the file? Jb Evain schrieb: > Hey, > > On 11/26/08, Steve Wagner <lists@...> wrote: >> Hi Jb thanks for the answer! I will try this, but can i open and change >> an assembly which is compiled into memory this way? > > You can not modify an already loaded assembly and load it back in its AppDomain. > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionHi Jb, ive got a problem with the SaveSymboles function. I have a very
simple assembly which only declares one class. This assembly was generated with the latest boo compiler. If i now use the SaveSymboles function and save the assembly after that with AssemblyFactory.SaveAssembly ive got a assembly which is only half of size as the original assembly and if i try to load it with Assembly.Load ive got a BadImageFormatException. Attached a sample project which demonstrates this problem. Greets, Steve Jb Evain schrieb: > Hey, > > On 11/26/08, Steve Wagner <lists@...> wrote: >> Hi Jb thanks for the answer! I will try this, but can i open and change >> an assembly which is compiled into memory this way? > > You can not modify an already loaded assembly and load it back in its AppDomain. > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionDid you have an idea Jb? Steve Wagner schrieb: > Hi Jb, ive got a problem with the SaveSymboles function. I have a very > simple assembly which only declares one class. This assembly was > generated with the latest boo compiler. If i now use the SaveSymboles > function and save the assembly after that with > AssemblyFactory.SaveAssembly ive got a assembly which is only half of > size as the original assembly and if i try to load it with Assembly.Load > ive got a BadImageFormatException. > > Attached a sample project which demonstrates this problem. > > Greets, Steve > > Jb Evain schrieb: >> Hey, >> >> On 11/26/08, Steve Wagner <lists@...> wrote: >>> Hi Jb thanks for the answer! I will try this, but can i open and change >>> an assembly which is compiled into memory this way? >> You can not modify an already loaded assembly and load it back in its AppDomain. >> > > > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatException |
|
|
Re: Change debugging information question - BadImageFormatExceptionHey, On 12/1/08, Steve Wagner <lists@...> wrote: > Did you have an idea Jb? The issue is that the pdb writer overwrite too much data in the assembly when patching it with the debug header. I'll look into fixing it. -- Jb Evain <jb@...> --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionOk thanks JB Jb Evain schrieb: > Hey, > > On 12/1/08, Steve Wagner <lists@...> wrote: >> Did you have an idea Jb? > > The issue is that the pdb writer overwrite too much data in the > assembly when patching it with the debug header. > > I'll look into fixing it. > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionCan you give me some hint on which place is must start to look to trying to fix it by my self? I am not very familiar with the way assembly's must be written. Steve Jb Evain schrieb: > Hey, > > On 12/1/08, Steve Wagner <lists@...> wrote: >> Did you have an idea Jb? > > The issue is that the pdb writer overwrite too much data in the > assembly when patching it with the debug header. > > I'll look into fixing it. > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionHi Steve,
Any luck? I also have got the same problem. Jb do you have any hint of any kind, I can also try to check out the problem this weekend (if I can provide with any help).
//Mario
On Thu, Dec 11, 2008 at 6:20 AM, Steve Wagner <lists@...> wrote:
--~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionHi Mario, no i did not tryed to find it because i have no idea how an assembly must written to be correct. So i decided to move to other think on my todo list first. Steve Mario Toffia schrieb: > Hi Steve, > Any luck? I also have got the same problem. Jb do you have any hint of any > kind, I can also try to check out the problem this weekend (if I can provide > with any help). > > //Mario > > On Thu, Dec 11, 2008 at 6:20 AM, Steve Wagner <lists@...> wrote: > >> Can you give me some hint on which place is must start to look to trying >> to fix it by my self? I am not very familiar with the way assembly's >> must be written. >> >> Steve >> >> Jb Evain schrieb: >>> Hey, >>> >>> On 12/1/08, Steve Wagner <lists@...> wrote: >>>> Did you have an idea Jb? >>> The issue is that the pdb writer overwrite too much data in the >>> assembly when patching it with the debug header. >>> >>> I'll look into fixing it. >>> > > > > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionHey Steve, On 12/11/08, Steve Wagner <lists@...> wrote: > Can you give me some hint on which place is must start to look to trying > to fix it by my self? I am not very familiar with the way assembly's > must be written. Sadly it's a little bit complicated. Am still thinking about how I want to tackle that. -- Jb Evain <jb@...> --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionHi Jb, i assume this bug get fixed within the rewrite of cecil? Can you make a rough estimate when ca. there is a testable version of the rewrite? Happy new year and hope the neighbor's dog get silent soon :-) Jb Evain schrieb: > Hey Steve, > > On 12/11/08, Steve Wagner <lists@...> wrote: >> Can you give me some hint on which place is must start to look to trying >> to fix it by my self? I am not very familiar with the way assembly's >> must be written. > > Sadly it's a little bit complicated. Am still thinking about how I > want to tackle that. > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionHey Steve, On 1/5/09, Steve Wagner <lists@...> wrote: > Hi Jb, i assume this bug get fixed within the rewrite of cecil? Can you > make a rough estimate when ca. there is a testable version of the rewrite? I'll fix it before the refactoring lands, but it requires changes to Cecil, Cecil.Pdb and Cecil.Mdb. > Happy new year and hope the neighbor's dog get silent soon :-) Happy new year! -- Jb Evain <jb@...> --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Change debugging information question - BadImageFormatExceptionHi Jb, any progress here? -Steve Jb Evain schrieb: > Hey Steve, > > On 1/5/09, Steve Wagner <lists@...> wrote: >> Hi Jb, i assume this bug get fixed within the rewrite of cecil? Can you >> make a rough estimate when ca. there is a testable version of the rewrite? > > I'll fix it before the refactoring lands, but it requires changes to > Cecil, Cecil.Pdb and Cecil.Mdb. > >> Happy new year and hope the neighbor's dog get silent soon :-) > > Happy new year! > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |