Microsoft MVP성태의 닷넷 이야기
디버깅 기술: 29. Windbg - Hyper-V 윈도우 7 원격 디버깅 구성 [링크 복사], [링크+제목 복사],
조회: 18358
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 7개 있습니다.)
디버깅 기술: 3. 원격 컴퓨터 디버깅 - VPC 설정
; https://www.sysnet.pe.kr/2/0/265

디버깅 기술: 3.1. Managed 원격 디버깅과 WinDBG 원격 디버깅
; https://www.sysnet.pe.kr/2/0/314

디버깅 기술: 27. Windbg - Local Kernel Debug 모드
; https://www.sysnet.pe.kr/2/0/934

디버깅 기술: 29. Windbg - Hyper-V 윈도우 7 원격 디버깅 구성
; https://www.sysnet.pe.kr/2/0/938

Windows: 57. 새로 추가된 네트워크 커널 디버깅 및 PowerShell 3.0
; https://www.sysnet.pe.kr/2/0/1259

디버깅 기술: 62. windbg - 사용자 모드 원격 디버깅
; https://www.sysnet.pe.kr/2/0/1602

디버깅 기술: 192. Windbg - Hyper-V VM으로 이더넷 원격 디버깅 연결하는 방법
; https://www.sysnet.pe.kr/2/0/13343




Windbg - Hyper-V 윈도우 7 원격 디버깅 구성

예전에 Virtual Server에서 호스팅하고 있는 가상 PC에 windbg를 연결하는 방법을 설명했었는데요.

원격 컴퓨터 디버깅 - VPC 설정 
; https://www.sysnet.pe.kr/2/0/265

방법은 Hyper-V에서도 유사합니다. 단지, 윈도우 7에서의 boot.ini가 제거되는 바람에 약간 추가적인 작업이 필요한 정도인데요.

가상 머신의 COM 포트와 호스트 운영체제 측의 로컬 Named pipe 자원을 연결하는 설정은 이전과 다름없이 아래에서처럼 비슷하게 설정 방법이 제공됩니다. (Generation 2 VM의 경우 PowerShell 명령어로 설정)

windbg_hyperv_win7_1.png

Named pipe 경로: \\.\pipe\se2

이제, 대상이 되는 VM 운영체제에서 다음과 같은 명령을 관리자 권한으로 실행한 후, "재부팅" 해줍니다.

C:\Windows\system32>bcdedit /set debug on
The operation completed successfully.

C:\Windows\system32> bcdedit /set testsigning on
The operation completed successfully.

C:\Windows\system32> bcdedit
...[생략]...

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
...[생략]...
testsigning             Yes
isolatedcontext         Yes
...[생략]...
debug                   Yes

끝났군요. ^^ 마지막으로 windbg를 명령행에서 다음과 같이 실행해 주거나,

...[설치경로]...\windbg.exe -k com:pipe,port=\\.\pipe\se2 -b

또는 windbg 실행 후, "File" / "Kernel Debug..." 메뉴를 이용하여 다음과 같이 설정해서 연결을 할 수 있습니다.

windbg_hyperv_win7_2.png

명령행에서 "-b" 옵션을 주지 않거나, 대화 상자에서 "Reconnect" 옵션을 끄고 실행한다면, 다음과 같이 "Waiting to reconnect..." / "Debuggee not connected" 메시지로 계속 대기를 하게 되는데요.

windbg_hyperv_win7_3.png

잘못된 것이 아니고 ^^ "Debug" / " Break" 메뉴 (단축키: Ctrl+Break)를 실행해 주면 대상이 되는 가상 PC의 실행을 완전히 멈추게 되고 다음과 같이 프롬프트가 떨어지게 됩니다.

windbg_hyperv_win7_4.png

만약, 명령행에서 "-b" 옵션을 주거나 대화 상자에서 "Reconnect" 옵션을 체크했다면 Windbg.exe는 원격 컴퓨터에 연결하자마자 "Break"를 하게 됩니다.

다시 가상 PC를 실행상태로 만들려면 "g" 명령어를 주면 됩니다. ^^




참고로, 원격 디버깅의 경우 반드시 관리자 권한으로 실행해 주어야 하는데, 그렇지 않으면 다음과 같은 오류가 발생합니다.

Could not start kernel debugging using com:pipe,port=\\.\pipe\se2
parameters, Win32 error 0n5

Access is denied.

그리고 주의해야 할 사항!

반드시 windbg 종료할 때 "g" 명령어로 시스템을 활성화시켜주어야 합니다. 그렇지 않으면 계속 스케쥴링이 멈춘 체로 VM이 유지되고 풀어주려면 다시 windbg 실행해서 "g" 명령어를 내려야 합니다. ^^

예전에 Virtual Server 이야기 하면서 VM이 멈춰진 상태에서 CPU 부하가 심하다는 이야기를 한 적이 있는데요. 다행히 Hyper-V에서는 이런 현상이 없습니다. 테스트 삼아서, "Windows Virtual PC" 환경은 어떨까 싶어서 호스팅 되고 있는 "XP Mode" 가상 PC에 windbg를 걸어보았는데 이건 여전히 CPU를 13% 소비하는 현상이 있습니다. (8-core에서 13%는 단일 CPU에서의 100% 현상입니다.)

음... CPU 소비를 고려한다면, windbg로 원격 디버깅하는 환경은 Hyper-V가 이상적일 수 있다는 거군요. ^^



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

[연관 글]






[최초 등록일: ]
[최종 수정일: 6/28/2023]

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

비밀번호

댓글 작성자
 



2020-01-14 10시05분
Windows - Kernel Debugging In Hyper-V
; https://t0rchwo0d.github.io/windows/Windows-Kernel-Debugging-In-Hyper-V/

입문자를 위한 윈도우 디바이스 드라이버 2장(커널디버거)
; https://www.youtube.com/watch?v=hJkSmz0BM5w

USB 키보드 크래시 덤프 (재부팅 후, Ctrl 키를 누른 상태에서 Scroll Lock 키를 두 번 연속 누르면 덤프 생성)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\kbdhid\Parameters
CrashOnCtrlScroll (REG_DWORD 0x01)

Why can’t I trigger a manual blue screen crash by injecting the magic key sequence?
; https://devblogs.microsoft.com/oldnewthing/20240219-00/?p=109424

이더넷 연결
; https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/bcdedit--dbgsettings
; https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/setting-up-network-debugging-of-a-virtual-machine-host

[Debuggee]
C:\Windows\System32> bcdedit /dbgsettings net hostip:192.168.100.50 port:65100 key:t.e.s.t

C:\Windows\System32> bcdedit /dbgsettings
key t.e.s.t
debugtype NET
hostip 192.168.100.50
port 65100
badmemoryaccess Yes
dhcp Yes
The operation completed successfully.

[Debugger]
windbg 실행 후 Ctrl + K(Kernel Debug...) 메뉴를 통해 "NET" 설정
정성태

... 46  47  48  [49]  50  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12421정성태11/19/20208784.NET Framework: 972. DNNE가 출력한 NE DLL을 직접 생성하는 방법파일 다운로드1
12420정성태11/19/20207966오류 유형: 684. Visual C++ - MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
12419정성태11/19/20209243VC++: 139. Visual C++ - .NET Core의 nethost.lib와 정적 링크파일 다운로드1
12418정성태11/19/202011265오류 유형: 683. Visual C++ - error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug'파일 다운로드1
12417정성태11/19/20208685오류 유형: 682. Visual C++ - warning LNK4099: PDB '...pdb' was not found with '...lib(pch.obj)' or at '...pdb'; linking object as if no debug info
12416정성태11/19/20209967오류 유형: 681. Visual C++ - error LNK2001: unresolved external symbol _CrtDbgReport
12415정성태11/18/202010083.NET Framework: 971. UnmanagedCallersOnly 특성과 DNNE 사용파일 다운로드1
12414정성태11/18/202011106VC++: 138. x64 빌드에서 extern "C"가 아닌 경우 ___cdecl name mangling 적용 [4]파일 다운로드1
12413정성태11/17/202010799.NET Framework: 970. .NET 5 / .NET Core - UnmanagedCallersOnly 특성을 사용한 함수 내보내기파일 다운로드1
12412정성태11/16/202013033.NET Framework: 969. .NET Framework 및 .NET 5 - UnmanagedCallersOnly 특성 사용파일 다운로드1
12411정성태11/12/202010030오류 유형: 680. C# 9.0 - Error CS8889 The target runtime doesn't support extensible or runtime-environment default calling conventions.
12410정성태11/12/20209928디버깅 기술: 174. windbg - System.TypeLoadException 예외 분석 사례
12409정성태11/12/202011306.NET Framework: 968. C# 9.0의 Function pointer를 이용한 함수 주소 구하는 방법파일 다운로드1
12408정성태11/9/202022860도서: 시작하세요! C# 9.0 프로그래밍 [8]
12407정성태11/9/202011608.NET Framework: 967. "clr!JIT_DbgIsJustMyCode" 호출이 뭘까요?
12406정성태11/8/202013190.NET Framework: 966. C# 9.0 - (15) 최상위 문(Top-level statements) [5]파일 다운로드1
12405정성태11/8/202010602.NET Framework: 965. C# 9.0 - (14) 부분 메서드에 대한 새로운 기능(New features for partial methods)파일 다운로드1
12404정성태11/7/202011147.NET Framework: 964. C# 9.0 - (13) 모듈 이니셜라이저(Module initializers)파일 다운로드1
12403정성태11/7/202011180.NET Framework: 963. C# 9.0 - (12) foreach 루프에 대한 GetEnumerator 확장 메서드 지원(Extension GetEnumerator)파일 다운로드1
12402정성태11/7/202011795.NET Framework: 962. C# 9.0 - (11) 공변 반환 형식(Covariant return types) [1]파일 다운로드1
12401정성태11/5/202010699VS.NET IDE: 153. 닷넷 응용 프로그램에서의 "My Code" 범위와 "Enable Just My Code"의 역할 [1]
12400정성태11/5/20207664오류 유형: 679. Visual Studio - "Source Not Found" 창에 "Decompile source code" 링크가 없는 경우
12399정성태11/5/202011415.NET Framework: 961. C# 9.0 - (10) 대상으로 형식화된 조건식(Target-typed conditional expressions)파일 다운로드1
12398정성태11/4/20209911오류 유형: 678. Windows Server 2008 R2 환경에서 Powershell을 psexec로 원격 실행할 때 hang이 발생하는 문제
12397정성태11/4/202010076.NET Framework: 960. C# - 조건 연산자(?:)를 사용하는 경우 달라지는 메서드 선택 사례파일 다운로드1
12396정성태11/3/20208383VS.NET IDE: 152. Visual Studio - "Tools" / "External Tools..."에 등록된 외부 명령어에 대한 단축키 설정 방법
... 46  47  48  [49]  50  51  52  53  54  55  56  57  58  59  60  ...