
    J/PhJ                         d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 dZ
 ede
          Z G d d	          Zd
 ZddZedk    r e             dS dS )z:Module for displaying information about Numba's gdb set up    )
namedtupleN)dedent)configz4binary_loc, extension_loc, py_ver, np_ver, supported	_gdb_infoc                   d    e Zd ZdZd ZddZed             Zed             Z	d Z
d Zd	 Zd
 ZdS )_GDBTestWrapperzmWraps the gdb binary and has methods for checking what the gdb binary
    has support for (Python and NumPy).c                 l    t           j        }|dt           j         }t          |          || _        d S )Nz.No valid binary could be found for gdb named: )r   
GDB_BINARY
ValueError_gdb_binary)self
gdb_binarymsgs      X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/misc/numba_gdbinfo.py__init__z_GDBTestWrapper.__init__   sA    &
*'* *CS//!%     c                     | j         dg}|D ],}|                    d           |                    |           -|                    ddg           t          j        |ddd          S )Nz-qz-exqT
   )capture_outputtimeouttext)r   appendextend
subprocessrun)r   cmdgdb_callxs       r   _run_cmdz_GDBTestWrapper._run_cmd   s|    OT+ 	 	AOOE"""OOA%%%~htR#') ) ) 	)r   c                     | j         S )N)r   r   s    r   r   z_GDBTestWrapper.gdb_binary#   s    r   c                     |j         dk    S )Nr   )
returncode)clsstatuss     r   successz_GDBTestWrapper.success'   s     A%%r   c                 *    |                                  S )zChecks that gdb will launch okr!   r#   s    r   check_launchz_GDBTestWrapper.check_launch+   s    }}r   c                 2    d}|                      |f          S )NzUpython from __future__ import print_function; import sys; print(sys.version_info[:2])r*   r   r   s     r   check_pythonz_GDBTestWrapper.check_python/   s    9}}cV$$$r   c                 2    d}|                      |f          S )Nztpython from __future__ import print_function; import types; import numpy; print(isinstance(numpy, types.ModuleType))r*   r-   s     r   check_numpyz_GDBTestWrapper.check_numpy4   s    < }}cV$$$r   c                 2    d}|                      |f          S )Nzapython from __future__ import print_function; import types; import numpy;print(numpy.__version__)r*   r-   s     r   check_numpy_versionz#_GDBTestWrapper.check_numpy_version:   s    * }}cV$$$r   N)r   )__name__
__module____qualname____doc__r   r!   propertyr   classmethodr(   r+   r.   r0   r2   r   r   r   r   r      s        + +& & &) ) ) )     X  & & [&  % % %
% % %% % % % %r   r   c                  Z   d} d}d}d}d}	 t                      }|                                }|                    |          s)d|j         d|j         d|j         }t          |          |j        } |                                }|                    |          rt          j	        d|j        
                                          }||                                \  }	}
|	 d	|
 }d
}|                                }|                    |          rd|j        
                                vr~|j        
                                dk    rad
}d}|                                }|                    |          r4d|j        
                                vr|j        
                                }n# t          $ r}d| } Y d}~nd}~ww xY w|r|rd}nd}nd}d}t          j                            t          j                            t&                    |          }t)          | ||||          S )zEPrints information to stdout about the gdb setup that Numba has foundNFzNo Python supportzNo NumPy supportzgdb at 'z#' does not appear to work.
stdout: z	
stderr: z\((\d+),\s+(\d+)\).T	TracebackTrueUnknownz+Testing gdb binary failed. Reported Error: z!Full (Python and NumPy supported)z'Partial (Python only, no NumPy support)Nonezgdb_print_extension.py)r   r+   r(   r   stdoutstderrr   r.   rematchstripgroupsr0   r2   	Exceptionospathjoindirname__file__r   )	gdb_stategdb_has_pythongdb_has_numpygdb_python_versiongdb_python_numpy_versiongdb_wrapperr'   r   version_matchpymajorpyminoreprint_ext_supportedprint_ext_fileprint_ext_paths                  r   collect_gdbinforX   A   s    INM,1
#>%'' ))++""6** 	"Ik4 I I &I I9?I ICS//!*	
 ))++v&& 	>H%:%+]%8%8%:%:< <M(#0#7#7#9#9 (/%;%;'%;%;"!%$0022&&v.. 
>"&-*=*=*?*???!=..00F::,0M7@4%0%D%D%F%FF*226:: >#.fm6I6I6K6K#K#K(.(;(;(=(= %=/  F F FE!EE						F6  % 	L"E"K$ .NW\\"'//(";";^LLN Y0B-/BD D Ds   A'F. .
G8GG-   c                    t                      }t          d           d|  d}t          |d|j        fz             t          |d|j        fz             t          |d|j        fz             t          |d|j        fz             t          |d|j        fz             t          d	           t          d
           t          d|j         d           t          d           d}t          t          |                     dS )z;Displays the information collected by collect_gdbinfo.
    zP--------------------------------------------------------------------------------z%-zs : %-szBinary locationzPrint extension locationzPython versionzNumPy versionz Numba printing extension support zTTo load the Numba gdb printing extension, execute the following from the gdb prompt:z
source 
a  
    =============================================================
    IMPORTANT: Before sharing you should remove any information
    in the above that you wish to keep private e.g. paths.
    =============================================================
    N)rX   print
binary_locextension_locpy_vernp_ver	supportedr   )sep_posgdb_infofmtwarns       r   display_gdbinforg      s       H	(OOO
w


C	#"H$78
8999	#+X-CD
DEEE	#!8?3
3444	#(/2
2333	#3X5GH
HIII	"III	 ! " " "	
0h,
0
0
0111	(OOOD 
&,,r   __main__)rY   )r6   collectionsr   rF   rA   r   textwrapr   numbar   _fieldsr   r   rX   rg   r3   r   r   r   <module>rm      s    @ @ " " " " " " 				 				                 BJ{G,,	0% 0% 0% 0% 0% 0% 0% 0%fAD AD ADH   6 zO r   