1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6 <meta name="generator" content="Movable Type 5.2.3" />
8 <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9 <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10 <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml"$>" />
12 <title>Status for Andrew DeFaria: October 15, 2006 - October 21, 2006 Archives</title>
14 <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15 <link rel="prev" href="http://defaria.com/blogs/Status/archives/week_2006_10_08.html" title="October 8, 2006 - October 14, 2006" />
16 <link rel="next" href="http://defaria.com/blogs/Status/archives/week_2006_10_22.html" title="October 22, 2006 - October 28, 2006" />
18 <body class="layout-one-column">
20 <div id="container-inner" class="pkg">
23 <div id="banner-inner" class="pkg">
24 <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
25 <h2 id="banner-description">Searchable status reports and work log</h2>
30 <div id="pagebody-inner" class="pkg">
32 <div id="alpha-inner" class="pkg">
34 <p class="content-nav">
35 <a href="http://defaria.com/blogs/Status/archives/week_2006_10_08.html">« October 8, 2006 - October 14, 2006</a> |
36 <a href="http://defaria.com/blogs/Status/">Main</a>
37 | <a href="http://defaria.com/blogs/Status/archives/week_2006_10_22.html">October 22, 2006 - October 28, 2006 »</a>
43 <h2 class="date-header">October 19, 2006</h2>
45 <div class="entry" id="entry-584">
46 <h3 class="entry-header">GPDB login</h3>
47 <div class="entry-content">
48 <div class="entry-body">
50 <li>Changed several gpdb modules to support a db parameter for logging into an alternate database</li>
52 <li>Changed gpdb-devel.pl to use new interface</li>
55 <p class="entry-footer">
56 <span class="post-footers">Posted by at 12:29 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000584.html">Permalink</a>
66 <h2 class="date-header">October 18, 2006</h2>
68 <div class="entry" id="entry-583">
69 <h3 class="entry-header">The Oracle speaks...</h3>
70 <div class="entry-content">
71 <div class="entry-body">
73 <li>Learned about sqlplus and how to speak to Oracle databases from Victor</li>
75 <li>Re-wrote the section about getting NIS data and managed to get gpdb_add_project to talk to Nice properly</li>
77 <li>Checked in working version of gpdb_add_project and the Rexec.pm module</li>
79 <li>Discovered that gpdb_add_project stumbles over some no longer existing machines in some DesignSync registries. Need to change this to send email</li>
81 <li>Updated my rc scripts to include support for Oracle</li>
83 <li>Working with Bill and Mike we determined that there is a test database for gpdb</li>
85 <li>Determined how gpdb.pm opens the database in an effort to teach it how to connect to a test database. It's currently an all or nothing thing. This needs to change.</li>
88 <p class="entry-footer">
89 <span class="post-footers">Posted by at 7:31 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000583.html">Permalink</a>
99 <h2 class="date-header">October 17, 2006</h2>
101 <div class="entry" id="entry-582">
102 <h3 class="entry-header">PerlDB Tips</h3>
103 <div class="entry-content">
104 <div class="entry-body">
105 <p>The Perl debugger is one of those valuable tools that surprisingly it seems few Perl coders know well. Here are some quick tips on using the Perl debugger. First a few explanations about commands I tend to use:
111 <dd>Single step. Step to the next statement stepping into any subroutines (where the source file is known and accessible).</dd>
115 <dd>Step over - if the line contains a call to a subroutine then this will step over that subroutine.</dd>
119 <dd>Return from subroutine - if, say you accidentally stepped into a subroutine or if you just want to return,</dd>
123 <dd>Rerun - start your Perl script again in the debugger with all the parms you started with.</dd>
129 <dt>p <variable or expression></dt>
131 <dd>Will print the contents of a variable or expression. Expressions can be Perl expressions including calls to subroutines. You can, for example, do "p 'There are " . scalar @foo . ' lines in foo';</dd>
133 <dt>x <variable or expression></dt>
135 <dd>Like p above however p will simply print out HASH for hashes whereas x will format them out. Also x will print out "undef" for things that are undefined yet p will print nothing for them.</dd>
139 <dd>List the next windowSize lines (see below). Use "l <n>" where <n> = a line number to list that line.</dd>
143 <dd>View lines around <n></dd>
145 <dt>V <package></dt>
147 <dd>List exported subroutines and variables for <package> (e.g. V MyModule will is all stuff exported from MyModule).</dd>
149 <dt>f <filename></dt>
151 <dd>File - switch to another file. (e.g. f MyModule) and the debugger switches to viewing MyModule.pm.</dd>
155 <dd>Continue to line <n>. If n is not specified then just continue until the next break point or the end of the script. Continue is like setting a temporary break point that disappears when you hit the line.</dd>
157 <dt>b <n> <condition></dt>
159 <dd>Breakpoint - set a break point (or b <n> $name eq "Donna" which will break at line <n> iff $name is "Donna" (evaluated when the debugger gets to line <n>))
163 <p>Also, at the Perl db prompt you can type in any Perl. So, for example, I often work out regex's that way. I'll be debugging a Perl script and stepping up to something like:</p>
165 <div class=code><pre>
166 10==> if (/(\d*).*\s+/) {
172 <p>Then I'll type in stuff like:</p>
174 <div class=code><pre>
175 DB<10> if (/(\d*).*\s+/) { print "1 = $1\n"; } else { print "No
181 <p>Then I can use the command history (with set -o emacs at the shell before executing perl db emacs key bindings work for me) to edit and enter that perl if statement changing the regex until it works correctly. This way I know I got the right regex. Copy and paste the new, tested, regex from the debugging session into my code then "R" to reload the debugger.</p>
183 <p>Or you can say call an arbitrary subroutine in your script:</p>
185 <div class=code><pre>
188 Rexec::ssh(/view/cmdt_x0062320/vobs/cmtools/src/misc/GPDB/bin/../../../../lib/perl/Rexec.pm:60):
189 60: my $self = shift;
193 <p>The "p Rexec::ssh" says to print the results of the following expression. The expression is a function call in to the Rexec module for the subroutine ssh. Since we just set a break point there in the previous debug command we break at the start of that subroutine and can then debug it. Note you don't want to "c Rexec::ssh" because that would continue the actual execution of your script and only stop at Rexec::ssh if that routine was actually called. Viola, you just forcefully caused the Perl interpreter to branch to this routine!</p>
195 <p>Another thing I'll frequently do is set or change variables to see how the code would proceed <b>if</b> the variables were correct (or perhaps incorrect to test error conditions). So let's say a forced execution of the subroutine Log like the above:
197 <div class=code><pre>
199 43:==> my $msg = shift;
203 main::Log(EvilTwin.pl:45): print "$msg\n";
204 DB<24>$msg = "Now I set msg to something I want it to be"
206 Now I set msg to something I want it to be
207 main::Log(EvilTwin.pl:47): return;
211 <p>There are all sorts of good reasons to examine (p $variable) and set ($variable = "new value") variables during debugging.</p>
213 <p>Finally put the following into ~/.perldb:</p>
215 <div class=code><pre>
216 parse_options ("windowSize=23");
219 <p>This sets the window size to 23 so that 'l" lists the next 23 lines.</p>
221 <p class="entry-footer">
222 <span class="post-footers">Posted by at 8:41 AM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000582.html">Permalink</a>