2017-11-16 19 views
0

나는 소스 코드에 로그 항목을 추가하는 습관이없는 회사에서 일하고있다.디버거가 연결된 프로세스의 소스 코드 라인을 모두 실행할 수 있습니까?

따라서 어떤 문제가 발생하면 실제로 일어난 일을 설명하는 로그의 양이 너무 작아서 실제 분석을 수행 할 수 없습니다.

그러므로 나는 다음과 같은 작업을 수행 할 수있는 도구를 찾고 있어요 :
  • 는 기호 파일을 실행중인 프로세스와 링크로 연결합니다.
  • 실행되는 모든 소스 코드를 따르십시오. ,

은 []

file1.c:010: function1(1, 2, 5) 
file1.c:011: sum(1,2) 
file1.c:020:  return 3; 
file1.c:012: sum(3,5); 
file1.c:020:  return 8; 
file1.c:012: return 8; 

내가이 질문은 매우 순진한 소리가 상상할 수 : 특정 키 ("Ctrl + C"와 같은)을 누르면

  • 후, 다음과 같이 보이는 보고서를 하지만이 결과에 접근하는 무언가를 가질 수 있다면 매우 유용 할 것입니다.

    누구나 windbg, cdb, Visual Studio 또는 다른 방법을 사용하여 달성 할 수 있는지 알고 있습니까? 예 windbg를이 단계 및 간단한 RECV 샘플

    SRC 정보와 그 PDB가 사용할 수있는 실행 파일을 시작하기위한

    데모 아래에 인쇄 소스 라인 수 있다면

  • +0

    (너무 많은 번거 로움없이)에서 [중량] (https://docs.microsoft.com/ 일 것 'main()'에서 시작하여 트레이스를 모듈 ('-m' 옵션)으로 제한하고 심도를 미세하게 조정하는 명령 (예 : en-us/windows-hardware/drivers/debugger/wt- 추적 및 감시 데이터) 옵션 ('-l'). 출력을 로그 파일 ('.logopen' 명령)로 전달하는 것을 잊지 마십시오. 정말 큰 산출량에 대비하십시오 (프로그램에 따라 다름). – Neitsa

    +0

    최적화 된 코드입니까? .NET 코드입니까? IMHO 우리는 질문에 신뢰성있게 대답 할 수있는 정보가 너무 적습니다. –

    +0

    시간 여행 디버깅은 필요한 모든 정보를 기록합니다. 그러나 소스 행이 실행될 때이를 표시하는 확장 프로그램이 없다고 생각합니다 (하나만 작성할 수 있음). https://docs.microsoft.com/en- us/windows-hardware/drivers/debugger/time-travel-debugging-overview – snoone

    답변

    2

    당신은 당신의 exe를 의 소스 코드와 기호를해야합니까 시스템 중단에

    :\>cdb recv 
    
    Microsoft (R) Windows Debugger Version 10.0.16299.15 X86 
    

    windbg를 나누기

    ntdll!LdrpDoDebuggerBreak+0x2c: 
    771a05a6 cc    int  3 
    
    당신이 볼 수

    0:000> .prompt_allow -reg -dis -sym -ea 
    Allow the following information to be displayed at the prompt: 
    (Other settings can affect whether the information is actually displayed) 
        src - Source info for current instruction 
    Do not allow the following information to be displayed at the prompt: 
        sym - Symbol for current instruction 
        dis - Disassembly of current instruction 
        ea - Effective address for current instruction 
        reg - Register state 
    

    주요 단계 10 번으로 이동

    0:000> .lines 
    Line number information will be loaded 
    0:000> l+t 
    Source options are 1: 
        1/t - Step/trace by source line 
    0:000> l+s 
    Source options are 5: 
        1/t - Step/trace by source line 
        4/s - List source code at prompt 
    

    해제하면 SRC를 제외한 다른 모든 출력 SRC 라인의 인쇄를 가능하게 소스 모드에서 스테핑 수 라인 정보의 로딩을 가능하게 각 단계는 src를 보여주고있다

    다양한 내용을 알고 windbg 도움말에서 대상을 제어하고 사용한다. execu 지점 등까지 반환 될 때까지 단계 단계와 같은 기 방법은 당신이 windbg를 달성 할 수있는 가장 가까운 것 같아요

    0:000> g recv!main 
    ModLoad: 69f50000 69f53000 C:\Windows\system32\api-ms-win-core-synch-l1-2-0.DLL 
    > 13: int __cdecl main() { 
    0:000> p 10 
    > 24:  iResult = WSAStartup(MAKEWORD(2,2), &wsaData); 
    > 25:  if (iResult != NO_ERROR) { 
    > 30:  ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 
    > 31:  if (ConnectSocket == INVALID_SOCKET) { 
    > 38:  clientService.sin_family = AF_INET; 
    > 39:  clientService.sin_addr.s_addr = inet_addr("127.0.0.1"); 
    > 40:  clientService.sin_port = htons(27015); 
    > 42:  iResult = connect(ConnectSocket, (SOCKADDR*) &clientService, sizeof(clientService)); 
    > 43:  if (iResult == SOCKET_ERROR) { 
    > 44:   closesocket (ConnectSocket); 
    > 45:   printf("Unable to connect to server: %ld\n", WSAGetLastError()); 
    
    Unable to connect to server: 0 
    > 66:   WSACleanup(); 
    > 67:   return 1; 
    > 88: } 
    *** The C++ standard library and CRT step filter can be enabled to skip this fun 
    ction. Run .settings set Sources.SkipCrtCode = true">.settings set Sources.SkipC 
    rtCode = true to enable it. *** 
    
    +0

    답장을 보내 주셔서 감사합니다. PC에서'cdb '를 사용하고 현지 제품으로 예제를 시도했지만 결과가 아직 좋지는 않지만 매우 유망합니다. – Dominique

    +2

    cdb는 windbg과 함께 할 수있는 요구 사항이 아니며 windbg 및 cdb의 도움말 파일도 동일한 디버거입니다 .chm – blabb