pdb 도구를 이용한 python 디버깅

2024. 10. 18. 09:31·기반 지식

 

1. pdb란?

● 프로그래밍에서, PDB는 "Python Debugger"의 약자로, 파이썬 프로그래밍 언어의 내장 디버깅 도구이다.

●  PDB를 사용하면 코드의 실행을 한 줄씩 추적하며, 변수의 값, 함수의 흐름 등을 실시간으로 검사하고 수정할 수 있다.

●  디버깅 과정에서 중단점(breakpoint)을 설정하고, 코드를 단계별로 실행하거나 특정 조건에서 멈추도록 할 수 있어, 코드 오류를 찾고 수정하는 데 매우 유용하다.

●  명령어를 통해 디버깅 작업을 진행하며, pdb.set_trace()를 코드 중간에 넣으면 그 지점에서 디버거가 실행되어 코드 실행을 멈추고 확인할 수 있다.

 

2. 실습

import pdb

 

중단점(break point) 지정

 

Debugger 확인

 

3. Command

Command Description Example
l Show a few lines of code around the current line. l
n Move to the next line (do not enter functions). n
s Step into the function if called. s
c Continue execution until a breakpoint is reached. c
b Set a breakpoint at a specific line or function. b 10
condition Add a condition to an existing breakpoint. condition 1 x == 5
tbreak Set a temporary breakpoint that clears after hitting once. tbreak 10
cl Clear a specific breakpoint or all breakpoints. cl 1
p Print the value of a variable. p x

 

'기반 지식' 카테고리의 다른 글

Proc Filesystem  (0) 2024.12.03
Windows Server 2008 R2 초기 설정  (0) 2024.11.28
로컬에 Wordpress 설치  (5) 2024.10.19
Windows Defender Off  (0) 2024.10.17
'기반 지식' 카테고리의 다른 글
  • Proc Filesystem
  • Windows Server 2008 R2 초기 설정
  • 로컬에 Wordpress 설치
  • Windows Defender Off
real-again
real-again
realagin 님의 블로그 입니다.
  • real-again
    또또, 다시
    real-again
  • 전체
    오늘
    어제
    • 분류 전체보기
      • 프로젝트
        • AOS 모바일 앱 모의해킹
        • Spring Boot 웹 애플리케이션 구축
        • [ESXi]인프라 구축 및 모니터링
        • 인프라 취약점 진단 고도화
      • CVE 분석
      • 기반 지식
        • AWS
        • 인프라
        • 웹 어플리케이션
        • Android
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    aos정리
    owasp mobile top10
    콘텐츠 프로바이더
    insecure authentication/authorization
    dvm
    AWS
    splunk #esm
    Snort
    spring boot
    하드코드
    통신 과정 취약점 진단
    tocken
    EC2
    브로트캐스트
    app intsructure
    sd스토리지
    vlan
    android directory
    pfsense
    diva
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.1
real-again
pdb 도구를 이용한 python 디버깅
상단으로

티스토리툴바