Current File : //usr/share/gdb/python/gdb/dap/__pycache__/startup.cpython-39.pyc
a

ɱZhQ�@s�ddlZddlZddlZddlZddlZddlZe��Zdaddd�Z	dd�Z
dd�Zd	d
�ZGdd�dej
�Ze�Zd
d�Zdd�Zedd��ZGdd�de�Zdd�Zdd�ZdS)�N�cCstj|||dd�}|��dS)z�Start a new thread, invoking TARGET with *ARGS there.
    This is a helper function that ensures that any GDB signals are
    correctly blocked.T)�name�target�args�daemonN)�gdb�Thread�start)rrr�resultrr�(/usr/share/gdb/python/gdb/dap/startup.py�start_thread"srcs"td��fdd�}td|�dS)z-Start the DAP thread and invoke TARGET there.zset breakpoint pending oncst��a��dS�N��	threading�current_thread�_dap_threadr�rrr�really_start_dap0sz#start_dap.<locals>.really_start_dapZDAPN)�exec_and_logr)rrrrr�	start_dap*srcst����fdd��}|S)zAA decorator that asserts that FUNC must be run in the GDB thread.cst��tusJ��|i|��Sr
)rr�_gdb_thread�r�kwargs��funcrr�ensure_gdb_thread;sz(in_gdb_thread.<locals>.ensure_gdb_thread��	functools�wraps)rrrrr�
in_gdb_thread8srcst����fdd��}|S)zAA decorator that asserts that FUNC must be run in the DAP thread.cst��tusJ��|i|��Sr
rrrrr�ensure_dap_threadFsz(in_dap_thread.<locals>.ensure_dap_threadr)rr rrr�
in_dap_threadCsr!cs4eZdZdZdZdZdZ�fdd�Zdd�Z�Z	S)	�LoggingParamzWhether DAP logging is enabled.zSet the DAP logging status.zShow the DAP logging status.Ncst��dtjtj�d|_dS)Nzdebug dap-log-file)�super�__init__rZCOMMAND_MAINTENANCEZPARAM_OPTIONAL_FILENAME�value��self��	__class__rrr$Vs
�zLoggingParam.__init__cCs6|jdur|j��d|_|jdur2t|jd�|_dS)N�w�)�log_file�closer%�openr&rrr�get_set_string\s


zLoggingParam.get_set_string)
�__name__�
__module__�__qualname__�__doc__Zset_docZshow_docr,r$r/�
__classcell__rrr(rr"Nsr"cCs&tjdur"t|tjd�tj��dS)z5Log SOMETHING to the log file, if logging is enabled.N��file)�dap_logr,�print�flush)Z	somethingrrr�logis
r:cCstjdurtjtjd�dS)z9Log a stack trace to the log file, if logging is enabled.Nr5)r7r,�	traceback�	print_excrrrr�	log_stackps
r=cCsTtd|�z(tj|ddd�}|dkr2td|�WntjyNt�Yn0dS)zWExecute the gdb command CMD.
    If logging is enabled, log the command and its output.z+++ T)Zfrom_ttyZ	to_stringr+z>>> N)r:rZexecute�errorr=)�cmd�outputrrrrvsrc@s$eZdZdZdd�Zedd��ZdS)�Invokerz-A simple class that can invoke a gdb command.cCs
||_dSr
�r?)r'r?rrrr$�szInvoker.__init__cCst|j�dSr
)rr?r&rrr�__call__�szInvoker.__call__N)r0r1r2r3r$rrCrrrrrA�srAcCs t|t�rt|�}t�|�dS)z}Send CMD to the gdb thread.
    CMD can be either a function or a string.
    If it is a string, it is passed to gdb.execute.N)�
isinstance�strrArZ
post_eventrBrrr�send_gdb�s
rFcspt�t�rt���tjddkr8tjddkr8t���nt�����fdd�}t|���	�}t|t
�rl|�|S)z�Send FN to the gdb thread and return its result.
    If FN is a string, it is passed to gdb.execute and None is
    returned as the result.
    If FN throws an exception, this function will throw the
    same exception in the calling thread.
    r���c
sHz��}��|�Wn.tyB}z��|�WYd}~n
d}~00dSr
)Zput�	Exception)�val�e��fnZresult_qrr�message�s
z'send_gdb_with_response.<locals>.message)rDrErA�sys�version_info�queueZQueueZSimpleQueuerF�getrJ)rNrOrKrrMr�send_gdb_with_response�s


rT)r)rrrRrr;rPrrrrrrr!Z	Parameterr"r7r:r=r�objectrArFrTrrrr�<module>s(