home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _8769022ba416bc7dfcd562c929237db7 < prev    next >
Text File  |  2000-03-23  |  11KB  |  283 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>DB - programmatic interface to the Perl debugging API (draft, subject to
  5. change)</TITLE>
  6. <LINK REL="stylesheet" HREF="../Active.css" TYPE="text/css">
  7. <LINK REV="made" HREF="mailto:">
  8. </HEAD>
  9.  
  10. <BODY>
  11. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  12. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  13. <STRONG><P CLASS=block> DB - programmatic interface to the Perl debugging API (draft, subject to
  14. change)</P></STRONG>
  15. </TD></TR>
  16. </TABLE>
  17.  
  18. <A NAME="__index__"></A>
  19. <!-- INDEX BEGIN -->
  20.  
  21. <UL>
  22.  
  23.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  24.  
  25.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  26.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  27.     <UL>
  28.  
  29.         <LI><A HREF="#global variables">Global Variables</A></LI>
  30.         <LI><A HREF="#api methods">API Methods</A></LI>
  31.         <LI><A HREF="#client callback methods">Client Callback Methods</A></LI>
  32.     </UL>
  33.  
  34.     <LI><A HREF="#bugs">BUGS</A></LI>
  35.     <LI><A HREF="#author">AUTHOR</A></LI>
  36. </UL>
  37. <!-- INDEX END -->
  38.  
  39. <HR>
  40. <P>
  41. <H1><A NAME="name">NAME</A></H1>
  42. <P>DB - programmatic interface to the Perl debugging API (draft, subject to
  43. change)</P>
  44. <P>
  45. <HR>
  46. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  47. <UL>
  48. <LI>Linux</LI>
  49. <LI>Solaris</LI>
  50. <LI>Windows</LI>
  51. </UL>
  52. <HR>
  53. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  54. <PRE>
  55.     package CLIENT;
  56.     use DB;
  57.     @ISA = qw(DB);</PRE>
  58. <PRE>
  59.     # these (inherited) methods can be called by the client</PRE>
  60. <PRE>
  61.     CLIENT->register()      # register a client package name
  62.     CLIENT->done()          # de-register from the debugging API
  63.     CLIENT->skippkg('hide::hide')  # ask DB not to stop in this package
  64.     CLIENT->cont([WHERE])       # run some more (until BREAK or another breakpt)
  65.     CLIENT->step()              # single step
  66.     CLIENT->next()              # step over
  67.     CLIENT->ret()               # return from current subroutine
  68.     CLIENT->backtrace()         # return the call stack description
  69.     CLIENT->ready()             # call when client setup is done
  70.     CLIENT->trace_toggle()      # toggle subroutine call trace mode
  71.     CLIENT->subs([SUBS])        # return subroutine information
  72.     CLIENT->files()             # return list of all files known to DB
  73.     CLIENT->lines()             # return lines in currently loaded file
  74.     CLIENT->loadfile(FILE,LINE) # load a file and let other clients know
  75.     CLIENT->lineevents()        # return info on lines with actions
  76.     CLIENT->set_break([WHERE],[COND])
  77.     CLIENT->set_tbreak([WHERE])
  78.     CLIENT->clr_breaks([LIST])
  79.     CLIENT->set_action(WHERE,ACTION)
  80.     CLIENT->clr_actions([LIST])
  81.     CLIENT->evalcode(STRING)  # eval STRING in executing code's context
  82.     CLIENT->prestop([STRING]) # execute in code context before stopping
  83.     CLIENT->poststop([STRING])# execute in code context before resuming</PRE>
  84. <PRE>
  85.     # These methods will be called at the appropriate times.
  86.     # Stub versions provided do nothing.
  87.     # None of these can block.</PRE>
  88. <PRE>
  89.     CLIENT->init()          # called when debug API inits itself
  90.     CLIENT->stop(FILE,LINE) # when execution stops
  91.     CLIENT->idle()          # while stopped (can be a client event loop)
  92.     CLIENT->cleanup()       # just before exit
  93.     CLIENT->output(LIST)    # called to print any output that API must show</PRE>
  94. <P>
  95. <HR>
  96. <H1><A NAME="description">DESCRIPTION</A></H1>
  97. <P>Perl debug information is frequently required not just by debuggers,
  98. but also by modules that need some ``special'' information to do their
  99. job properly, like profilers.</P>
  100. <P>This module abstracts and provides all of the hooks into Perl internal
  101. debugging functionality, so that various implementations of Perl debuggers
  102. (or packages that want to simply get at the ``privileged'' debugging data)
  103. can all benefit from the development of this common code.  Currently used
  104. by Swat, the perl/Tk GUI debugger.</P>
  105. <P>Note that multiple ``front-ends'' can latch into this debugging API
  106. simultaneously.  This is intended to facilitate things like
  107. debugging with a command line and GUI at the same time, debugging 
  108. debuggers etc.  [Sounds nice, but this needs some serious support -- GSAR]</P>
  109. <P>In particular, this API does <STRONG>not</STRONG> provide the following functions:</P>
  110. <UL>
  111. <LI>
  112. data display
  113. <P></P>
  114. <LI>
  115. command processing
  116. <P></P>
  117. <LI>
  118. command alias management
  119. <P></P>
  120. <LI>
  121. user interface (tty or graphical)
  122. <P></P></UL>
  123. <P>These are intended to be services performed by the clients of this API.</P>
  124. <P>This module attempts to be squeaky clean w.r.t <CODE>use strict;</CODE> and when
  125. warnings are enabled.</P>
  126. <P>
  127. <H2><A NAME="global variables">Global Variables</A></H2>
  128. <P>The following ``public'' global names can be read by clients of this API.
  129. Beware that these should be considered ``readonly''.</P>
  130. <DL>
  131. <DT><STRONG><A NAME="item_%24DB%3A%3Asub">$DB::sub</A></STRONG><BR>
  132. <DD>
  133. Name of current executing subroutine.
  134. <P></P>
  135. <DT><STRONG><A NAME="item_%DB::sub">%DB::sub</A></STRONG><BR>
  136. <DD>
  137. The keys of this hash are the names of all the known subroutines.  Each value
  138. is an encoded string that has the <A HREF="../lib/Pod/perlfunc.html#item_sprintf"><CODE>sprintf(3)</CODE></A> format 
  139. <CODE>("%s:%d-%d", filename, fromline, toline)</CODE>.
  140. <P></P>
  141. <DT><STRONG><A NAME="item_%24DB%3A%3Asingle">$DB::single</A></STRONG><BR>
  142. <DD>
  143. Single-step flag.  Will be true if the API will stop at the next statement.
  144. <P></P>
  145. <DT><STRONG><A NAME="item_%24DB%3A%3Asignal">$DB::signal</A></STRONG><BR>
  146. <DD>
  147. Signal flag. Will be set to a true value if a signal was caught.  Clients may
  148. check for this flag to abort time-consuming operations.
  149. <P></P>
  150. <DT><STRONG><A NAME="item_%24DB%3A%3Atrace">$DB::trace</A></STRONG><BR>
  151. <DD>
  152. This flag is set to true if the API is tracing through subroutine calls.
  153. <P></P>
  154. <DT><STRONG><A NAME="item_%40DB%3A%3Aargs">@DB::args</A></STRONG><BR>
  155. <DD>
  156. Contains the arguments of current subroutine, or the <CODE>@ARGV</CODE> array if in the 
  157. toplevel context.
  158. <P></P>
  159. <DT><STRONG><A NAME="item_%40DB%3A%3Adbline">@DB::dbline</A></STRONG><BR>
  160. <DD>
  161. List of lines in currently loaded file.
  162. <P></P>
  163. <DT><STRONG><A NAME="item_%DB::dbline">%DB::dbline</A></STRONG><BR>
  164. <DD>
  165. Actions in current file (keys are line numbers).  The values are strings that
  166. have the <A HREF="../lib/Pod/perlfunc.html#item_sprintf"><CODE>sprintf(3)</CODE></A> format <CODE>("%s\000%s", breakcondition, actioncode)</CODE>.
  167. <P></P>
  168. <DT><STRONG><A NAME="item_%24DB%3A%3Apackage">$DB::package</A></STRONG><BR>
  169. <DD>
  170. Package namespace of currently executing code.
  171. <P></P>
  172. <DT><STRONG><A NAME="item_%24DB%3A%3Afilename">$DB::filename</A></STRONG><BR>
  173. <DD>
  174. Currently loaded filename.
  175. <P></P>
  176. <DT><STRONG><A NAME="item_%24DB%3A%3Asubname">$DB::subname</A></STRONG><BR>
  177. <DD>
  178. Fully qualified name of currently executing subroutine.
  179. <P></P>
  180. <DT><STRONG><A NAME="item_%24DB%3A%3Alineno">$DB::lineno</A></STRONG><BR>
  181. <DD>
  182. Line number that will be executed next.
  183. <P></P></DL>
  184. <P>
  185. <H2><A NAME="api methods">API Methods</A></H2>
  186. <P>The following are methods in the DB base class.  A client must
  187. access these methods by inheritance (*not* by calling them directly),
  188. since the API keeps track of clients through the inheritance
  189. mechanism.</P>
  190. <DL>
  191. <DT><STRONG><A NAME="item_register">CLIENT-><CODE>register()</CODE></A></STRONG><BR>
  192. <DD>
  193. register a client object/package
  194. <P></P>
  195. <DT><STRONG><A NAME="item_evalcode">CLIENT-><CODE>evalcode(STRING)</CODE></A></STRONG><BR>
  196. <DD>
  197. eval STRING in executing code context
  198. <P></P>
  199. <DT><STRONG><A NAME="item_skippkg">CLIENT-><CODE>skippkg('D::hide')</CODE></A></STRONG><BR>
  200. <DD>
  201. ask DB not to stop in these packages
  202. <P></P>
  203. <DT><STRONG><A NAME="item_run">CLIENT-><CODE>run()</CODE></A></STRONG><BR>
  204. <DD>
  205. run some more (until a breakpt is reached)
  206. <P></P>
  207. <DT><STRONG><A NAME="item_step">CLIENT-><CODE>step()</CODE></A></STRONG><BR>
  208. <DD>
  209. single step
  210. <P></P>
  211. <DT><STRONG><A NAME="item_next">CLIENT-><CODE>next()</CODE></A></STRONG><BR>
  212. <DD>
  213. step over
  214. <P></P>
  215. <DT><STRONG><A NAME="item_done">CLIENT-><CODE>done()</CODE></A></STRONG><BR>
  216. <DD>
  217. de-register from the debugging API
  218. <P></P></DL>
  219. <P>
  220. <H2><A NAME="client callback methods">Client Callback Methods</A></H2>
  221. <P>The following ``virtual'' methods can be defined by the client.  They will
  222. be called by the API at appropriate points.  Note that unless specified
  223. otherwise, the debug API only defines empty, non-functional default versions
  224. of these methods.</P>
  225. <DL>
  226. <DT><STRONG><A NAME="item_init">CLIENT-><CODE>init()</CODE></A></STRONG><BR>
  227. <DD>
  228. Called after debug API inits itself.
  229. <P></P>
  230. <DT><STRONG><A NAME="item_prestop">CLIENT-><CODE>prestop([STRING])</CODE></A></STRONG><BR>
  231. <DD>
  232. Usually inherited from DB package.  If no arguments are passed,
  233. returns the prestop action string.
  234. <P></P>
  235. <DT><STRONG><A NAME="item_stop">CLIENT-><CODE>stop()</CODE></A></STRONG><BR>
  236. <DD>
  237. Called when execution stops (w/ args file, line).
  238. <P></P>
  239. <DT><STRONG><A NAME="item_idle">CLIENT-><CODE>idle()</CODE></A></STRONG><BR>
  240. <DD>
  241. Called while stopped (can be a client event loop).
  242. <P></P>
  243. <DT><STRONG><A NAME="item_poststop">CLIENT-><CODE>poststop([STRING])</CODE></A></STRONG><BR>
  244. <DD>
  245. Usually inherited from DB package.  If no arguments are passed,
  246. returns the poststop action string.
  247. <P></P>
  248. <DT><STRONG>CLIENT-><CODE>evalcode(STRING)</CODE></STRONG><BR>
  249. <DD>
  250. Usually inherited from DB package.  Ask for a STRING to be <A HREF="../lib/Pod/perlfunc.html#item_eval"><CODE>eval</CODE></A>-ed
  251. in executing code context.
  252. <P></P>
  253. <DT><STRONG><A NAME="item_cleanup">CLIENT-><CODE>cleanup()</CODE></A></STRONG><BR>
  254. <DD>
  255. Called just before exit.
  256. <P></P>
  257. <DT><STRONG><A NAME="item_output">CLIENT-><CODE>output(LIST)</CODE></A></STRONG><BR>
  258. <DD>
  259. Called when API must show a message (warnings, errors etc.).
  260. <P></P></DL>
  261. <P>
  262. <HR>
  263. <H1><A NAME="bugs">BUGS</A></H1>
  264. <P>The interface defined by this module is missing some of the later additions
  265. to perl's debugging functionality.  As such, this interface should be considered
  266. highly experimental and subject to change.</P>
  267. <P>
  268. <HR>
  269. <H1><A NAME="author">AUTHOR</A></H1>
  270. <P>Gurusamy Sarathy    <A HREF="mailto:gsar@activestate.com">gsar@activestate.com</A></P>
  271. <P>This code heavily adapted from an early version of perl5db.pl attributable
  272. to Larry Wall and the Perl Porters.</P>
  273. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  274. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  275. <STRONG><P CLASS=block> DB - programmatic interface to the Perl debugging API (draft, subject to
  276. change)</P></STRONG>
  277. </TD></TR>
  278. </TABLE>
  279.  
  280. </BODY>
  281.  
  282. </HTML>
  283.