@@ -315,7 +315,14 @@ def _gdbserver_port(gdbserver, ssh):
315
315
316
316
# Process /bin/bash created; pid = 14366
317
317
# Listening on port 34816
318
- process_created = gdbserver .recvline ()
318
+ process_created = gdbserver .recvline (timeout = 3 )
319
+
320
+ if not process_created :
321
+ log .error (
322
+ 'No output from gdbserver after 3 seconds. Try setting the SHELL=/bin/sh '
323
+ 'environment variable or using the env={} argument if you are affected by '
324
+ 'https://sourceware.org/bugzilla/show_bug.cgi?id=26116'
325
+ )
319
326
320
327
if process_created .startswith (b'ERROR:' ):
321
328
raise ValueError (
@@ -645,7 +652,10 @@ def __init__(self, conn, *args, **kwargs):
645
652
"""
646
653
# Creates a real breakpoint and connects it with this mirror
647
654
self .conn = conn
648
- self .server_breakpoint = conn .root .set_breakpoint (
655
+ self .server_breakpoint = self ._server_set_breakpoint (* args , ** kwargs )
656
+
657
+ def _server_set_breakpoint (self , * args , ** kwargs ):
658
+ return self .conn .root .set_breakpoint (
649
659
self , hasattr (self , 'stop' ), * args , ** kwargs )
650
660
651
661
def __getattr__ (self , item ):
@@ -663,25 +673,43 @@ def __getattr__(self, item):
663
673
raise AttributeError ()
664
674
return getattr (self .server_breakpoint , item )
665
675
676
+ def __setattr__ (self , name , value ):
677
+ """Set attributes of the real breakpoint."""
678
+ if name in (
679
+ 'enabled' ,
680
+ 'silent' ,
681
+ 'thread' ,
682
+ 'task' ,
683
+ 'ignore_count' ,
684
+ 'hit_count'
685
+ 'condition' ,
686
+ 'commands' ,
687
+ ):
688
+ return setattr (self .server_breakpoint , name , value )
689
+ return super ().__setattr__ (name , value )
690
+
666
691
def exposed_stop (self ):
667
692
# Handle stop() call from the server.
668
693
return self .stop ()
669
694
670
- class FinishBreakpoint :
695
+ class FinishBreakpoint ( Breakpoint ) :
671
696
"""Mirror of ``gdb.FinishBreakpoint`` class.
672
697
673
698
See https://sourceware.org/gdb/onlinedocs/gdb/Finish-Breakpoints-in-Python.html
674
699
for more information.
675
700
"""
676
701
677
- def __init__ (self , conn , * args , ** kwargs ):
702
+ def __init__ (self , * args , ** kwargs ):
678
703
"""Do not create instances of this class directly.
679
704
680
705
Use ``pwnlib.gdb.Gdb.FinishBreakpoint`` instead.
681
706
"""
682
- # Creates a real finish breakpoint and connects it with this mirror
683
- self .conn = conn
684
- self .server_breakpoint = conn .root .set_finish_breakpoint (
707
+ # See https://github.com/pylint-dev/pylint/issues/4228
708
+ # pylint: disable=useless-super-delegation
709
+ super ().__init__ (* args , ** kwargs )
710
+
711
+ def _server_set_breakpoint (self , * args , ** kwargs ):
712
+ return self .conn .root .set_finish_breakpoint (
685
713
self , hasattr (self , 'stop' ), hasattr (self , 'out_of_scope' ),
686
714
* args , ** kwargs )
687
715
@@ -701,10 +729,6 @@ def __getattr__(self, item):
701
729
raise AttributeError ()
702
730
return getattr (self .server_breakpoint , item )
703
731
704
- def exposed_stop (self ):
705
- # Handle stop() call from the server.
706
- return self .stop ()
707
-
708
732
def exposed_out_of_scope (self ):
709
733
# Handle out_of_scope() call from the server.
710
734
return self .out_of_scope ()
0 commit comments