
    xKgJ                         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        yy)z:Module for displaying information about Numba's gdb set up    )
namedtupleN)dedent)configz4binary_loc, extension_loc, py_ver, np_ver, supported	_gdb_infoc                   V    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y
)_GDBTestWrapperzmWraps the gdb binary and has methods for checking what the gdb binary
    has support for (Python and NumPy).c                 r    t         j                  }|dt         j                   }t        |      || _        y )Nz.No valid binary could be found for gdb named: )r   
GDB_BINARY
ValueError_gdb_binary)self
gdb_binarymsgs      \/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/misc/numba_gdbinfo.py__init__z_GDBTestWrapper.__init__   s;    &&
C''(*CS/!%    c                     | j                   dg}|D ]$  }|j                  d       |j                  |       & |j                  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^    OOT+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                 "    | j                         S )zChecks that gdb will launch okr    r"   s    r   check_launchz_GDBTestWrapper.check_launch+   s    }}r   c                 *    d}| j                  |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                 *    d}| j                  |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                 *    d}| j                  |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) )__name__
__module____qualname____doc__r   r    propertyr   classmethodr'   r*   r-   r/   r1   r2   r   r   r   r      sM    +&)     & &%
%%r   r   c                  (   d} d}d}d}d}	 t               }|j                         }|j                  |      s4d|j                   d|j                   d|j
                   }t        |      |j                  } |j                         }|j                  |      rt        j                  d|j                  j                               }||j                         \  }	}
|	 d	|
 }d
}|j                         }|j                  |      rd|j
                  j                         vry|j                  j                         dk(  r\d
}d}|j                         }|j                  |      r7d|j
                  j                         vr|j                  j                         }	 |r|rd}nd}nd}d}t        j                   j#                  t        j                   j%                  t&              |      }t)        | ||||      S # t        $ r}d| } Y d}~qd}~ww xY w)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groupsr/   r1   	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*k445 6  &jICS/!**	
 ))+v&HH%:%+]]%8%8%:<M(#0#7#7#9 (/y'%;"!%$002&&v."&--*=*=*??!==..0F:,0M7@4%0%D%D%FF*226:#.fmm6I6I6K#K(.(;(;(= %= "E"K$ .NWW\\"''//(";^LN Y0B-/BD DQ  FA!E	Fs   A+G9 9	HHH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        |             y)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_gdbinforf      s      H	(Owiw
C	#"H$7$78
89	#+X-C-CD
DE	#!8??3
34	#(//2
23	#3X5G5GH
HI	"I	 ! "	Ih,,-R
01	(OD 
&,r   __main__)-   )r6   collectionsr   rF   rA   r   textwrapr   numbar   _fieldsr   r   rX   rf   r3   r2   r   r   <module>rm      s[    @ " 	 	    B{G,	0% 0%fADH6 z r   