Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

WinDbg - 덤프 분석 중인 닷넷 어셈블리가 Debug 빌드인지, Release 빌드인지 알아내는 방법

혹시, WinDbg에서도 분석 중인 모듈의 빌드 상태를 알아낼 수 있을까요?

해당 어셈블리가 Debug 빌드인지, Release 빌드인지 알아내는 방법
; https://www.sysnet.pe.kr/2/0/1227

일단, lm 명령어로는 딱히 나오는 것이 없습니다.

0:000> lmDvmConsoleApp1
Browse full module list
start             end                 module name
000001c2`6e4e0000 000001c2`6e4e8000   ConsoleApp1   (deferred)             
    Image path: c:\temp\builds\ConsoleApp1\AnyCPU\Debug\ConsoleApp1.dll
    Image name: ConsoleApp1.dll
    Browse all global symbols  functions  data  Symbol Reload
    Using CLR debugging support for all symbols
    Has CLR image header, track-debug-data flag not set
    Image was built with /Brepro flag.
    Timestamp:        A845CF62 (This is a reproducible build file hash, not a timestamp)
    CheckSum:         00000000
    ImageSize:        00008000
    Mapping Form:     Loaded
    File version:     1.0.0.0
    Product version:  1.0.0.0
    File flags:       0 (Mask 3F)
    File OS:          4 Unknown Win32
    File type:        1.0 App
    File date:        00000000.00000000
    Translations:     0000.04b0
    Information from resource tables:
        CompanyName:      ConsoleApp1
        ProductName:      ConsoleApp1
        InternalName:     ConsoleApp1.dll
        OriginalFilename: ConsoleApp1.dll
        ProductVersion:   1.0.0
        FileVersion:      1.0.0.0
        FileDescription:  ConsoleApp1
        LegalCopyright:    

중간에 "track-debug-data flag not set"이라는 문구가 있는데, Debug/Release 모두 동일한 문자열이 나왔습니다. 이제 남은 것은 sos 확장 명령어인데요, 그나마 쓸모 있는 정보가 DumpModule의 TransientFlags로 나오는 듯합니다.

// Debug 빌드인 경우

0:000> !DumpModule /d 00007ffe2c7b7770
Name: c:\temp\builds\ConsoleApp1\AnyCPU\Debug\ConsoleApp1.dll
Attributes:              PEFile 
TransientFlags:          00209019 IS_EDIT_AND_CONTINUE
Assembly:                000001c26cb3d3c0
BaseAddress:             000001C26E4E0000
LoaderHeap:              0000000000000000
TypeDefToMethodTableMap: 00007FFE2C7A2240
TypeRefToMethodTableMap: 00007FFE2C7A2270
MethodDefToDescMap:      00007FFE2C7A2358
FieldDefToDescMap:       00007FFE2C7A23B0
MemberRefToDescMap:      0000000000000000
FileReferencesMap:       00007FFE2C7A23D8
AssemblyReferencesMap:   00007FFE2C7A23E0
MetaData start address:  000001C26E4E21BC (2664 bytes)

// Release 빌드인 경우

0:000> !DumpModule /d 00007ffe2c7f7778
Name: c:\temp\builds\ConsoleApp1\AnyCPU\Release\ConsoleApp1.dll
Attributes:              PEFile 
TransientFlags:          00208811 
Assembly:                00000227fc48bca0
BaseAddress:             00000227FDF50000
LoaderHeap:              0000000000000000
TypeDefToMethodTableMap: 00007FFE2C7E2240
TypeRefToMethodTableMap: 00007FFE2C7E2270
MethodDefToDescMap:      00007FFE2C7E2348
FieldDefToDescMap:       00007FFE2C7E23A0
MemberRefToDescMap:      0000000000000000
FileReferencesMap:       00007FFE2C7E23C8
AssemblyReferencesMap:   00007FFE2C7E23D0
MetaData start address:  00000227FDF5219C (2572 bytes)

위의 경우, "IS_EDIT_AND_CONTINUE"는 Visual Studio에서 "Edit and Continue" 옵션을 켠 경우에 나타난 것입니다. 그게 꺼져 있다면 출력은 이런 식으로 바뀝니다. (각자의 빌드 옵션에 따라 다릅니다.)

// ("Enable Hot Reload" 옵션을 끈) Debug 빌드인 경우

0:007> !DumpModule /d 00007ffe2c7d7770
Name: c:\temp\builds\ConsoleApp1\AnyCPU\Debug\ConsoleApp1.dll
Attributes:              PEFile 
TransientFlags:          00209011 
Assembly:                000001b13553ac80
BaseAddress:             000001B137040000
LoaderHeap:              0000000000000000
TypeDefToMethodTableMap: 00007FFE2C7C2240
TypeRefToMethodTableMap: 00007FFE2C7C2270
MethodDefToDescMap:      00007FFE2C7C2370
FieldDefToDescMap:       00007FFE2C7C23C8
MemberRefToDescMap:      0000000000000000
FileReferencesMap:       00007FFE2C7C23F0
AssemblyReferencesMap:   00007FFE2C7C23F8
MetaData start address:  000001B1370421D4 (2792 bytes)

그렇다면, 관련해서 TransientFlags 내부에 디버그 빌드에 준하는 정보가 남아 있지 않을까요? ^^ 이를 알아 보기 위해 sos 소스 코드에서 다음과 같은 enum 정보를 찾았는데요,

src/SOS/Strike/strike.cpp
; https://github.com/dotnet/diagnostics/blob/ea6796b6d0556f8ab3c01d0c0d8f234fdfdf1d73/src/SOS/Strike/strike.cpp#L3918

enum {
    // These are the values set in m_dwTransientFlags.
    // Note that none of these flags survive a prejit save/restore.

    MODULE_IS_TENURED           = 0x00000001,   // Set once we know for sure the Module will not be freed until the appdomain itself exits
    // unused                   = 0x00000002,
    CLASSES_FREED               = 0x00000004,
    IS_EDIT_AND_CONTINUE        = 0x00000008,   // is EnC Enabled for this module

    IS_PROFILER_NOTIFIED        = 0x00000010,
    IS_ETW_NOTIFIED             = 0x00000020,

    //
    // Note: the order of these must match the order defined in
    // cordbpriv.h for DebuggerAssemblyControlFlags. The three
    // values below should match the values defined in
    // DebuggerAssemblyControlFlags when shifted right
    // DEBUGGER_INFO_SHIFT bits.
    //
    DEBUGGER_USER_OVERRIDE_PRIV = 0x00000400,
    DEBUGGER_ALLOW_JIT_OPTS_PRIV= 0x00000800,
    DEBUGGER_TRACK_JIT_INFO_PRIV= 0x00001000,
    DEBUGGER_ENC_ENABLED_PRIV   = 0x00002000,   // this is what was attempted to be set.  IS_EDIT_AND_CONTINUE is actual result.
    DEBUGGER_PDBS_COPIED        = 0x00004000,
    DEBUGGER_IGNORE_PDBS        = 0x00008000,
    DEBUGGER_INFO_MASK_PRIV     = 0x0000Fc00,
    DEBUGGER_INFO_SHIFT_PRIV    = 10,

    // Used to indicate that this module has had it's IJW fixups properly installed.
    IS_IJW_FIXED_UP             = 0x00080000,
    IS_BEING_UNLOADED           = 0x00100000,

    // Used to indicate that the module is loaded sufficiently for generic candidate instantiations to work
    MODULE_READY_FOR_TYPELOAD  = 0x00200000,

    // Used during NGen only
    TYPESPECS_TRIAGED           = 0x40000000,
    MODULE_SAVED                = 0x80000000,
};

이에 비춰서 TransientFlags 값을 분석하면 각각 다음과 같이 펼쳐집니다.

// Debug 빌드인 경우

TransientFlags:          00209019
    - MODULE_READY_FOR_TYPELOAD
    - DEBUGGER_IGNORE_PDBS
    - DEBUGGER_TRACK_JIT_INFO_PRIV
    - IS_PROFILER_NOTIFIED
    - IS_EDIT_AND_CONTINUE
    - MODULE_IS_TENURED

// Release 빌드인 경우

TransientFlags:          00208811 
    - MODULE_READY_FOR_TYPELOAD
    - DEBUGGER_IGNORE_PDBS
    - DEBUGGER_ALLOW_JIT_OPTS_PRIV
    - IS_PROFILER_NOTIFIED
    - MODULE_IS_TENURED

// ("Enable Hot Reload" 옵션을 끈) Debug 빌드인 경우

TransientFlags:          00209011 
    - MODULE_READY_FOR_TYPELOAD
    - DEBUGGER_IGNORE_PDBS
    - DEBUGGER_TRACK_JIT_INFO_PRIV
    - IS_PROFILER_NOTIFIED
    - MODULE_IS_TENURED

확신할 수는 없지만, 그냥 저 결과만 보면 DEBUGGER_TRACK_JIT_INFO_PRIV 옵션 유무로 Debug 빌드를 느슨하게 판정할 수는 있을 듯합니다.

참고로, 위의 방법 이외에도 그냥 대상 .NET Assembly를 파일로 덤프시킨 다음,

windbg - 풀 덤프 파일로부터 .NET DLL을 추출/저장하는 방법
; https://www.sysnet.pe.kr/2/0/10943

거기서 Debuggable 특성의 값을 확인하는 것도 고려할 수 있을 것입니다.




유의해야 할 점은, Debug 빌드는 다양한 옵션의 조합이기 때문에 어떤 특정 옵션만을 가지고 Debug 빌드라고 단정할 수는 없습니다. "해당 어셈블리가 Debug 빌드인지, Release 빌드인지 알아내는 방법" 글에서도, DisableOptimizations, EnableEditAndContinue, Default 옵션이 Debuggable 특성에 있는 정도로 판정하는 수준에 불과합니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 11/10/2025]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  [2]  3  4  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
14016정성태9/28/20254069Linux: 122. eBPF - __attribute__((preserve_access_index)) 사용법
14015정성태9/22/20253343닷넷: 2365. C# - FFMpegCore를 이용한 MP4 동영상으로부터 MP3 음원 추출 예제파일 다운로드1
14014정성태9/17/20253291닷넷: 2364. C# - stun.l.google.com을 사용해 공용 IP 주소와 포트를 알아내는 방법파일 다운로드1
14013정성태9/14/20254599닷넷: 2363. C# - Whisper.NET Library를 이용해 음성을 텍스트로 변환 및 번역하는 예제파일 다운로드1
14012정성태9/9/20254341닷넷: 2362. C# - Windows.Media.Ocr: 윈도우 운영체제에 포함된 OCR(Optical Character Recognition)파일 다운로드1
14011정성태9/7/20254847닷넷: 2361. C# - Linux 환경의 readlink 호출
14010정성태9/1/20254968오류 유형: 983. apt update 시 "The repository 'http://deb.debian.org/debian buster Release' does not have a Release file." 오류
14009정성태8/28/20255011닷넷: 2360. C# 14 - (11) Expression Tree에 선택적 인수와 명명된 인수 허용파일 다운로드1
14008정성태8/26/20255520닷넷: 2359. C# 14 - (10) 복합 대입 연산자의 오버로드 지원파일 다운로드1
14007정성태8/25/20256610닷넷: 2358. C# - 현재 빌드에 적용 중인 컴파일러 버전 확인 방법 (#error version)
14006정성태8/23/20256742Linux: 121. Linux - snap 패키지 관리자로 설치한 소프트웨어의 디렉터리 접근 제한
14005정성태8/21/20255343오류 유형: 982. sudo: unable to load /usr/libexec/sudo/sudoers.so: libssl.so.3: cannot open shared object file: No such file or directory
14004정성태8/21/20256037오류 유형: 981. dotnet 실행 시 No usable version of the libssl was found
14003정성태8/21/20256306닷넷: 2357. C# 14 - (9) 새로운 지시자 추가 (Ignored directives)
14002정성태8/20/20256623오류 유형: 980. C# - appsettings.json 파일의 설정값이 적용 안 된다면?
14001정성태8/19/202511514닷넷: 2356. .NET SDK 10 - 단일 소스 코드 파일을 빌드/실행하는 기능을 "dotnet" 명령어에 추가 [1]
14000정성태8/18/20257152오류 유형: 979. ERROR: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory
13999정성태8/15/20256390닷넷: 2355. C# 14 - (8) null 조건부 연산자 개선 - 대입문에도 사용 가능파일 다운로드1
13998정성태8/14/20255496닷넷: 2354. C# 14 - (7) 확장 메서드에 정적 메서드와 속성 지원을 위한 전용 구문 추가파일 다운로드1
13997정성태8/14/20257421Linux: 120. docker 컨테이너로 매핑된 볼륨에 컨테이너 측의 사용자 ID를 유지하면서 복사하는 방법
13996정성태8/13/20255265오류 유형: 978. Unable to find the requested .Net Framework Data Provider.
13995정성태8/13/20255609개발 환경 구성: 754. Visual C++ - 리눅스 빌드를 위한 Ubuntu 18 docker 컨테이너 설정
13994정성태8/12/20255016오류 유형: 977. SQL Server - User, group, or role '...' already exists in the current database. (Microsoft SQL Server, Error: 15023)
13993정성태8/11/20256280오류 유형: 976. Microsoft.ML.OnnxRuntimeGenAI 패키지 사용 시 "cublasLt64_12.dll" which is missing. (Error 126: "The specified module could not be found.") 오류
13992정성태8/11/20255842닷넷: 2353. C# - Foundry Local을 이용한 gpt-oss-20b 모델 사용파일 다운로드1
13991정성태8/9/20255824오류 유형: 975. winget - Foundry Local 패키지 업데이트가 안 되는 문제
1  [2]  3  4  5  6  7  8  9  10  11  12  13  14  15  ...