자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 Q&A 이용 (제품 구매 고객 한정)

본 게시판 사용시 당부 사항
* 이 게시판은 자유롭게 질문을 올리고 자발적으로 답변을 공유하는 게시판입니다.
* 어느 누구도 답변을 달아야만 하는 책임은 없습니다.
* 따라서 질문을 올리실 때에는 최대한 자세하고 정중하게 질문을 올려 주세요.
* 최대한 질문을 자세히 올려야 답변도 자세히 올라 옵니다.
* 본 질문에 답변을 주시는 여러 개발자님들께 미리 감사드립니다.
-----------------------------------------------------------------------------------------------
 

참고: // http://www.blong.com/Conferences/BorCon2002/Debugging/3188.htm

delphi7 기준 입니다.

 

type
  TAssertErrorProc = procedure (const Message, Filename: string;
    LineNumber: Integer; ErrorAddr: Pointer);

var
  AssertErrorProc   : TAssertErrorProc; { Assertion error handler }

function MakeDebugMsg(const Msg: String; ShowPIDAndTID: Boolean): String;
begin
  if ShowPIDAndTID then
    Result := Format('PID = %d ($%0:x), TID = %d ($%1:x): %s',
      [GetCurrentProcessID, GetCurrentThreadID, Msg])
  else
    Result := Msg;
end;
 
 
 
procedure InternalDebugMsg(const Msg: String);
begin
  OutputDebugString(PChar(Msg))
end;
 
procedure DebugMsg(const Msg: String;
  ShowPIDAndTID: Boolean = False); overload;
begin
  InternalDebugMsg(MakeDebugMsg(Msg, ShowPIDAndTID));
end;
 
procedure DebugMsg(const Msg: String; const Params: array of const;
  ShowPIDAndTID: Boolean = False); overload;
begin
  DebugMsg(Format(Msg, Params), ShowPIDAndTID)
end;
 
 
 
//The debug support code from DebugSupport.pas
procedure AssertErrorHandler(const Msg, Filename: string;
  LineNumber: Integer; ErrorAddr: Pointer);
begin
  //ErrorAddr is address Assert will return to
  //(i.e. instruction following call to Assert).
  //Subtract 1 from it to ensure it refers to part
  //of the Assert call, making it more appropriate
  DebugMsg('%s (%s, line %d, address $%x)',
    [Msg, Filename, LineNumber, Pred(Integer(ErrorAddr))]);
end;
 

procedure TfMain.Button1Click(Sender: TObject);
begin
  try
    Assert(False, 'Entering TestIt routine');
    //body of the interesting routine
    Assert(False, 'Exiting TestIt routine');
  except
  on e : Exception do
    begin
      ShowMessage(e.Message);
    end;
  end;
end;
 

procedure RerouteAssertions;
begin
{$ifdef Delphi6AndAbove}
  AssertErrorProc := AssertErrorHandler;
{$else}
  AssertErrorProc := @AssertErrorHandler;
{$endif}
end;
 
 
 
 
 
initialization
  RerouteAssertions;
 
 
번호 제목 글쓴이 날짜 조회 수
공지 [프로그래밍 강의] 2021.6~2021.12 관리자 2015.01.22 15875
공지 유용한 관련 사이트 관리자2 2014.03.20 54664
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 98126
1439 [시작하는 사람들을 위한 델파이 프로그래밍] 모듈 6 - Exercise 3 [9] 관리자 2016.05.02 447
1438 ExportGridToXLSX 한글 & 특수 문자 사용시 오류 가나다 2021.02.10 448
1437 10.1 Berlin FMX TStringGrid문제 [3] 불나방 2016.05.16 449
1436 REST Debugger 실행시 에러 [3] file 미스터몽키 2018.01.08 449
1435 [10.4 시드니 신기능] 이제 리눅스 클라이언트 프로그램 개발이 윈도우처럼 가능합니까? 험프리 2020.06.10 449
1434 파이어몽키로 사진저장 파일오류...?? [1] 밤바야 2016.05.26 450
1433 [질문] rtl210 error 관련 [2] file 평생회원 2017.06.26 450
1432 Delphi 10.2 Indy Client Component 문의드립니다. [1] 엘트 2019.09.30 450
1431 델파이 10.4에서 10.3.3 에서 되던 fcm push가 안됩니다. [3] 델파이_사랑 2020.12.04 450
1430 c++ buider 10.4.2 버젼 설치하고 테스트 [2] sihwan 2021.02.25 450
1429 TEdit 에 커서가 들어갈때 가상키보드 나타나지 않게 [2] 희망나라 2015.06.22 451
1428 VCL 컴포넌트를 FMX용으로 바꾸고 싶습니다. [6] 쿠리 2018.09.12 451
1427 sqlite [1] 희망나라 2021.03.10 451
1426 경로 문제에 대하여 [1] file 손보라 2016.07.28 453
» 아래 Debug Error 추적 내용이 있어 다른 방법을 공유 합니다. [1] jang 2016.12.06 453
1424 HTML 에디터 관련 문의드립니다 [1] 배기현 2015.05.27 453
1423 델파이7에서 String 변수 값이 메모리에 남습니다. [1] 농약먹고쿠 2016.02.04 453
1422 LOCKBOX의 CODEC컴포넌트에서 AES 복호화시 유니코드 에러 입니다 ㅠ 돌떵이이11 2021.04.20 453
1421 Unable to open include file '*.hpp' [1] jina 2016.07.26 454
1420 실명인증, 본인인증 [1] 가나다 2019.04.03 454