Current File : //proc/self/root/kunden/usr/share/gdb/python/gdb/__pycache__/__init__.cpython-39.opt-1.pyc
a

ɱZh� �@s^ddlZddlZddlZddlZddlZddlZddlmZejdkrTddl	m
Z
nddlm
Z
ddlTddlZ
e
ejd<Gdd�de�Zee�e_ee�e_dZd	ge_gZgZgZiZgZd
d�Zdd
�Zej�ej�e ��a!gd�Z"dd�Z#e#�dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*edd ��Z+ed!d"��Z,Gd#d$�d$ej-�Z-dS)%�N)�contextmanager)��)�reload)�*z
gdb.eventsc@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�_GdbFilezUTF-8�strictcCs
||_dS�N��stream)�selfr�r
�%/usr/share/gdb/python/gdb/__init__.py�__init__,sz_GdbFile.__init__cCsdSr	r
�rr
r
r�close/sz_GdbFile.closecCsdS)NFr
rr
r
r�isatty3sz_GdbFile.isattycCs|D]}|�|�qdSr	)�write)r�iterable�liner
r
r�
writelines6sz_GdbFile.writelinescCst|jd�dS�Nr
)�flushrrr
r
rr:sz_GdbFile.flushcCst||jd�dSr)rr)r�sr
r
rr=sz_GdbFile.writeN)�__name__�
__module__�__qualname__�encoding�errorsrrrrrrr
r
r
rr'sr�cCs�t�D]8}|jD],}|jr||�}|dur||jfSqqt�jD](}|jrH||�}|durH||jfSqHtD](}|jrv||�}|durv||jfSqvdS)a�Internal function called from GDB to execute all unwinders.

    Runs each currently enabled unwinder until it finds the one that
    can unwind given frame.

    Arguments:
        pending_frame: gdb.PendingFrame instance.

    Returns:
        Tuple with:

          [0] gdb.UnwindInfo instance
          [1] Name of unwinder that claimed the frame (type `str`)

        or None, if no unwinder has claimed the frame.
    N)�objfiles�frame_unwindersZenabled�name�current_progspace)Z
pending_frameZobjfileZunwinderZunwind_infor
r
r�_execute_unwindersYs"

r$cCs�tjdj}d}t|d�s&||d<d}zTt|d��,}t|��|d�}t|||�Wd�n1sd0YW|r�|d=n|r�|d=0dS)aBThis function is used to replace Python 2's PyRun_SimpleFile.

    Loads and executes the given file.

    We could use the runpy module, but its documentation says:
    "Furthermore, any functions and classes defined by the executed code are
    not guaranteed to work correctly after a runpy function has returned."
    �__main__F�__file__T�rb�execN)�sys�modules�__dict__�hasattr�open�compile�readr()�filepath�globalsZset_file�fileZcompiledr
r
r�
_execute_file�s	
,�r3)�functionZcommandZprinterc	Cs�tD]�}tj�tj�t�|�}tj�|�rtdd�t�|��}|D]`}dt	||dd�f}z$|t
jvrvtt
|��nt
|�WqBt
j�t��d�YqB0qBqdS)NcSs|�d�o|dkS)Nz.pyz__init__.py)�endswith)�xr
r
r�<lambda>��z%_auto_load_packages.<locals>.<lambda>z%s.%s.%s����
)�packages�os�path�join�dirnamer&�exists�filter�listdirrr)r*r�
__import__�stderrr�	traceback�
format_exc)�package�locationZpy_filesZpy_file�modnamer
r
r�_auto_load_packages�s�
rJcCsLztj�t�Wnty"Yn0tj�d|�|attt��t	�dS)z3Update sys.path, reload gdb and auto-load packages.rN)
r)r=�remove�	PYTHONDIR�
ValueError�insertrrCrrJ)�dirr
r
r�GdbSetPythonDirectory�srPcCst�jS)zReturn the current Progspace.)Zselected_inferiorZ	progspacer
r
r
rr#�sr#cCs
t���S)z:Return a sequence of the current program space's objfiles.)r#r r
r
r
rr �sr cCst��|�S)zdsolib_name (Long) -> String.
Return the name of the shared library holding a given address, or None.)r#�
solib_name)�addrr
r
rrQ�srQcCst��|�S)z8Return the block containing the given pc value, or None.)r#�block_for_pc�Zpcr
r
rrS�srScCst��|�S)znfind_pc_line (pc) -> Symtab_and_line.
    Return the gdb.Symtab_and_line object corresponding to the pc value.)r#�find_pc_linerTr
r
rrU�srUcCsF|durd}nt|t�r&|r"d}nd}td|dt|�dd�dS)	z$Set the GDB parameter NAME to VALUE.NZ	unlimitedZonZoffzset � T)Z	to_string)�
isinstance�boolZexecute�str)r"�valuer
r
r�
set_parameter�s
r[c	cs8t|�}t||�zdVWt||�nt||�0dS)zYTemporarily set the GDB parameter NAME to VALUE.
    Note that this is a context manager.N)Z	parameterr[)r"rZ�	old_valuer
r
r�with_parameter�s

r]c
csdttd�sdVdStjtjtjtjh}t�tj|�}zdVWt�tj|�nt�tj|�0dS)z3A helper function that blocks and unblocks signals.�pthread_sigmaskN)	r,�signal�SIGCHLD�SIGINT�SIGALRM�SIGWINCHr^�	SIG_BLOCK�SIG_SETMASK)Zto_blockZold_maskr
r
r�blocked_signals
s
rfcs eZdZdZ�fdd�Z�ZS)�Threadz�A GDB-specific wrapper around threading.Thread

    This wrapper ensures that the new thread blocks any signals that
    must be delivered on GDB's main thread.cs4t��t���Wd�n1s&0YdSr	)rf�super�startr��	__class__r
rriszThread.start)rrr�__doc__ri�
__classcell__r
r
rjrrgsrg).r_�	threadingrEr<r)Z_gdb�
contextlibr�version_info�	importlibr�impZ
_gdbeventsZeventsr*�objectrZSTDOUT�stdoutZSTDERRrDZprompt_hook�argvZpretty_printersZ
type_printersZxmethodsZ
frame_filtersr!r$r3r=r?r&rLr;rJrPr#r rQrSrUr[r]rfrgr
r
r
r�<module>sP



'