<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DelphiTools.info &#187; Monitor</title>
	<atom:link href="http://delphitools.info/tag/monitor/feed/" rel="self" type="application/rss+xml" />
	<link>http://delphitools.info</link>
	<description>SamplingProfiler, DWS and other Delphi tools</description>
	<lastBuildDate>Thu, 02 Feb 2012 11:33:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Spotlight on DWS&#8217;s IDebugger</title>
		<link>http://delphitools.info/2010/12/03/spotlight-on-dwss-idebugger/</link>
		<comments>http://delphitools.info/2010/12/03/spotlight-on-dwss-idebugger/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 09:45:32 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[DWS]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Monitor]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[Real-time]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=735</guid>
		<description><![CDATA[DWScript includes a debugging facility, in the form of the IDebugger interface. The TdwsSimpleDebugger component implements that interface and can be used to simply surface the events. Debugger interface You activate a debugger by merely attaching it to a compiled script (a TdswProgram), you&#8217;ll then get notified of debugging events. Note that the events will [...]]]></description>
			<content:encoded><![CDATA[<p>DWScript includes a debugging facility, in the form of the <em>IDebugger</em> interface. The <em>TdwsSimpleDebugger</em> component implements that interface and can be used to simply surface the events.</p>
<h4>Debugger interface</h4>
<p>You activate a debugger by merely attaching it to a compiled script (a <em>TdswProgram</em>), you&#8217;ll then get notified of debugging events. Note that the events will be invoked from the thread the scripts runs in, so if you&#8217;ve got some UI updates involved f.i., you&#8217;ll have to handle the cross-thread synchronization.</p>
<ul>
<li><em><strong>StartDebug</strong></em>: invoked when the program execution (under debug) starts.</li>
<li><em><strong>DoDebug</strong></em>: invoked for each instruction by executed.</li>
<li><em><strong>StopDebug</strong></em>: invoked when the program execution (under debug) ends.</li>
<li><em><strong>EnterFunc</strong></em>: invoked when the script enters a function.</li>
<li><em><strong>LeaveFunc</strong></em>: invoked when the script enters a function.</li>
</ul>
<p>For aborting script execution, you have the standard <em>TdwsProgram.Stop</em> method.</p>
<h4>Standard debugging tasks</h4>
<p><strong>Breakpoints</strong></p>
<p>Breakpoints can be implemented by merely checking the position of the instruction you get in <em>DoDebug</em> against a reference of breakpoints (you can use a <em>TBits</em> for that). You can then suspend or check conditions (see below).</p>
<p><strong>Suspend, step</strong></p>
<p>To suspend execution, just don&#8217;t return from <em>DoDebug</em> and the script will effectively be suspended.</p>
<p>When stepping, <em>DoDebug</em> will fire on instructions, so if you step from <em>DoDebug </em>to <em>DoDebug</em>, and the user placed two instruction in the same script lines f.i., you&#8217;ll step twice on the same script line. If that isn&#8217;t desirable, you can filter and step only if the source line changed.<br />
Step into and step over can be implemented with the help of the <em>EnterFunc</em>/<em>LeaveFunc </em>notifications.</p>
<p><strong>Evaluating symbols</strong></p>
<p>If you want to evaluate a symbol, you can use <em>Expr.Prog.Table.FindSymbol()</em>, with <em>Expr </em>being the expression you got passed in the <em>DoDebug</em>. That will find the symbol in the current context (the current method if you&#8217;re in a method f.i.). You can also find a symbol from the root by going through the <em>Root </em>property.<br />
Note that <em>FindSymbol </em>will return any symbol, not just variables (<em>TDataSymbol</em>), so you can use this to evaluate functions (with side-effects) if you wish. Data symbols are stored in the stack, so the relevant part for you will be a data symbol&#8217;s stack address (<em>Addr</em>).</p>
<p>The stack is accessible via <em>Expr.Prog.Stack</em>, you&#8217;ll need it to evaluate data symbols. You can of course also use it to modify a variable (just write to the variable&#8217;s stack location).</p>
<p><strong>Call stack</strong></p>
<p>DWS 2.1: If you want the call stack, the most pragmatic approach is IME to do it via <em>EnterFunc/LeaveFunc</em>, the script call stack structure exist, but they aren&#8217;t really geared towards ease of use when debugging. So you can just maintain your own simplified call stack.</p>
<p>DWS 2.2+: StackTrace is available directly in the execution, both as a raw expression CallStack array, or via CallStackToString, as a textual version. You also have access to any script Exception call stack via the StackTrace method.</p>
<p><strong>Note on calls to Delphi-functions</strong></p>
<p>Keep in mind the debugger can only operate on the script code. If the script has invoked a Delphi function, and your execution is stuck there, the debugger won&#8217;t help. You&#8217;ll have to handle suspension in your Delphi code.</p>
<p>That&#8217;s a reason why here it&#8217;s considered a good practice to wrap calls to Delphi code with a safety net, as failure, crashes, incorrect data are the norm when scripting. Raw exposure of Delphi (or external) functions can often be problematic when the user is writing and debugging his scripts.</p>
<h4>Using the debugger for profiling</h4>
<p>You can easily make use of <em>IDebugger </em>for profiling purposes via <em>DoDebug </em>and <em>EnterFunc/LeaveFunc</em>. Instrumenting is implicitly there, so it&#8217;s just a matter of performing the timings.</p>
<p>In our mini-IDE for scripting here (not open-source), a sampling profiler is always active when running code: it periodically suspends the script, notes the current expression, call stack and resumes execution ASAP. For scripting purposes, a sampling frequency of 100 Hz is more than enough IME, and it&#8217;s low-frequency enough to have no measurable impact on the script execution time.<br />
Another cheap profiling tool is to add a function call counter (via EnterFunc), with the two combined, you can pretty much identify all bottlenecks at a glance.</p>
<p>Finally, another tool in your chest can be to implement an execution monitor with the debugger, like the one in <a href="http://delphitools.info/2009/04/15/samplingprofiler-170-still-hot-from-the-compiler/">SamplingProfiler</a>, which can be useful not just at the IDE level, but also at runtime. A typical use is to make a watchdog screen, where you can have an overview of what all the running scripts are doing: useful to diagnose in-production slowdowns, see if they&#8217;re all stuck on the same database access, shared resources, or whatever.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2010/12/03/spotlight-on-dwss-idebugger/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SamplingProfiler 1.7.0 still hot from the compiler</title>
		<link>http://delphitools.info/2009/04/15/samplingprofiler-170-still-hot-from-the-compiler/</link>
		<comments>http://delphitools.info/2009/04/15/samplingprofiler-170-still-hot-from-the-compiler/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 17:19:31 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[MAP]]></category>
		<category><![CDATA[Monitor]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[Real-time]]></category>
		<category><![CDATA[Screenshots]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=301</guid>
		<description><![CDATA[SamplingProfiler v1.7.0 is now available, you can get the zip and release details from its changelog page. As announced last week, the changes are a fix for a bug that could drastically affect the execution speed of the profiled application when relying on MAP files for debug information, if you were hit by this bug, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://delphitools.info/samplingprofiler/">SamplingProfiler</a> v1.7.0 is now available, you can get the zip and release details from its <a href="http://delphitools.info/downloads/samplingprofiler-changelog/">changelog</a> page.</p>
<p>As announced last week, the changes are a fix for a bug that could drastically affect the execution speed of the profiled application when relying on MAP files for debug information, if you were hit by this bug, things should be like night and day with this version (and hopefully I didn&#8217;t break anything else in the process&#8230;).</p>
<p style="text-align: left;">The other main addition is that of the real-time monitor, which with default parameters and when activated locally should be reachable at <a rel="nofollow" href="http://localhost:880/">http://localhost:880/</a> (see the help for other details). The monitor is still at an early stage, and only provides real-time information, as time allows, it may grow to offer more profiling and debug features.<a href="http://delphitools.info/wp-content/uploads/2009/04/monitor-1-7.png"><img class="aligncenter size-medium wp-image-303" style="margin-top: 10px; margin-bottom: 10px;" title="SamplingProfiler RealTime Monitor" src="http://delphitools.info/wp-content/uploads/2009/04/monitor-1-7-300x103.png" alt="SamplingProfiler RealTime Monitor" width="300" height="103" /></a>The current monitor page is a rather basic html page that is fully refreshed periodically, which isn&#8217;t very pretty at the moment&#8230; an XML version of the real-time information is available at <a rel="nofollow" href="http://localhost:880/sampling.xml">http://localhost:880/sampling.xml</a>, if you come up with a pretty AJAX-based version before I do, feel free to contribute it <img src='http://delphitools.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2009/04/15/samplingprofiler-170-still-hot-from-the-compiler/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MapFileStats v1.2 out and other news</title>
		<link>http://delphitools.info/2009/04/09/mapfilestats-v12-out-and-other-news/</link>
		<comments>http://delphitools.info/2009/04/09/mapfilestats-v12-out-and-other-news/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 16:50:44 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[MAP]]></category>
		<category><![CDATA[MapFileStats]]></category>
		<category><![CDATA[Monitor]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[Real-time]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://delphitools.info/?p=279</guid>
		<description><![CDATA[MapFileStats v1.2 is now available for download, it fixes reported issues and introduces a few minor improvements, such as using the ability to abort search paths scans and remembering MAP File and Search Paths options between executions. You can find the complete list in the changelog. In other news v1.7 of SamplingProfiler should be ready [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://delphitools.info/other-tools/mapfilestats/">MapFileStats v1.2</a> is now available for <a href="http://delphitools.info/downloads/mapfilestats-changelog/">download</a>, it fixes reported issues and introduces a few minor improvements, such as using the ability to abort search paths scans and remembering <em>MAP File</em> and <em>Search Paths</em> options between executions. You can find the complete list in the <a href="http://delphitools.info/downloads/mapfilestats-changelog/">changelog</a>.</p>
<p>In other news v1.7 of <a href="http://delphitools.info/samplingprofiler/">SamplingProfiler</a> should be ready &#8220;soon&#8221;. It fixes a bug that could drastically reduce the profiled application&#8217;s execution speed (when using MAP file information), and will introduce a &#8220;Real Time Monitor&#8221;, which allows to see what a profiled application is doing in real-time (unsurprisingly).<br />
 The monitor is actually a simple web server embedded into the profiler, so you can monitor an application that is run locally or on another machine. Real-time data will be accessible both as a bare-bones HTML page, or in XML form for the AJAX freaks out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://delphitools.info/2009/04/09/mapfilestats-v12-out-and-other-news/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  www.delphitools.info/tag/monitor/feed/ ) in 0.84948 seconds, on Feb 4th, 2012 at 1:38 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 5th, 2012 at 1:38 pm UTC -->
