Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / week_2006_10_15.html
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">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
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"$>" />
11
12    <title>Status for Andrew DeFaria: October 15, 2006 - October 21, 2006 Archives</title>
13
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" />
17 </head>
18 <body class="layout-one-column">
19    <div id="container">
20       <div id="container-inner" class="pkg">
21
22          <div id="banner">
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>
26             </div>
27          </div>
28
29          <div id="pagebody">
30             <div id="pagebody-inner" class="pkg">
31                <div id="alpha">
32                   <div id="alpha-inner" class="pkg">
33                      
34                      <p class="content-nav">
35                         <a href="http://defaria.com/blogs/Status/archives/week_2006_10_08.html">&laquo; 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 &raquo;</a>
38                      </p>
39                      
40                      
41                      
42
43                      <h2 class="date-header">October 19, 2006</h2>
44                      <a id="a000584"></a>
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">
49                               <ul>
50   <li>Changed several gpdb modules to support a db parameter for logging into an alternate database</li>
51
52   <li>Changed gpdb-devel.pl to use new interface</li>
53 </ul>
54                               
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>
57                                  
58                                  
59                               </p>
60                            </div>
61                         </div>
62                      </div>
63                      
64                      
65
66                      <h2 class="date-header">October 18, 2006</h2>
67                      <a id="a000583"></a>
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">
72                               <ul>
73   <li>Learned about sqlplus and how to speak to Oracle databases from Victor</li>
74
75   <li>Re-wrote the section about getting NIS data and managed to get gpdb_add_project to talk to Nice properly</li>
76
77   <li>Checked in working version of gpdb_add_project and the Rexec.pm module</li>
78
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>
80
81   <li>Updated my rc scripts to include support for Oracle</li>
82
83   <li>Working with Bill and Mike we determined that there is a test database for gpdb</li>
84
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>
86 </ul>
87                               
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>
90                                  
91                                  
92                               </p>
93                            </div>
94                         </div>
95                      </div>
96                      
97                      
98
99                      <h2 class="date-header">October 17, 2006</h2>
100                      <a id="a000582"></a>
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:
106
107 <blockquote>
108 <dl>
109   <dt>s</dt>
110
111   <dd>Single step. Step to the next statement stepping into any subroutines (where the source file is known and accessible).</dd>
112
113   <dt>n</dl>
114
115   <dd>Step over - if the line contains a call to a subroutine then this will step over that subroutine.</dd>
116
117   <dt>r</dt>
118
119   <dd>Return from subroutine - if, say you accidentally stepped into a subroutine or if you just want to return,</dd>
120
121   <dt>R</dt>
122
123   <dd>Rerun - start your Perl script again in the debugger with all the parms you started with.</dd>
124
125   <dt>q</dt>
126
127   <dd>quit</dd>
128
129   <dt>p &lt;variable or expression&gt;</dt>
130
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>
132
133   <dt>x &lt;variable or expression&gt;</dt>
134
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>
136
137   <dt>l (ell)</dt>
138
139   <dd>List the next windowSize lines (see below). Use "l &lt;n&gt;"  where &lt;n&gt; = a line number to list that line.</dd>
140
141   <dt>v &lt;n&gt;</dt>
142
143   <dd>View lines around &lt;n&gt;</dd>
144
145   <dt>V &lt;package&gt;</dt>
146
147   <dd>List exported subroutines and variables for &lt;package&gt; (e.g. V MyModule will is all stuff exported from MyModule).</dd>
148
149   <dt>f &lt;filename&gt;</dt>
150
151    <dd>File - switch to another file. (e.g. f MyModule) and the debugger switches to viewing MyModule.pm.</dd>
152
153   <dt>c &lt;n&gt;</dt>
154
155   <dd>Continue to line &lt;n&gt;. 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>
156
157   <dt>b &lt;n&gt; &lt;condition&gt;</dt>
158
159   <dd>Breakpoint - set a break point (or b &lt;n&gt; $name eq "Donna" which will break at line &lt;n&gt; iff $name is "Donna" (evaluated when the debugger gets to line &lt;n&gt;))
160 </dl>
161 </blockquote>
162
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>
164
165 <div class=code><pre>
166      10==> if (/(\d*).*\s+/) {
167      11      print "match!\n";
168      12      $x = $1;
169      13    }
170 </pre></div>
171
172 <p>Then I'll type in stuff like:</p>
173
174 <div class=code><pre>
175      DB<10> if (/(\d*).*\s+/) { print "1 = $1\n"; } else { print "No
176      match!\n"; }
177      No match!
178      DB<11>
179 </pre></div>
180
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>
182
183 <p>Or you can say call an arbitrary subroutine in your script:</p>
184
185 <div class=code><pre>
186        DB<2> b Rexec::ssh
187        DB<3> p Rexec::ssh
188 Rexec::ssh(/view/cmdt_x0062320/vobs/cmtools/src/misc/GPDB/bin/../../../../lib/perl/Rexec.pm:60):
189      60:         my $self = shift;
190        DB<<4>>
191 </pre></div>
192
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>
194
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:
196
197 <div class=code><pre>
198 42      sub Log {
199 43:==>    my $msg = shift;
200 44        print "$msg\n";
201
202   DB<23> s
203 main::Log(EvilTwin.pl:45):       print "$msg\n";
204   DB<24>$msg = "Now I set msg to something I want it to be"
205   DB<25>s
206 Now I set msg to something I want it to be
207 main::Log(EvilTwin.pl:47):              return;
208   DB<25>
209 </pre></div>
210
211 <p>There are all sorts of good reasons to examine (p $variable) and set ($variable = "new value") variables during debugging.</p>
212
213 <p>Finally put the following into ~/.perldb:</p>
214
215 <div class=code><pre>
216      parse_options ("windowSize=23");
217 </pre></div>
218
219 <p>This sets the window size to 23 so that 'l" lists the next 23 lines.</p>
220                               
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>
223                                  
224                                  
225                               </p>
226                            </div>
227                         </div>
228                      </div>
229                      
230                   </div>
231                </div>
232             </div>
233          </div>
234       </div>
235    </div>
236 </body>
237 </html>