
    Ng                         d Z ddlZddlZddlZddlZddlZddlZddlZddlZ ej	        e
          Z	 	 ddZdZd	dZdS )
a  
The Cython debugger

The current directory should contain a directory named 'cython_debug', or a
path to the cython project directory should be given (the parent directory of
cython_debug).

Additional gdb args can be provided only if a path to the project directory is
given.
    N Fc                 Z   |sst           j                            | dd          }t          j        |          }|s<t	          j        t          dt           j                            |           d           t          j	                    \  }}t          j
        |d          }	 |                    |           |                    t          j        dt          t                    z   dz                        |rn|st           j                            | dd          }	t!          |	          }
	 |
                                }|
                                 n# |
                                 w xY w|                    d	|z             |                    d
                    d |D                                  |s-|                    t          j        d|z   dz                        |                    d           |                                 n# |                                 w xY w|S )Ncython_debugzcython_debug_info_*z.
No debug files were found in z. Aborting.wa              # This is a gdb command file
            # See https://sourceware.org/gdb/onlinedocs/gdb/Command-Files.html

            set breakpoint pending on
            set print pretty on

            python
            try:
                # Activate virtualenv, if we were launched from one
                import os
                virtualenv = os.getenv('VIRTUAL_ENV')
                if virtualenv:
                    path_to_activate_this_py = os.path.join(virtualenv, 'bin', 'activate_this.py')
                    print("gdb command file: Activating virtualenv: %s; path_to_activate_this_py: %s" % (
                        virtualenv, path_to_activate_this_py))
                    with open(path_to_activate_this_py) as f:
                        exec(f.read(), dict(__file__=path_to_activate_this_py))
                from Cython.Debugger import libcython, libpython
            except Exception as ex:
                from traceback import print_exc
                print("There was an error in Python code originating from the file z")
                print("It used the Python interpreter " + str(sys.executable))
                print_exc()
                exit(1)
            end
            interpreterzfile %s

c              3       K   | ]	}d |z  V  
dS )zcy import %s
N ).0fns     Q/var/www/html/ai-engine/env/lib/python3.11/site-packages/Cython/Debugger/Cygdb.py	<genexpr>z$make_command_file.<locals>.<genexpr>V   s(      JJ.3JJJJJJ    z                    python
                    import sys
                    try:
                        gdb.lookup_type('PyModuleObject')
                    except RuntimeError:
                        sys.stderr.write(
                            "z was not compiled with debug symbols (or it was "
                            "stripped). Some functionality may not work (properly).\n")
                    end
                zsource .cygdbinit)ospathjoinglobsysexitusageabspathtempfilemkstempfdopenwritetextwrapdedentstr__file__openreadclose)path_to_debug_infoprefix_code	no_importskip_interpreterpatterndebug_filesfdtempfilenamefr   interpreter_filer   s               r   make_command_filer-      sL    P',,1-46 6 i(( 	PH#(55"'//:L*M*M*M*MO P P P  '))B
	"cA?		 !W* Z]]eYfYf+!g*j+!   	 	 	8  	) # 	3 w||$6VV#':: -"2"7"7"9"9K$**,,,,$**,,,,k1222GGDIIJJkJJJJJKKK#  )! $/)/2
) 
 
 
 
 
 GG'(((									s&   "B
H -E H E,,BH H(z0Usage: cygdb [options] [PATH [-- GDB_ARGUMENTS]]c                 d   t          j        t                    }|                    dddd           |                    dddd	d
d           |                    ddddd           |                                \  }}| (t          |          dk    r	|d
         } nt          j        } |
|dd         }| dk    rd}t          j	        }|j
        dk    rt          j        }|j
        dk    rt          j        }t          j        |           |j        }t                              d|j
                   t                              d||           t                              d| |           t%          | ||          }t                              d|j        ||           t)          |          5 }	t                              d| |	j                               t                              d|j                   t-          j        |j        d |g|z             }
t                              d!|j        |
j                   	 	 t                              d"|
j                   |
                                }t                              d#|
j        |           n# t4          $ r Y nw xY wht                              d$ |	j                               ddd           n# 1 swxY w Y   t                              d%|           t          j        |           t                              d&|           dS )'ab  
    Start the Cython debugger. This tells gdb to import the Cython and Python
    extensions (libcython.py and libpython.py) and it enables gdb's pending
    breakpoints.

    path_to_debug_info is the path to the Cython build directory
    gdb_argv is the list of options to gdb
    no_import tells cygdb whether it should import debug information
    )r   z--gdb-executablegdbz$gdb executable to use [default: gdb])destdefaulthelpz	--verbosez-v	verbositycountr   z8Verbose mode. Multiple -v options increase the verbosity)r0   actionr1   r2   z--skip-interpreterr&   F
store_truez]Do not automatically point GDB to the same interpreter used to generate debugging information)r0   r1   r5   r2   N   z--T   )levelzverbosity = %rzoptions = %r; args = %rzIDone parsing command-line options. path_to_debug_info = %r, gdb_argv = %r)r%   r&   z3Launching %s with command file: %s and gdb_argv: %sz%Command file (%s) contains: """
%s"""zSpawning %s...z-commandzSpawned %s (pid %d)z#Waiting for gdb (pid %d) to exit...z3Wait for gdb (pid %d) to exit is done. Returned: %rz%Closing temp command file with fd: %szRemoving temp command file: %szRemoved temp command file: %s)optparseOptionParserr   
add_option
parse_argslenr   curdirloggingWARNr3   INFODEBUGbasicConfigr&   loggerinfodebugr-   r/   r    r!   
subprocessPopenpidwaitKeyboardInterruptfilenoremove)r#   gdb_argvr%   parseroptionsargslogging_levelr&   r*   r   prets               r   mainrV   m   s    "///F
(E3  5 5 5 k4!G  I I I *-u\D  E E E
 ''))OWd!t99q==!%a!#8T!!	LMAAm,,,,/
KK '"3444
LL*GT:::
LL\H& & & %%7/86FH H HL KKE\8- - -	l		 Qx=|]X]__]]]$gk222gk:|DxOPP)7;>>>	BAEJJJffhhRTUTY[^___  %   	 	<oho>O>OPPPQ Q Q Q Q Q Q Q Q Q Q Q Q Q Q LL1<@@@Il
LL0,?????s8   /BK AJK
J# K"J##,KK"K)r   FF)NNF)__doc__r   r   r   r   r   rH   r:   r@   	getLogger__name__rE   r-   r   rV   r
   r   r   <module>rZ      s   	 	 
			 



         		8	$	$ 798=O O O Ob 	;G@ G@ G@ G@ G@ G@r   