Skip to content

Instantly share code, notes, and snippets.

@jorgeas80
Last active January 27, 2020 14:00
Show Gist options
  • Save jorgeas80/65bc92e689fe05ddce24438e0c5853dc to your computer and use it in GitHub Desktop.
Save jorgeas80/65bc92e689fe05ddce24438e0c5853dc to your computer and use it in GitHub Desktop.

Revisions

  1. jorgeas80 revised this gist Jan 27, 2020. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion pdb_tricks
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,12 @@
    Breakpoint 1 at /home/user/path/to/another/module/another_module.py:356
    (Pdb) c

    # Conditionally hit the breakpoint #1
    (Pdb) conditions 1 some_variable == some_value

    # Watch a variable when you are hitting breakpoint #1. And ensure the breakpoint is only hit whenever the variable takes a certain value.
    # Ref: https://stackoverflow.com/a/34620310/593722
    (Pdb) commands 1
    (com) print(some_variable)
    (com) end
    (Pdb) conditions 1 some_variable == some_value

  2. jorgeas80 revised this gist Jan 27, 2020. 1 changed file with 8 additions and 9 deletions.
    17 changes: 8 additions & 9 deletions pdb_tricks
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,15 @@
    # Watch a variable when you are hitting breakpoint #1
    # Ref: https://stackoverflow.com/a/34620310/593722
    (Pdb) commands 1
    (com) print(some_variable)
    (com) end
    (Pdb)


    # Put a breakpoint in a file that is not part of our code
    # Ref: https://stackoverflow.com/q/13589736/593722
    (Pdb) import sys
    (Pdb) sys.path.append("/home/user/path/to/another/module")
    (Pdb) import another_module
    (Pdb) b another_module:356
    Breakpoint 1 at /home/user/path/to/another/module/another_module.py:356
    (Pdb) c
    (Pdb) c

    # Watch a variable when you are hitting breakpoint #1. And ensure the breakpoint is only hit whenever the variable takes a certain value.
    # Ref: https://stackoverflow.com/a/34620310/593722
    (Pdb) commands 1
    (com) print(some_variable)
    (com) end
    (Pdb) conditions 1 some_variable == some_value
  3. jorgeas80 revised this gist Jan 27, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pdb_tricks
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Watch a variable when you are hitting breakpoint #1
    # Ref: https://docs.python.org/2/library/pdb.html#debugger-commands
    # Ref: https://stackoverflow.com/a/34620310/593722
    (Pdb) commands 1
    (com) print(some_variable)
    (com) end
  4. jorgeas80 created this gist Jan 27, 2020.
    16 changes: 16 additions & 0 deletions pdb_tricks
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # Watch a variable when you are hitting breakpoint #1
    # Ref: https://docs.python.org/2/library/pdb.html#debugger-commands
    (Pdb) commands 1
    (com) print(some_variable)
    (com) end
    (Pdb)


    # Put a breakpoint in a file that is not part of our code
    # Ref: https://stackoverflow.com/q/13589736/593722
    (Pdb) import sys
    (Pdb) sys.path.append("/home/user/path/to/another/module")
    (Pdb) import another_module
    (Pdb) b another_module:356
    Breakpoint 1 at /home/user/path/to/another/module/another_module.py:356
    (Pdb) c