<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for gary</title>
    <link>http://www.advogato.org/person/gary/</link>
    <description>Advogato blog for gary</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Wed, 22 May 2013 22:12:19 GMT</pubDate>
    <item>
      <pubDate>Fri, 10 May 2013 10:19:26 GMT</pubDate>
      <title>VM networking tip</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=268</link>
      <guid>http://gbenson.net/?p=379</guid>
      <description>&lt;p&gt;If you are setting up VMs using &lt;a href="http://libvirt.org/" &gt;libvirt&lt;/a&gt; then it&#x2019;s a good idea to change the address of the virtual network to something other than the default.  Why?  Because if you don&#x2019;t, and you create a guest which itself starts up libvirt &lt;em&gt;and&lt;/em&gt; uses &lt;a href="http://projects.gnome.org/NetworkManager/" &gt;NetworkManager&lt;/a&gt; then at least some of the time your VM will start up with its networking hosed.&lt;/p&gt;
&lt;p&gt;If the host is using the default network (192.168.122.0/24) and the guests also want to use that network then there is a race between NetworkManager bringing up eth0 and libvirt bringing up virbr0.  libvirt checks for existing interfaces using the network it is configured for before starting up virbr0, so if NetworkManager brings up eth0 first then virbr0 will not be set up on the guest and everything will be fine.  But, if eth0 is not set up by the time libvirt runs the check, then virbr0 will take 192.168.122.0/24, then eth0 will come up on 192.168.122.something, and you&#x2019;ll have a VM with two separate interfaces connected to two separate networks that both have the same address range&#x2026; and it won&#x2019;t work!&lt;/p&gt;
&lt;p&gt;The easy way to solve this is to not install libvirt on the guest, but you may not be able to change this until after the guest is running, and if libvirt starts up during a guest&#x2019;s installer then you may need to complete parts of the installation with no networking.  This may or may not be ok for you and your OS.  I&#x2019;m using VMs to set up clean test environments for GDB, and at the moment I&#x2019;m setting up three or four new &#x201C;machines&#x201D; every day (and throwing them away when I&#x2019;m done) so I want the process as streamlined as possible.  If you only occasionally set up new VMs then some extra tasks during the installation may not be a problem, but it is pretty simple to change the network on the host and you only have to do it once:
&lt;/p&gt;&lt;ol&gt;&lt;li&gt;As root, run &lt;code&gt;virsh net-edit default&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Change every occurence of &lt;code&gt;192.168.122&lt;/code&gt; to something else&lt;/li&gt;
&lt;li&gt;Stop any running guests&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;virsh net-destroy default&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;virsh net-start default&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;It&#x2019;s a shame this can&#x2019;t be fixed more conclusively elsewhere, but NetworkManager brings up the interfaces asynchronously at boot time which makes it impossible to definitively schedule libvirt&#x2019;s startup to happen after NetworkManager.&lt;/p&gt;
&lt;p&gt;Thank you &lt;a href="http://fedoraproject.org/wiki/User:Laine" &gt;Laine&#xA0;Stump&lt;/a&gt; for helping me out with this.&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Wed, 8 May 2013 20:14:14 GMT</pubDate>
      <title>Only dest dir longer than base dir not supported</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=267</link>
      <guid>http://gbenson.net/?p=367</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Have you experienced the mysterious error, &#x201C;Only dest dir longer than base dir not supported&#x201D;?&lt;/p&gt;
&lt;p&gt;I have.&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;The Problem&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;When you build an rpm, the code is built in &lt;code&gt;%{_builddir}&lt;/code&gt;, which usually evaluates as &lt;code&gt;%{_topdir}/BUILD&lt;/code&gt;, which in turn evaluates as something like &lt;code&gt;/home/you/rpmbuild/BUILD&lt;/code&gt;.  The built code (if built with GCC) ends up with loads of &lt;code&gt;/home/you/rpmbuild/BUILD&lt;/code&gt; paths embedded in it, and the script &lt;code&gt;/usr/lib/rpm/debugedit&lt;/code&gt; rewrites these paths to &lt;code&gt;/usr/src/debug&lt;/code&gt; so that the debuginfo rpms work. &lt;code&gt;/usr/lib/rpm/debugedit&lt;/code&gt; cannot extend strings, it can only shrink them.  If you are seeing &#x201C;Only dest dir longer than base dir not supported&#x201D; then, somewhere in your build system, &lt;code&gt;%{_builddir}&lt;/code&gt; is defined as something that expands to a string shorter than &lt;code&gt;/usr/src/debug&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;In my case, I was building a glibc rpm in a VM that turned out not to have enough disk.  I created a new disk, mounted it on &lt;code&gt;/mnt&lt;/code&gt;, and added the line &lt;code&gt;%_topdir /mnt&lt;/code&gt; to my &lt;code&gt;~/.rpmmacros&lt;/code&gt;.  The result?  &#x201C;Only dest dir longer than base dir not supported&#x201D;.  I fixed it by editing &lt;code&gt;~/.rpmmacros&lt;/code&gt; to say &lt;code&gt;%_topdir /mnt/rpmbuild&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Briefly&lt;/strong&gt;
&lt;/p&gt;&lt;pre&gt;/usr/src/debug       # the reference
/mnt/BUILD           # too short!
/mnt/rpmbuild/BUILD  # plenty long enough&lt;/pre&gt;
&lt;p&gt;Thank you,&lt;br/&gt;
The Mgt.&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Wed, 1 May 2013 10:25:38 GMT</pubDate>
      <title>Saving money</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=266</link>
      <guid>http://gbenson.net/?p=353</guid>
      <description>&lt;p&gt;I have a pair of set-top&#xA0;box PCs I&#x2019;ve been using as always-on servers.  I used them because they&#x2019;re silent, but lately I&#x2019;ve been thinking about power consumption.  They were pretty good when I bought them in 2006 and 2008, but there&#x2019;s much better stuff available now.  I spent &#xA3;60 on a &lt;a href="http://www.raspberrypi.org/faqs" &gt;Raspberry&#xA0;Pi&lt;/a&gt; and some supporting bits; given that it uses roughly a tenth the power of &lt;i&gt;one&lt;/i&gt; of the set-top boxes it will have paid for itself in about two months.&lt;/p&gt;
&lt;p&gt;While reorganising everything I also decommissioned an old Netgear switch which was likely costing &#xA3;100 a year to run.  Maybe it&#x2019;s time you looked in your networking cupboard too!&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 19 Apr 2013 15:14:03 GMT</pubDate>
      <title>ath9k_htc drivers for RHEL 6.4</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=265</link>
      <guid>http://gbenson.net/?p=342</guid>
      <description>&lt;p&gt;This morning I packaged up ath9k_htc drivers for RHEL&#xA0;6.4.  This isn&#x2019;t anything official, just something I knocked together. I&#x2019;m using it with a TP-LINK&#xA0;TL-WN722N and kernel-2.6.32-358.2.1.el6.x86_64; it seems to work but your mileage may vary!  RPMs &lt;a href="http://inauspicious.org/files/ath9k_htc/" &gt;here&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Wed, 15 Aug 2012 09:12:06 GMT</pubDate>
      <title>Because I never remember how to use OProfile</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=264</link>
      <guid>http://gbenson.net/?p=325</guid>
      <description>&lt;pre&gt;sudo opcontrol --reset
sudo opcontrol --start
&lt;i&gt;# the thing you want to profile&lt;/i&gt;
sudo opcontrol --stop
opreport -l | less&lt;/pre&gt;</description>
    </item>
    <item>
      <pubDate>Mon, 26 Mar 2012 14:08:29 GMT</pubDate>
      <title>Easy things to do with GDB #1</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=263</link>
      <guid>http://gbenson.net/?p=313</guid>
      <description>&lt;p&gt;I&#x2019;ve been meaning to write some introductory articles to GDB ever since back in February at &lt;a href="http://fosdem.org/2012/" &gt;FOSDEM&lt;/a&gt;, where I was surprised by just how many people do not use GDB&#x2013;or even know what it is!  It&#x2019;s taken me a while to figure out a nice example, but I finally found them.&lt;/p&gt;
&lt;p&gt;Last week I wanted to extend &lt;code&gt;ogg123&lt;/code&gt;, a tool for playing music files on the commandline.  It supports several formats&#x2013;Ogg Vorbis, FLAC and Speex&#x2013;and the way it abstracts that is by passing around a &lt;code&gt;struct&#xA0;format_t&lt;/code&gt; full of function pointers to various callbacks.  I was adding a new format, and wanted to know what kind of arguments it was calling its callbacks with.  I &lt;em&gt;could&lt;/em&gt; have tried to figure it out by reading the code, but it was easier to just run it in GDB and see what was happening.  Here&#x2019;s how:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Build a copy of ogg123 with debugging support:
&lt;pre&gt;wget http://downloads.xiph.org/releases/vorbis/vorbis-tools-1.4.0.tar.gz
tar xf vorbis-tools-1.4.0.tar.gz
cd vorbis-tools-1.4.0
CFLAGS="-g -O0" ./configure
make&lt;/pre&gt;
&lt;p&gt;The important bit here is the &lt;code&gt;CFLAGS="-g -O0"&lt;/code&gt;.  This causes &lt;code&gt;configure&lt;/code&gt; to pass these extra options to GCC in the makefiles it generates.  &lt;code&gt;-g&lt;/code&gt; instructs GCC to include debugging information in the files it generates to allow GDB to relate the executable files you&#x2019;re debugging to the source files they were generated from. &lt;code&gt;-O0&lt;/code&gt; instructs GCC not to optimise the code, which makes for easier debugging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Start up GDB on the &lt;code&gt;ogg123&lt;/code&gt; you just built:
&lt;pre&gt;gdb -args ogg123/ogg123 ~/music/Various/Disco\ Demands/4-08\ -\ Give\ It\ Up.flac&lt;/pre&gt;
&lt;p&gt;Everything after the &lt;code&gt;-args&lt;/code&gt; option is the command you&#x2019;d normally type to run the program.  GDB will print out some stuff as it starts up, then present you with a &lt;code&gt;(gdb)&lt;/code&gt; prompt and wait for you to enter some commands:
&lt;/p&gt;&lt;pre&gt;GNU gdb (GDB) 7.4.50.20120313-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
&amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;...
Reading symbols from /home/gary/vorbis-tools/ogg123/ogg123...done.
(gdb) &amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Ok, the callback I&#x2019;m interested in is the &#x201C;read&#x201D; callback, and we&#x2019;re playing a FLAC file so the callback is called &lt;code&gt;flac_read&lt;/code&gt;.  I&#x2019;d like to run the program until &lt;code&gt;flac_read&lt;/code&gt; is called, so I set a &lt;em&gt;breakpoint&lt;/em&gt; on &lt;code&gt;flac_read&lt;/code&gt; by entering &lt;code&gt;break&#xA0;flac_read&lt;/code&gt; and then using the &lt;code&gt;run&lt;/code&gt; command to set &lt;code&gt;ogg123&lt;/code&gt; going:
&lt;pre&gt;(gdb) &lt;b&gt;break flac_read&lt;/b&gt;
Breakpoint 1 at 0x40dde5: file flac_format.c, line 253.
(gdb) &lt;b&gt;run&lt;/b&gt;
Starting program: /home/gary/vorbis-tools/ogg123/ogg123 /home/gary/music/Various/Disco\ Demands/4-08\ -\ Give\ It\ Up.flac
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffeb863700 (LWP 10312)]
[Thread 0x7fffeb863700 (LWP 10312) exited]

Audio Device:   PulseAudio Output

Playing: /home/gary/music/Various/Disco Demands/4-08 - Give It Up.flac

Breakpoint 1, flac_read (decoder=0x637560, ptr=0x6182a0, nbytes=30240,
    eos=0x7fffffffe37c, audio_fmt=0x7fffffffe380) at flac_format.c:253
253	  flac_private_t *priv = decoder-&amp;gt;private;
(gdb)&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;GDB now has a running copy of &lt;code&gt;ogg123&lt;/code&gt; stopped at the very start of &lt;code&gt;flac_read&lt;/code&gt;.  Pretty jazzy huh?  You can see the values of the arguments in the second-to-last line it printed, so for example you can see that the caller has requested to read 30240 bytes of data.  The various structures (&lt;code&gt;decoder=0x637560&lt;/code&gt; etc) aren&#x2019;t so useful as they&#x2019;re pointers, but we can deference them with the &lt;code&gt;print&lt;/code&gt; command:
&lt;pre&gt;(gdb) &lt;b&gt;print *decoder&lt;/b&gt;
$1 = {source = 0x637060, request_fmt = {big_endian = 0, word_size = 2,
    signed_sample = 1, rate = 0, channels = 0, matrix = 0x0}, actual_fmt = {
    big_endian = 0, word_size = 2, signed_sample = 1, rate = 0, channels = 0,
    matrix = 0x0}, format = 0x617ec0, callbacks = 0x7fffffffe3a0,
  callback_arg = 0x0, private = 0x6375d0}&lt;/pre&gt;
&lt;p&gt;That&#x2019;s pretty nice, we can see for example what format it wants the data in: little endian, signed, etc.  Also, notice the line of code it stopped on:
&lt;/p&gt;&lt;pre&gt;253	  flac_private_t *priv = decoder-&amp;gt;private;&lt;/pre&gt;
&lt;p&gt;That&#x2019;s the &lt;em&gt;next&lt;/em&gt; line of code GDB will execute if we set the program going again in some way.  We can advance over just that line with the &lt;code&gt;next&lt;/code&gt; command:
&lt;/p&gt;&lt;pre&gt;(gdb) &lt;b&gt;next&lt;/b&gt;
254	  decoder_callbacks_t *cb = decoder-&amp;gt;callbacks;&lt;/pre&gt;
&lt;p&gt;Now it&#x2019;s initialised the local variable &lt;code&gt;priv&lt;/code&gt;, which we can also print out:
&lt;/p&gt;&lt;pre&gt;(gdb) &lt;b&gt;p *priv&lt;/b&gt;
$2 = {decoder = 0x637000, is_oggflac = 0, channels = 2, rate = 44100,
  bits_per_sample = 16, totalsamples = 13337016, currentsample = 0,
  samples_decoded = 4096, samples_decoded_previous = 0, bytes_read = 24576,
  bytes_read_previous = 0, comments = 0x638240, bos = 1, eos = 0,
  buf = 0x637020, buf_len = 4096, buf_start = 0, buf_fill = 4096, stats = {
    total_time = 0, current_time = 0, instant_bitrate = 0, avg_bitrate = 0}}&lt;/pre&gt;
&lt;p&gt;Did you see what I did there?  Most GDB commands have abbreviated forms, and the abbreviation for &lt;code&gt;print&lt;/code&gt; is &lt;code&gt;p&lt;/code&gt;.  The commands I&#x2019;ve introduced in this article are some of the most commonly used, and their abbreviated forms are all simply their first letter: &lt;code&gt;b&lt;/code&gt; for &lt;code&gt;breakpoint&lt;/code&gt;, &lt;code&gt;r&lt;/code&gt; for &lt;code&gt;run&lt;/code&gt; and &lt;code&gt;n&lt;/code&gt; for &lt;code&gt;next&lt;/code&gt;. You can also repeat the previous command by pressing Return, which is handy for doing a load of &lt;code&gt;next&lt;/code&gt; commands one after the other, for instance.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Ok, that&#x2019;s all for today.  Go and have a play!&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 16 Mar 2012 18:09:19 GMT</pubDate>
      <title>Breakpoints on inlined functions</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=262</link>
      <guid>http://gbenson.net/?p=318</guid>
      <description>&lt;p&gt;I just committed a &lt;a href="http://www.cygwin.com/ml/gdb-patches/2012-03/msg00623.html" &gt;patch&lt;/a&gt; that makes GDB able to set breakpoints on inlined functions by name.&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Thu, 15 Mar 2012 16:11:22 GMT</pubDate>
      <title>GDB neat things #1</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=261</link>
      <guid>http://gbenson.net/?p=315</guid>
      <description>&lt;p&gt;The command &lt;code&gt;tbreak&lt;/code&gt; (&lt;code&gt;tb&lt;/code&gt; for short) is exactly like &lt;code&gt;break&lt;/code&gt; except that the breakpoint it sets is deleted when it&#x2019;s hit.&lt;/p&gt;
&lt;p&gt;The command &lt;code&gt;start&lt;/code&gt; runs the debugged program until the start of the main procedure.  It&#x2019;s equivalent to &lt;code&gt;tbreak&#xA0;main&lt;/code&gt; followed by &lt;code&gt;run&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Little things for sure, but they save typing.&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Wed, 21 Sep 2011 13:09:58 GMT</pubDate>
      <title>Working on gdb</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=260</link>
      <guid>http://gbenson.net/?p=292</guid>
      <description>&lt;p&gt;For future reference, and because I keep forgetting things, here is how I work on gdb:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Check out a copy of the sources.  Some of this is described on the &lt;a href="http://sourceware.org/gdb/wiki/ArcherBranchManagement" &gt;branch management&lt;/a&gt; page of the &lt;a href="http://sourceware.org/gdb/wiki/" &gt;GDB wiki&lt;/a&gt;:
&lt;pre&gt;mkdir /somewhere/to/work
cd /somewhere/to/work
git clone ssh://sourceware.org/git/archer.git src
cd src
git remote add gdb git://sourceware.org/git/gdb.git&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Point the &lt;code&gt;master&lt;/code&gt; branch to the correct place.  The real one is in the GDB repo, but there&#x2019;s an old one in Archer that is no longer used. Open &lt;code&gt;/somewhere/to/work/src/.git/config&lt;/code&gt; in your favourite editor and change &lt;code&gt;remote&#xA0;=&#xA0;origin&lt;/code&gt; to &lt;code&gt;remote&#xA0;=&#xA0;gdb&lt;/code&gt; in the &lt;code&gt;[branch&#xA0;"master"]&lt;/code&gt; section.  Then probably do a &lt;code&gt;git&#xA0;pull&lt;/code&gt; to fetch the actual code you&#x2019;ll be working on.&lt;/li&gt;
&lt;li&gt;Create yourself a nice new branch to make your changes in:&lt;/li&gt;
&lt;pre&gt;git branch --track archer-gbenson-lazy-skip-inline-frames gdb/master
git checkout archer-gbenson-lazy-skip-inline-frames&lt;/pre&gt;

&lt;li&gt;(make your changes here)&lt;/li&gt;
&lt;li&gt;Build it.  I build out-of-tree, like this:
&lt;pre&gt;mkdir /somewhere/to/work/build
cd /somewhere/to/work/build
CFLAGS="-g -O0" ../src/configure --with-separate-debug-dir=/usr/lib/debug
make&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Run the testsuite.  I like to run the tests twice, once without and once with the changes, then I diff the results and pipe it through a script I wrote to hide the unimportant bits:
&lt;pre&gt;make check &amp;gt;&amp;amp; build-20110921-3.log
diff -u baseline-20110919.log build-20110921-3.log | &lt;a href="http://inauspicious.org/files/scripts/gdbtestdiff.py" &gt;gdbtestdiff&lt;/a&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;If a test fails, you&#x2019;ll want to hook gdb into it.  To do that you run the specific test to create a transcript:
&lt;pre&gt;cd /somewhere/to/work/build/gdb/testsuite
runtest TRANSCRIPT=1 ../../../src/gdb/testsuite/gdb.opt/inline-cmds.exp
gdb ../gdb&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Then you pipe the transcript into gdb:
&lt;pre&gt;
set prompt (top-gdb)
b internal_error
r -nx
&lt;transcript/&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Ok, I think that is enough for now.&lt;/p&gt;</description>
    </item>
    <item>
      <pubDate>Thu, 23 Jun 2011 09:06:01 GMT</pubDate>
      <title>New role</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=259</link>
      <guid>http://gbenson.net/?p=288</guid>
      <description>&lt;p&gt;A couple of months ago I switched from the OpenJDK team to the GDB team.  I&#x2019;ll no doubt write something here about what I&#x2019;m doing soon (ie within the next year or so) but in the meantime if you would like to apply for my old job at the awesomeness that is Red&#xA0;Hat then please &lt;a href="https://careers.redhat.com/ext/detail?redhat7832" &gt;click this link&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
