
    Xh=                     ,   d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZ d dlmZmZ d dlmZmZ d dlZd dlZd dlZd dlmZ d dlZd dlZej4                  Z G d d      Zd Zd	 Zd
 Z ej@                         Z!d Z"d Z#d Z$d Z% e
       Z&d Z'd Z(d Z)ddZ*y)    )	get_frame
IS_CPYTHONIS_64BIT_PROCESS
IS_WINDOWSIS_LINUXIS_MACDebugInfoHolderLOAD_NATIVE_LIB_FLAGENV_FALSE_LOWER_VALUESForkSafeLockPYDEVD_USE_SYS_MONITORING)thread	threading)	pydev_logpydev_monkeyN)StringIOc                        e Zd ZdZdZdZdZi Zy)TracingFunctionHolderzcThis class exists just to keep some variables (so that we don't keep them in the global namespace).NT   )__name__
__module____qualname____doc___original_tracing_warn_traceback_limit_warnings_shown     [/var/www/html/myenv/lib/python3.12/site-packages/debugpy/_vendored/pydevd/pydevd_tracing.pyr   r      s    mEOr   r   c                      t        j                         } t               }t        j                  | d   | d   | d   |       |j                         S )Nr   r      )file)sysexc_infor   	tracebackprint_exceptiongetvalue)r%   ss     r    get_exception_traceback_strr*   #   s@    ||~H
Ahqk8A;!L::<r   c                     d}t         j                  rTt               }|j                  d       t	        j
                  | t         j                  |       ||j                         z   }|S )Nz
If this is needed, please check: 
http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html
to see how to restore the debug tracing back correctly.
zCall Location:
)flimitr#   )r   r   r   writer&   print_stackr(   )framemsgr)   s      r    _get_stack_strr2   *   s[    	H  --J	"#-B-S-SZ[\AJJL Jr   c                    t         rt        d      t        j                  r&t	               }||j
                  t        j                  j                  |j
                  j                  j                  j                               d   }|j                  d      rd|v r| t        j                  d       y |j                  d      sddt        |j
                        z  z   }|t        j                   vrSd	t        j                   |<   t"        j$                  j'                  |d
       t"        j$                  j)                          t        j*                  rt        j+                  |        y y )Nz@pydevd: Using sys.monitoring, sys.settrace should not be called.r   
threadpoolgeventz6Disabled internal sys.settrace from gevent threadpool.)r   pydevd_tracingz
PYDEV DEBUGGER WARNING:
sys.settrace() should not be used when the debugger is being used.
This may cause the debugger to stop working correctly.z%sr   
)r   RuntimeErrorr   r   r   f_backospathsplitextf_codeco_filenamelowerendswithr   debugr2   r   r$   stderrr.   flushr   )tracing_funcr0   filenamemessages       r    _internal_set_tracerG   :   s'    ]^^""!9ww''(;(;(G(G(M(M(OPQRSH  .8x3G'OO$\]&&Q ^ELL99:  "7"G"GGEF)99'BJJ$$w%89JJ$$&..//= /r   c                     t         rt        d      | t        _        | %t	        | t        j                         gd      dk(  ry t        j                  xs t        j                  } ||        y )Nz6SetTrace should not be used when using sys.monitoring.F)thread_identscreate_dummy_threadr   )r   r8   _last_tracing_func_thread_localrD   set_trace_to_threadsr   	get_identr   r   r$   settrace)rD   	set_traces     r    SetTracerP   `   sb     STT3?#0V=M=M=O<Pfklpqq  &77G3<<Ilr   c                  Z    	 t         j                  } t        |        y # t        $ r Y y w xY wN)rK   rD   rP   AttributeError)rD   s    r    reapply_settracerT   t   s0    6CC 	  s    	**c                      t         ry t        j                  )t        j                  t        _        t
        t        _        y y rR   )r   r   r   r$   rN   rG   r   r   r    replace_sys_set_trace_funcrV   }   s-     ..625,,/* 7r   c                  |    t         ry t        j                  %t        j                  t        _        d t        _        y y rR   )r   r   r   r$   rN   r   r   r    restore_sys_set_trace_funcrX      s/     ..:,>>26/ ;r   c                      	 t         j                  S # t        $ r Y nw xY wt        5  	 t         j                  cd d d        S # t        $ r Y nw xY wt	               } | t         _        | cd d d        S # 1 sw Y   y xY wrR   )_load_python_helper_lib__lib__rS   _lock _load_python_helper_lib_uncached)libs    r    rZ   rZ      s    &... 	 	*22   		 /0*-'  s4    	A1A	AA1AA11A:c                  h   t         j                  j                  t         j                  j                  t         j                  j	                  t
                    d      } t         j                  j                  |       st        j                  d|        d}t        r>t         j                  j                  dt         j                  j                  dd            }|s,t        j                         }|st        j                  d       y t        rd}d}d	}n?t        rd
}d}d	}n2t         rd}d}d	}n%t        j                  dt"        j                         y |j%                         dvrh	 t        j&                  |       D cg c](  }|j)                  d      s|j+                  |      s'|* }}d|z   |z   }d|z   |z   }d }	||v r!t         j                  j                  | |      }	nt        r%||v r!t         j                  j                  | |      }	nt3        |      dk(  r$t         j                  j                  | |d         }	nZ|D cg c]  }|j+                  ||z   ||z   f      r|  }
}t3        |
      dk(  r#t         j                  j                  | |d         }	|	t        j                  d|||        y t        j                  d|	|       nst4        r|}n|}t        rd}n9t         rd}d}n.t        rd}n%t        j                  dt"        j                         y t         j                  j                  | |||      }	t         j                  j                  |	      st        j                  d|	       y |	S c c}w #  t,        j.                  dk\  rt        j0                  d|        Y y xY wc c}w )Npydevd_attach_to_processz$Expected the directory: %s to exist! PROCESSOR_ARCHITEW6432PROCESSOR_ARCHITECTUREz.platform.machine() did not return valid value.z.dllamd64x86z.soz.dylibx86_64z2Unable to set trace to all threads in platform: %s)arm64rd   re   rf   i386re   attach_r   zError listing dir: %sattach_linux_r   zMUnable to set trace to all threads in arch: %s (did not find a %s lib in %s).zUsing %s lib in arch: %s.attachzExpected: %s to exist.)r:   r;   joindirnameabspath__file__existsr   criticalr   environgetplatformmachineinfor   r   r$   r?   listdir
startswithr@   r	   DEBUG_TRACE_LEVEL	exceptionlenr   )libdirarch	extension	suffix_64	suffix_32namefoundexpected_nameexpected_name_linuxrE   filteredsuffixprefixs                r    get_python_helper_lib_filenamer      s    WW\\"''//"''//(*CDF`aF77>>&!A6JD zz~~6

G_ac8de!NNKL											 	KS\\Zzz|MM	&(jj&8tdDOOI<V[_[h[hir[sTtEt "D(94-4y@E!ww||FM:H-6ww||F,?@HZ1_ww||FE!H5H */tdmmYQZEZ\ehq\qDr6stHt8}!77<<a9NNjlpr  BH  I2HdC FFFFF$FNNOQTQ]Q]^77<<FFI(NO77>>(#3X>Oo u	00A5##$;VD  us6   (M? ?M:M:(M:,M? N/%N/:M? ?+N,c                     t         r2t        j                  d d dkD  st        t        d      st        t
        v rt        j                  d       y 	 t               } | y t        j                  j                  |       }t        j                  d       |S #  t        j                  dk\  rt        j                  d        Y y xY w)Nr"   )      gettotalrefcountz4Helper lib to set tracing to all threads not loaded.z=Successfully Loaded helper lib to set tracing to all threads.r   zError loading: %s)r   r$   version_infohasattrr
   r   r   rv   r   ctypespydllLoadLibraryr	   ry   rz   )rE   r^   s     r    r]   r]     s    BQ')3*+#99MN13ll&&x0VW
,,1  3X>s   B 5B +C c           
         t         rt        d      | J d}|t        t        j                         j                               }t        j                         D ]F  }t        |dd      r|j                  |j                         ,|j                  |j                         H t        j                         }t        j                  j                  |      }||v r<t!        |      dk7  r.t#        |      }|j%                  |       |j'                  d|       |D ]  |rt        j                  vr G fddt        j(                        } |       }t        j(                  |_        |k(  r|}t        j,                  5  |t        j                  <   |t        j                  |<   |j                  k7  rt/        j0                  d       d d d        d}t        j2                         j5                          fd	fd
}	t7        j8                  t              }
 |
|	d       j5                          d t:        j<                  xs t        j>                  }tA               }|t/        jB                  d       d}e	 |jE                  tG        jH                  |      tG        jJ                  |      tG        jJ                  |       tG        jL                        tG        jJ                  d             }|dk7  st/        jB                  d|       |} |S # 1 sw Y   OxY w#  tN        jP                  dk\  rt/        jR                  d       d}Y :xY w)Nz/Should not be called when using sys.monitoring.r   pydev_do_not_traceFr   c                       e Zd Z fdZy)*set_trace_to_threads.<locals>._DummyThreadc                     | _         y rR   )_ident)selfthread_idents    r    
_set_identz5set_trace_to_threads.<locals>._DummyThread._set_identT  s
    &2r   N)r   r   r   r   )r   s   r    _DummyThreadr   S  s    3r   r   zIpydevd: creation of _DummyThread with fixed thread ident did not succeed.c                     S rR   r   )r0   eventargdummy_traces      r    r   z)set_trace_to_threads.<locals>.dummy_traces  s	    r   c                  z    t         j                  xs t        j                  }  |        j	                          y rR   )r   r   r$   rN   release)rO   r   proceeds    r    increase_tracing_countz4set_trace_to_threads.<locals>.increase_tracing_countv  s)    -??O3<<Ik"OOr   r   zPUnable to load helper lib to set tracing to all threads (unsupported python vm).z5Unable to set tracing for existing thread. Result: %sz Error attaching debugger tracing)*r   r8   setr$   _current_frameskeysr   	enumerategetattrdiscardidentaddr   rM   _activers   r{   listremoveinsertr   	__class___active_limbo_lockr   rq   allocate_lockacquirer   get_original_start_new_threadr   r   rN   rZ   rv   AttachDebuggerTracingr   c_int	py_objectc_uintr	   ry   rz   )rD   rI   rJ   rett
curr_identcurr_threadr   show_debug_infor   start_new_threadset_trace_funcr^   resultr   r   r   s                 @@@r    rL   rL   +  s    LMM###
C C//16689$$& 	+A q.6%%agg.!!!''*	+ !!#J##''
3K]"s='9Q'> ]+Z(Q
+% K! 9#4#4439#9#9 3
 !N'44:-"#K11 	x 78I%%l34?I%%j1ww,.!**+vw	x  &&(		
 (EEfM/4 /@@PCLL%';NNmnC!22LL1$$^4$$\2MM,/$$T* Q;NN#Z\bc CWK!Z Jw	x 	xb"449''(JKs    AL A4L%L"	%,M)NT)+_pydevd_bundle.pydevd_constantsr   r   r   r   r   r   r	   r
   r   r   r   "_pydev_bundle._pydev_saved_modulesr   r   _pydev_bundler   r   os.pathr:   rt   r   ior   r$   r&   rN   _original_settracer   r*   r2   rG   localrK   rP   rT   rV   rX   r\   rZ   r   r]   rL   r   r   r    <module>r      s       A 1     
 \\    >F #2)//"3 (+7 	"m`4or   