3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
937 stars 131 forks source link

How to debug? #204

Closed CoenraadS closed 2 years ago

CoenraadS commented 2 years ago

Hello

Apologies for yet another issue, I did search first but didn't see this one yet. Closest I found was https://github.com/3F/DllExport/issues/164 but it's not my problem Maybe related to https://github.com/3F/coreclr/issues/3? . . .

The question is related to:


Hi

When I try to debug my project with DLLExport function from a unit-test, Visual Studio asks me to locate the {projectName}.il file?

Any idea how I can resolve this?

3F commented 2 years ago
Compiler.rSysObj: False
Compiler.ourILAsm: False
Compiler.customILAsm: 
...
TargetFramework: net472

No, this is not related to https://github.com/3F/coreclr/issues/3

Did you try to set debugger type at least to Mixed? You can also note this in my old screencasts on youtube

Also make sure .pdb is located near final/modified assembly. That is, same to $(TargetDir) because of selected x86 but $(TargetDir)\x86 for x86+x64

CoenraadS commented 2 years ago

Hi, when I remove the nuget package it debugs normally hence I think it's related. Dll and pdb are in same folder, but the error isn't that it can't find the pdb. Not really sure what else I can try to debug this issues

On Sun, Feb 20, 2022, 6:18 PM Denis Kuzmin @.***> wrote:

Compiler.rSysObj: False Compiler.ourILAsm: False Compiler.customILAsm: ... TargetFramework: net472

No, this is not related to 3F/coreclr#3 https://github.com/3F/coreclr/issues/3

Did you try to set debugger type at least to Mixed? You can also note this in my old screencasts on youtube

Also make sure .pdb is located near final/modified assembly. That is, same to $(TargetDir) because of selected x86 but $(TargetDir)\x86 for x86+x64

— Reply to this email directly, view it on GitHub https://github.com/3F/DllExport/issues/204#issuecomment-1046283036, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKVVYM5YJZITMTG4EJO2YTU4EO6FANCNFSM5O4SB74A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

3F commented 2 years ago

Hi, @CoenraadS

Can you clarify the following,

  1. Where is entry point for both cases? From unmanaged/native side?
  2. What actual value for debugger type?
  3. Can you also reproduce this behavior from scratch in empty project?
  4. Please attach build log if possible

Thanks

CoenraadS commented 2 years ago

Hi, so I have enabled mixed-mode debugged on both my project and the unit test project, to no avail. Tried both VS2019 & 2022

  1. EntryPoint is from managed unit-test, then calling (still managed), a function with [DLLExport] defined. When I try to step into the function is asks for this .il file.

  2. This is no value? I did not manage to step into the function

  3. I attached empty project, just try to step into the function from the test project ClassLibrary1.zip

I noticed it also happens to functions without [DllExport] attribute, as long as it's present on at least one function, all functions become undebuggable

3F commented 2 years ago

Looks like a bug for x86 and individual x64 configurations.

Meanwhile this works well for "x86+x64". Check this out.

This is no value?

My mistake, my thoughts were about C++ projects ~ e.g. available debugger types to use:

cpp

CoenraadS commented 2 years ago

Do you mean change PlatformTarget from x86 to AnyCPU?

Unfortunately I am interfacing with a 32 bit application and then the bindings break.

3F commented 2 years ago

No. It will just produce both x86 and x64 modules in individual folders (i.e. $(TargetDir)\x86 and $(TargetDir)\x64). There is nothing incompatible for your task. You need only select "x86+x64" when configuring, then Apply. It should help until fix.

CoenraadS commented 2 years ago

Thanks for your patience, it is working now, at least from the unit test.

I tried a remote-debug situation, but then received {projectName}.x86.il not found. However I could continue with Decompile source code which while not perfect, is already much better then having nothing.

3F commented 2 years ago

at least from the unit test

Can you describe steps for a "remote-debug situation" because "x86+x64" should work for other cases too, like manual attaching to process (just checked it) for debugger or other entering from some executable modules.

CoenraadS commented 2 years ago

InnoSetupExample.zip

ClassLibrary1\bin\Debug\net472\win-x86\x86\CodeDll.iss

Hi, I think the easiest way to reproduce is to run it from InnoSetup

I made a minimal example, just run the script from InnoSetup and it will automatically launch the debugger and give the .il error