Bug 321315 (MONO78586) - Wrong line numbers in stack traces
Summary: Wrong line numbers in stack traces
Status: CONFIRMED
Alias: MONO78586
Product: Mono: Runtime
Classification: Mono
Component: debug (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-05 23:06 UTC by Rodrigo Oliveira
Modified: 2011-06-02 18:01 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:00:50 UTC


---- Reported by rodrigobamboo@gmail.com 2006-06-05 16:06:59 MST ----

using System;
using System.IO;
using System.Reflection.Emit;
using System.Reflection;
using System.Diagnostics.SymbolStore;

namespace BugReport
{
    public interface IFoo
    {
        void Bar();
    }

    class Program
    {
        const string DocumentPath = "/temp/test.cs";

        static void Main(string[] args)
        {
            IFoo foo = EmitFoo();
            try
            {
                foo.Bar();
            }
            catch (Exception x)
            {
                //Console.WriteLine(x);
                Assert(x.StackTrace.IndexOf(DocumentPath + ":10") != -1);
            }
        }
        
        static void Assert(bool condition)
        {
            if (!condition) throw new ApplicationException();
        }

        static IFoo EmitFoo()
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;
            string fname = Path.Combine(currentDomain.BaseDirectory,
"bugged.dll");

            AssemblyName name = new AssemblyName();
            name.Name = Path.GetFileNameWithoutExtension(fname);

            AssemblyBuilder builder =
currentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Save,
Path.GetDirectoryName(fname), null);
            ModuleBuilder module =
builder.DefineDynamicModule(Path.GetFileName(fname), true);
            ISymbolDocumentWriter document =
module.DefineDocument(DocumentPath, SymDocumentType.Text,
SymLanguageType.CSharp, Guid.Empty);

            TypeBuilder foo = module.DefineType("Foo",
TypeAttributes.Public | TypeAttributes.Class, typeof(object));
            foo.AddInterfaceImplementation(typeof(IFoo));

            MethodBuilder bar = foo.DefineMethod("Bar",
MethodAttributes.Public | MethodAttributes.Virtual, typeof(void), new Type[0]);
            ILGenerator il = bar.GetILGenerator();
            il.MarkSequencePoint(document, 10, 0, 11, 0);
            il.ThrowException(typeof(ApplicationException));
            // MONO uses the next sequence point as the line number for the
            // exception above, it should use the previous one
            il.MarkSequencePoint(document, 11, 0, 12, 0);
            il.Emit(OpCodes.Ret);

            foo.CreateType();

            builder.Save(Path.GetFileName(fname));
            return
(IFoo)Activator.CreateInstance(Assembly.LoadFrom(fname).GetType("Foo"));
        }
    }
}



---- Additional Comments From martin@ximian.com 2006-06-12 09:28:55 MST ----

What's the problem here, this works for me ?


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Windows XP</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".