<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>drboblog</title>
	
	<link>http://tecnocode.co.uk</link>
	<description>Ramblings on computers…</description>
	<lastBuildDate>Wed, 25 Aug 2010 20:12:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>		<feedburner:info uri="drboblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><image><link>http://creativecommons.org/licenses/by-sa/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://tecnocode.co.uk/feed/" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ftecnocode.co.uk%2Ffeed%2F" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ftecnocode.co.uk%2Ffeed%2F" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://tecnocode.co.uk/feed/" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ftecnocode.co.uk%2Ffeed%2F" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ftecnocode.co.uk%2Ffeed%2F" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site.</feedburner:browserFriendly><item>
		<title>The last GUADEC post?</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/JVh8kZGVvuE/</link>
		<comments>http://tecnocode.co.uk/2010/08/25/the-last-guadec-post/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 08:52:29 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[automake]]></category>
		<category><![CDATA[Collabora]]></category>
		<category><![CDATA[gtk-doc]]></category>
		<category><![CDATA[GUADEC]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=378</guid>
		<description><![CDATA[GUADEC&#8216;s over (and has been so for a while) and was great. The talk videos are up, and still I haven&#8217;t blogged about the conference. Naughty me. The conference was great: it was good to meet up with friends (old and new) again, get a bit of hacking done and hear lots of discussion about [...]]]></description>
			<content:encoded><![CDATA[<p><a title="GUADEC: The annual GNOME conference." href="http://guadec.org/index.php/guadec/index">GUADEC</a>&#8216;s over (and has been so for a while) and was great. The <a title="Videos of the talks at GUADEC 2010." href="http://www.flumotion.com/first_webm_live_event.php">talk videos</a> are up, and still I haven&#8217;t blogged about the conference. Naughty me.</p>
<p>The conference was great: it was good to meet up with friends (old and new) again, get a bit of hacking done and hear lots of discussion about the future of GNOME. My thanks to the <a title="The non-profit foundation behind the GNOME Project." href="http://foundation.gnome.org/">GNOME Foundation</a> and my summer employer, <a title="Open-source consultants from the UK." href="http://www.collabora.co.uk/">Collabora</a>, for sponsoring my accommodation and travel. Thank you to the local team for organising a brilliant GUADEC in a nice city, and here&#8217;s to a successful GCDS 2011 in Berlin!</p>
<p>In other news, I&#8217;ve finally got fed up with forgetting to add new files in my project to either the project-wide header file or the documentation index, so I wrote some `make check` rules which will check for my braindeadness:</p>
<p>This one goes in the <tt>Makefile.am</tt> in the directory which builds your public header (such as <tt>gtk/gtk.h</tt>), and assumes a list of all the headers you&#8217;re going to install is in <tt>public_headers</tt>, and that your main header&#8217;s path is in <tt>main_header</tt>.</p>
<pre class="brush: plain;">check-local: check-headers
check-headers:
	@any_missing=0; for header_file in $(public_headers); do \
		if test &quot;x$$header_file&quot; != &quot;x$(main_header)&quot;; then \
			if ! grep &quot;#include &lt;$$header_file&gt;&quot; $(main_header) &gt;/dev/null; then \
				echo &quot;$(main_header) doesn't appear to include \&quot;$$header_file\&quot;&quot;; \
				any_missing=1; \
			fi; \
		fi; \
	done; exit &quot;$$any_missing&quot;</pre>
<p>This one goes in the <tt>Makefile.am</tt> in your gtk-doc directory (e.g. <tt>docs/reference</tt>), and only assumes the existence of <tt>DOC_MAIN_SGML_FILE</tt>, which needs to be defined for gtk-doc anyway.</p>
<pre class="brush: plain;">check-local: check-xml-includes
check-xml-includes:
	@any_missing=0; find $(srcdir) -name &quot;*.xml&quot; | while read x; do \
		xml_file=&quot;$${x#./}&quot;; \
		if test &quot;x$$xml_file&quot; != &quot;x$(DOC_MAIN_SGML_FILE)&quot;; then \
			if ! grep &quot;\&quot;$$xml_file\&quot;&quot; $(DOC_MAIN_SGML_FILE) &gt;/dev/null; then \
				echo &quot;$(DOC_MAIN_SGML_FILE) doesn't appear to include \&quot;$$xml_file\&quot;&quot;; \
				any_missing=1; \
			fi; \
		fi; \
	done; exit &quot;$$any_missing&quot;</pre>
<p>I&#8217;ve filed <a title="Bug 627920 — `make check` rule to list xml files missing from DOC_MAIN_SGML_FILE" href="https://bugzilla.gnome.org/show_bug.cgi?id=627920">bgo#627920</a> about adding the second rule to gtk-doc itself. I&#8217;m not sure the first rule is general enough to be put anywhere common.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=JVh8kZGVvuE:9So99J_JrVQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=JVh8kZGVvuE:9So99J_JrVQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=JVh8kZGVvuE:9So99J_JrVQ:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=JVh8kZGVvuE:9So99J_JrVQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=JVh8kZGVvuE:9So99J_JrVQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=JVh8kZGVvuE:9So99J_JrVQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=JVh8kZGVvuE:9So99J_JrVQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/JVh8kZGVvuE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/08/25/the-last-guadec-post/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/08/25/the-last-guadec-post/</feedburner:origLink></item>
		<item>
		<title>GUADEC’s nearly here!</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/DAcu2W6NXH8/</link>
		<comments>http://tecnocode.co.uk/2010/07/19/guadecs-nearly-here/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 22:44:41 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[GUADEC]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=374</guid>
		<description><![CDATA[Less than a week from now GUADEC 2010 will have started: a week of talks, work and partying in The Hague! This doesn&#8217;t happen by magic, though, and we&#8217;re still looking for volunteers to help the week run smoothly. We need just a few more heralds, particularly for Thursday and Friday, to announce each speaker, [...]]]></description>
			<content:encoded><![CDATA[<p>Less than a week from now <a title="The annual GNOME development conference." href="http://guadec.org/index.php/index/index">GUADEC 2010</a> will have started: a week of talks, work and partying in The Hague! This doesn&#8217;t happen by magic, though, and we&#8217;re still looking for volunteers to help the week run smoothly. We need just a few more <a title="My first post about heralding at GUADEC 2010." href="http://tecnocode.co.uk/2010/07/08/helping-out-at-guadec-2010/">heralds</a>, particularly for Thursday and Friday, to announce each speaker, keep time, ensure that the speaker has  what they need, and help out with the changeover between speakers. Volunteering to herald for just one morning or afternoon would be a great help, and the only requirement is that you can spend the entirety of that morning or afternoon in one room. With the interesting talks on <a title="The GUADEC 2010 main talk schedule." href="http://live.gnome.org/GUADEC/2010/Schedule/Main">this year&#8217;s schedule</a>, this should be possible!</p>
<p>If you want to help out but don&#8217;t fancy heralding, there&#8217;s always more which can be done! In either case, please leave a comment below or e-mail <span id="emob-thnqrp-yvfg@tabzr.bet-16">guadec-list {at} gnome(.)org</span><script type="text/javascript">
    var mailNode = document.getElementById('emob-thnqrp-yvfg@tabzr.bet-16');
    var linkNode = document.createElement('a');
    linkNode.setAttribute('href', "mailto:%67%75%61%64%65%63%2D%6C%69%73%74%40%67%6E%6F%6D%65%2E%6F%72%67");
    tNode = document.createTextNode("guadec-list {at} gnome(.)org");
    linkNode.appendChild(tNode);
    linkNode.setAttribute('id', "emob-thnqrp-yvfg@tabzr.bet-16");
    mailNode.parentNode.replaceChild(linkNode, mailNode);
</script> with your availability.</p>
<p><a href="http://tecnocode.co.uk/wp-content/uploads/2010/05/guadec-oranje.png"><img class="aligncenter size-full wp-image-336" title="guadec-oranje" src="http://tecnocode.co.uk/wp-content/uploads/2010/05/guadec-oranje.png" alt="I am attending GUADEC" width="134" height="46" /></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=DAcu2W6NXH8:KCcJJw4V5ro:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=DAcu2W6NXH8:KCcJJw4V5ro:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=DAcu2W6NXH8:KCcJJw4V5ro:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=DAcu2W6NXH8:KCcJJw4V5ro:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=DAcu2W6NXH8:KCcJJw4V5ro:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=DAcu2W6NXH8:KCcJJw4V5ro:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=DAcu2W6NXH8:KCcJJw4V5ro:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/DAcu2W6NXH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/07/19/guadecs-nearly-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/07/19/guadecs-nearly-here/</feedburner:origLink></item>
		<item>
		<title>Reference count debugging with systemtap</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/heu7Kg5qdpQ/</link>
		<comments>http://tecnocode.co.uk/2010/07/13/reference-count-debugging-with-systemtap/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 22:39:22 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Empathy]]></category>
		<category><![CDATA[systemtap]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=365</guid>
		<description><![CDATA[I got some really helpful comments on yesterday&#8217;s post about reference count debugging with gdb which enabled me to get systemtap working. Getting systemtap working (on Fedora 13) Install the systemtap-* and kernel-devel packages as per the instructions on the systemtap wiki. Note that the kernel packages need to be for the same version as [...]]]></description>
			<content:encoded><![CDATA[<p>I got some really <a title="Frank Ch. Eigler's comment which enlightened me about systemtap." href="http://tecnocode.co.uk/2010/07/12/reference-count-debugging-with-gdb/#comment-1024">helpful</a> <a title="Mark Wielaard's comment on the future of systemtap." href="http://tecnocode.co.uk/2010/07/12/reference-count-debugging-with-gdb/#comment-1028">comments</a> on yesterday&#8217;s post about <a title="A tutorial on reference count debugging with gdb." href="http://tecnocode.co.uk/2010/07/12/reference-count-debugging-with-gdb/">reference count debugging with gdb</a> which enabled me to get <a title="A Linux kernel-level debugging and tracing framework." href="http://sourceware.org/systemtap/">systemtap</a> working.</p>
<h2>Getting systemtap working (on Fedora 13)</h2>
<p>Install the <tt>systemtap-*</tt> and <tt>kernel-devel</tt> packages as per the <a title="Instructions for installing systemtap on Fedora." href="http://sourceware.org/systemtap/wiki/SystemtapOnFedora">instructions on the systemtap wiki</a>. Note that the kernel packages need to be for the same version as the kernel you&#8217;re currently running. I got caught out by this since I hadn&#8217;t rebooted since I last downloaded an updated kernel package. You then need to add yourself to the <tt>stapdev</tt> and <tt>stapusr</tt> groups. Run the command <tt>stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'</tt> to test whether everything&#8217;s installed and working properly. systemtap might ask you to run a <tt>make</tt> command at this point, which you need to do.</p>
<h2>Writing systemtap probes</h2>
<p>The probe I&#8217;m using to sort out referencing issues is the following, based off the <a title="Alex Larsson's blog entry on tracing GLib with systemtap." href="http://blogs.gnome.org/alexl/2010/01/04/tracing-glib/">examples Alex Larsson gave</a> when static probes were initially added to GLib and GObject. I&#8217;ve saved it as <tt>refs.stp</tt>:</p>
<pre class="brush: plain;">global alive
global my_object = &quot;FooObject&quot;

probe gobject.object_new {
	if (type == my_object)
		alive++
}

probe gobject.object_ref {
	if (type == my_object) {
		printf (&quot;%s %p ref (%u)\n&quot;, type, object, refcount)
		print_ubacktrace_brief ()
		printf (&quot;\n&quot;)
	}
}

probe gobject.object_unref {
	if (type == my_object) {
		printf (&quot;%s %p unref (%u)\n&quot;, type, object, old_refcount)
		print_ubacktrace_brief ()
		printf (&quot;\n&quot;)

		if (old_refcount == 1)
			alive--
	}
}

probe end {
	printf (&quot;Alive objects: \n&quot;)
	if (alive &gt; 0)
		printf (&quot;%d\t%s\n&quot;, alive, my_object)
}</pre>
<p>This counts how many instances of the <tt>FooObject</tt> class are created (using a probe on <tt>g_object_new()</tt>) and destroyed (probing on <tt>g_object_unref()</tt> and decrementing the alive counter when the last reference is dropped). References and dereferences are also counted, with a short backtrace being outputted for each, which is the key thing I was looking for when debugging reference counting problems.</p>
<h2>Using the probes</h2>
<p>I was debugging problems in Empathy, so I had to use the following command:</p>
<pre>stap refs.stp \
-d ${libdir}/libfolks.so \
-d ${libdir}/libfolks-telepathy.so \
-d ${libdir}/libglib-2.0.so \
-d ${libdir}/libgobject-2.0.so \
-d ${libdir}/libgee.so \
-d ${libdir}/libgtk-x11-2.0.so \
-d ${bindir}/empathy \
-c "${bindir}/empathy"</pre>
<p>Each <tt>-d</tt> option tells systemtap to load unwind data from the given library or executable, which is the key thing I was missing yesterday; these options are necessary for the backtraces to be useful, since systemtap stops unwinding a backtrace at the first frame it can&#8217;t map to a symbol name. Note that it&#8217;s necessary to explicitly tell systemtap to load data from the <tt>empathy</tt> executable, even though it then runs Empathy to trace it.</p>
<p>This gives output like the following when tracing the <tt>EmpathyMainWindow</tt> object:</p>
<pre>EmpathyIndividualStore 0x09c05a10 ref (2)
g_object_ref+0x138
g_value_object_collect_value+0xe0
g_value_set_instance+0x190
.L1016+0x1e0
g_signal_emit_by_name+0x165
gtk_tree_sortable_sort_column_changed+0x78
gtk_tree_store_set_sort_column_id+0xde
gtk_tree_sortable_set_sort_column_id+0xe6
empathy_individual_store_set_sort_criterium+0x108
individual_store_setup+0x162
empathy_individual_store_init+0xb0
g_type_create_instance+0x1c3
g_object_constructor+0x1d
g_object_newv+0x438
.L345+0xfd
g_object_new+0x8d
empathy_individual_store_new+0xb6
empathy_main_window_init+0x890
g_type_create_instance+0x1c3
g_object_constructor+0x1d
empathy_main_window_constructor+0x4c

EmpathyIndividualStore 0x09c05a10 unref (2)
g_object_unref+0x13f
g_value_object_free_value+0x2a
g_value_unset+0x6d
.L1041+0x100
g_signal_emit_by_name+0x165
gtk_tree_sortable_sort_column_changed+0x78
gtk_tree_store_set_sort_column_id+0xde
gtk_tree_sortable_set_sort_column_id+0xe6
empathy_individual_store_set_sort_criterium+0x108
individual_store_setup+0x162
empathy_individual_store_init+0xb0
g_type_create_instance+0x1c3
g_object_constructor+0x1d
g_object_newv+0x438
.L345+0xfd
g_object_new+0x8d
empathy_individual_store_new+0xb6
empathy_main_window_init+0x890
g_type_create_instance+0x1c3
g_object_constructor+0x1d
empathy_main_window_constructor+0x4c</pre>
<p>The only thing I need to do now is to figure out how to script systemtap so that it indents each backtrace nicely according to the reference count of the object.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=heu7Kg5qdpQ:qscjxA8m6qU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=heu7Kg5qdpQ:qscjxA8m6qU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=heu7Kg5qdpQ:qscjxA8m6qU:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=heu7Kg5qdpQ:qscjxA8m6qU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=heu7Kg5qdpQ:qscjxA8m6qU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=heu7Kg5qdpQ:qscjxA8m6qU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=heu7Kg5qdpQ:qscjxA8m6qU:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/heu7Kg5qdpQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/07/13/reference-count-debugging-with-systemtap/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/07/13/reference-count-debugging-with-systemtap/</feedburner:origLink></item>
		<item>
		<title>Reference count debugging with gdb</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/ACQNEHNClDY/</link>
		<comments>http://tecnocode.co.uk/2010/07/12/reference-count-debugging-with-gdb/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 22:07:43 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[systemtap]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=359</guid>
		<description><![CDATA[As I was hacking today, I ran into some hard-to-debug reference counting problems with one of my classes. The normal smattering of printf()s didn&#8217;t help, and neither did this newfangled systemtap, which was a bit disappointing. It worked, in that my probes were correctly run and correctly highlighted each reference/dereference of the class I was [...]]]></description>
			<content:encoded><![CDATA[<p>As I was hacking today, I ran into some hard-to-debug reference counting problems with one of my classes. The normal smattering of <tt>printf()</tt>s didn&#8217;t help, and neither did this newfangled <a title="A Linux kernel-level debugging and tracing framework." href="http://sourceware.org/systemtap/">systemtap</a>, which was a bit disappointing.</p>
<p>It worked, in that my probes were correctly run and correctly highlighted each reference/dereference of the class I was interested in, but printing a backtrace only extended to the <tt>g_object_ref()</tt>/<tt>g_object_unref()</tt> call, and no further. I&#8217;m guessing this was a problem with the location of the debug symbols for my code (since it was in a development prefix, whereas systemtap was not), but it might be that systemtap hasn&#8217;t quite finished userspace stuff yet. That&#8217;s what I read, at least.</p>
<p>In the end, I ended up using <a title="gdb's manual page on conditional breakpoints." href="http://sourceware.org/gdb/current/onlinedocs/gdb/Conditions.html#Conditions">conditional breakpoints in gdb</a>. This was a lot slower than systemtap, but it worked. It&#8217;s the sort of thing I would&#8217;ve killed to know a few years (or even a few months) ago, so hopefully it&#8217;s useful for someone (even if it&#8217;s not the most elegant solution out there).</p>
<pre class="brush: plain;">set pagination off
set $foo=0
break main
run

break g_object_ref
condition 2 _object==$foo
commands
	silent
	bt 8
	cont
	end

break g_object_unref
condition 3 _object==$foo
commands
	silent
	bt 8
	cont
	end

break my_object_init
commands
	silent
	set $foo=my_object
	cont
	end
enable once 4
cont</pre>
<p>The breakpoint in <tt>main()</tt> is to stop gdb discarding our breakpoints out of hand because the relevant libraries haven&#8217;t been loaded yet. <tt>$foo</tt> contains the address of the first instance of <tt>MyObject</tt> in the program; if you need to trace the <var>n+1</var>th instance, use <tt>ignore 4 <var>n</var></tt> to only fire the <tt>my_object_init</tt> breakpoint on the <var>n+1</var>th <tt>MyObject</tt> instantiation.</p>
<p>This can be extended to track (a fixed number of) multiple instances of the object, by using several <tt>$foo<var>i</var></tt> variables and <a title="gdb's manual page on expressions which can be used in if statements." href="http://sourceware.org/gdb/current/onlinedocs/gdb/Expressions.html#Expressions">gdb&#8217;s <tt>if</tt> statements</a> to set them as appropriate. This is left as an exercise to the reader!</p>
<p>I welcome the inevitable feedback and criticism of this approach. It&#8217;s hacky, ugly and slower than systemtap, but at least it works.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=ACQNEHNClDY:lQiDW-cnniI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=ACQNEHNClDY:lQiDW-cnniI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=ACQNEHNClDY:lQiDW-cnniI:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=ACQNEHNClDY:lQiDW-cnniI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=ACQNEHNClDY:lQiDW-cnniI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=ACQNEHNClDY:lQiDW-cnniI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=ACQNEHNClDY:lQiDW-cnniI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/ACQNEHNClDY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/07/12/reference-count-debugging-with-gdb/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/07/12/reference-count-debugging-with-gdb/</feedburner:origLink></item>
		<item>
		<title>Helping out at GUADEC 2010</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/s7H_wydv-Uw/</link>
		<comments>http://tecnocode.co.uk/2010/07/08/helping-out-at-guadec-2010/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 22:22:42 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=348</guid>
		<description><![CDATA[GUADEC&#8216;s approaching fast, and we&#8217;re looking for volunteers to act as heralds in each room; announcing each speaker, keeping time, ensuring that the speaker has what they need, and helping out with the changeover between speakers. Volunteers are needed for the three main rooms (Paris, Copenhagen and Seville) for the three core days of GUADEC, [...]]]></description>
			<content:encoded><![CDATA[<p><a title="GUADEC: The annual GNOME conference." href="http://guadec.org/index.php/guadec/index">GUADEC</a>&#8216;s approaching fast, and we&#8217;re looking for volunteers to act as heralds in each room; announcing each speaker, keeping time, ensuring that the speaker has what they need, and helping out with the changeover between speakers.</p>
<p>Volunteers are needed for the <a title="Overview of the schedule conference." href="http://guadec.org/index.php/guadec/2010/schedConf/overview">three main rooms</a> (Paris, Copenhagen and Seville) for the three core days of GUADEC, plus for the <a title="A pre-conference day focussing on the desktop in government and education." href="http://guadec.org/index.php/guadec/2010/schedConf/opendesktopday">GNOME Open Desktop Day</a> in the Seville room. Each heralding slot is half a day long, which you&#8217;d spend in one room, attending to the talks for that morning or afternoon. We&#8217;re flexible about which rooms people are assigned to, so if you want to help out but don&#8217;t want to miss a particular talk, we can try and get you heralding in the right room for it!</p>
<p>Anybody who helps out with heralding will get a warm fuzzy feeling and an exclusive shiny new t-shirt. If you want your very own warm fuzzy feeling (and t-shirt), please leave a comment below or e-mail <span id="emob-thnqrp-yvfg@tabzr.bet-76">guadec-list {at} gnome(.)org</span><script type="text/javascript">
    var mailNode = document.getElementById('emob-thnqrp-yvfg@tabzr.bet-76');
    var linkNode = document.createElement('a');
    linkNode.setAttribute('href', "mailto:%67%75%61%64%65%63%2D%6C%69%73%74%40%67%6E%6F%6D%65%2E%6F%72%67");
    tNode = document.createTextNode("guadec-list {at} gnome(.)org");
    linkNode.appendChild(tNode);
    linkNode.setAttribute('id', "emob-thnqrp-yvfg@tabzr.bet-76");
    mailNode.parentNode.replaceChild(linkNode, mailNode);
</script> with your availability and any preference you have as to rooms or times.</p>
<p><a href="http://tecnocode.co.uk/wp-content/uploads/2010/05/guadec-oranje.png"><img class="aligncenter size-full wp-image-336" title="guadec-oranje" src="http://tecnocode.co.uk/wp-content/uploads/2010/05/guadec-oranje.png" alt="I am attending GUADEC" width="134" height="46" /></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=s7H_wydv-Uw:CMmSN-ipce0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=s7H_wydv-Uw:CMmSN-ipce0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=s7H_wydv-Uw:CMmSN-ipce0:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=s7H_wydv-Uw:CMmSN-ipce0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=s7H_wydv-Uw:CMmSN-ipce0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=s7H_wydv-Uw:CMmSN-ipce0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=s7H_wydv-Uw:CMmSN-ipce0:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/s7H_wydv-Uw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/07/08/helping-out-at-guadec-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/07/08/helping-out-at-guadec-2010/</feedburner:origLink></item>
		<item>
		<title>Totem and libpeas</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/39OF9M175T8/</link>
		<comments>http://tecnocode.co.uk/2010/06/19/totem-and-libpeas/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 18:39:41 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[libpeas]]></category>
		<category><![CDATA[Totem]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=343</guid>
		<description><![CDATA[I&#8217;ve just released Totem 2.90.0 after some person conned me into rolling the tarball. This release is notable because Totem&#8217;s now been ported to use libpeas for plugin handling. This allowed us to eliminate a lot of the old plugin handling code, but unfortunately it means that Python and Vala plugins don&#8217;t work any more. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just <a title="The download page for Totem 2.90.0." href="http://ftp.gnome.org/pub/GNOME/sources/totem/2.90/">released Totem 2.90.0</a> after <a title="Bastien Nocera, the person who should be rolling the tarball" href="http://hadess.net/">some person</a> conned me into rolling the tarball. This release is notable because Totem&#8217;s now been ported to use <a title="Get the code for libpeas!" href="http://git.gnome.org/browse/libpeas/">libpeas</a> for plugin handling. This allowed us to eliminate a lot of the old plugin handling code, but unfortunately it means that Python and Vala plugins don&#8217;t work any more. We&#8217;re working on this (when we&#8217;re not <a title="Bastien spends his time reading comics these days." href="http://www.hadess.net/2010/06/idevice-tablet-hints.html">reading comics</a>).</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=39OF9M175T8:iXFwfJK_Z94:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=39OF9M175T8:iXFwfJK_Z94:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=39OF9M175T8:iXFwfJK_Z94:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=39OF9M175T8:iXFwfJK_Z94:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=39OF9M175T8:iXFwfJK_Z94:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=39OF9M175T8:iXFwfJK_Z94:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=39OF9M175T8:iXFwfJK_Z94:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/39OF9M175T8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/06/19/totem-and-libpeas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/06/19/totem-and-libpeas/</feedburner:origLink></item>
		<item>
		<title>Unicode in Python</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/dMGYyrTxUbg/</link>
		<comments>http://tecnocode.co.uk/2010/06/11/unicode-in-python/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 11:36:28 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Unicode]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=340</guid>
		<description><![CDATA[Now that exams are finally over, I can spend more time on GNOMEy things. One problem which has been sitting on my to-do list for a while is that of translatable Unicode strings in Python. It appears that my patch in bug #591496 to get Hamster to use Unicode em-dashes inadvertently broke translation of the [...]]]></description>
			<content:encoded><![CDATA[<p>Now that exams are finally over, I can spend more time on GNOMEy things. One problem which has been sitting on my to-do list for a while is that of translatable Unicode strings in Python. It appears that my patch in <a title="Bug 591496 — Use proper em-dashes instead of hyphens" href="https://bugzilla.gnome.org/show_bug.cgi?id=591496">bug #591496</a> to get Hamster to use Unicode em-dashes inadvertently broke translation of the strings. Whoops.</p>
<p>It turns out that in order for gettext to properly match and translate a C-locale string which contains Unicode characters, the encoding of the Python file must be specified using a <a title="Python's documentation on file encodings." href="http://docs.python.org/reference/lexical_analysis.html#encodings"><code>coding:</code> line</a> at the top of the file, and the string in question must be a <a title="Python's documentation on Unicode sequence objects." href="http://docs.python.org/library/stdtypes.html#typesseq">Unicode object</a>. For example:</p>
<pre class="brush: plain;"># -*- coding: utf-8 -*-
…
import gettext
gettext.textdomain('myapp')
…
my_translated_string = gettext.gettext(u'My Unicode string…')
…</pre>
<p>I don&#8217;t think this is too common a problem, and I&#8217;ve checked that it doesn&#8217;t affect any of the other Python modules I&#8217;ve fiddled with, but hopefully this will be useful to someone. As far as I understand it, all translatable strings in Python modules should be <code>u'Unicode objects rather than normal strings'</code> anyway, ideally, but don&#8217;t take my word on it because my Python-fu is weak.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=dMGYyrTxUbg:pBfAdtbv1kk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dMGYyrTxUbg:pBfAdtbv1kk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dMGYyrTxUbg:pBfAdtbv1kk:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dMGYyrTxUbg:pBfAdtbv1kk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=dMGYyrTxUbg:pBfAdtbv1kk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dMGYyrTxUbg:pBfAdtbv1kk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=dMGYyrTxUbg:pBfAdtbv1kk:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/dMGYyrTxUbg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/06/11/unicode-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/06/11/unicode-in-python/</feedburner:origLink></item>
		<item>
		<title>GUADEC!</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/NGug7EKLQUQ/</link>
		<comments>http://tecnocode.co.uk/2010/05/21/guadec/#comments</comments>
		<pubDate>Fri, 21 May 2010 11:37:15 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[GUADEC]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=335</guid>
		<description><![CDATA[Thanks to the generous sponsorship of the GNOME Foundation, I&#8217;m going to GUADEC this year! Thanks to all those involved in funding and sorting out travel sponsorship.]]></description>
			<content:encoded><![CDATA[<p>Thanks to the generous sponsorship of the <a title="The GNOME Foundation's website." href="http://foundation.gnome.org/">GNOME Foundation</a>, I&#8217;m going to <a title="The annual GNOME development conference." href="http://guadec.org/">GUADEC</a> this year! Thanks to all those involved in funding and sorting out travel sponsorship.<a href="http://tecnocode.co.uk/wp-content/uploads/2010/05/guadec-oranje.png"><img class="aligncenter size-full wp-image-336" src="http://tecnocode.co.uk/wp-content/uploads/2010/05/guadec-oranje.png" alt="I am attending GUADEC" width="134" height="46" /></a><br />
<a href="http://tecnocode.co.uk/wp-content/uploads/2009/07/sponsored-badge-simple.png"><img class="aligncenter size-full wp-image-250" src="http://tecnocode.co.uk/wp-content/uploads/2009/07/sponsored-badge-simple.png" alt="Sponsored by the GNOME Foundation" width="213" height="213" /></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=NGug7EKLQUQ:cuvHaE_wLxg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=NGug7EKLQUQ:cuvHaE_wLxg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=NGug7EKLQUQ:cuvHaE_wLxg:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=NGug7EKLQUQ:cuvHaE_wLxg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=NGug7EKLQUQ:cuvHaE_wLxg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=NGug7EKLQUQ:cuvHaE_wLxg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=NGug7EKLQUQ:cuvHaE_wLxg:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/NGug7EKLQUQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/05/21/guadec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/05/21/guadec/</feedburner:origLink></item>
		<item>
		<title>Evolution kicks the libgdata-google habit</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/7pNBcYVpyWU/</link>
		<comments>http://tecnocode.co.uk/2010/04/20/evolution-kicks-the-libgdata-google-habit/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 20:24:48 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[Evolution]]></category>
		<category><![CDATA[evolution-data-server]]></category>
		<category><![CDATA[libgdata]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=333</guid>
		<description><![CDATA[So, after a year of blood, sweat and tears repeatedly appearing at exactly the wrong time to get my patches in, I&#8217;ve finally managed to commit my patches to Evolution and evolution-data-server to port it to use libgdata rather than its home-grown libgdata-google library. Since Evolution has switched to using CalDAV for its Google Calendar [...]]]></description>
			<content:encoded><![CDATA[<p>So, after a year of <span style="text-decoration: line-through;">blood, sweat and tears</span> repeatedly appearing at exactly the wrong time to get my patches in, I&#8217;ve finally managed to commit my <a title="The bug report about porting Evolution to libgdata." href="https://bugzilla.gnome.org/show_bug.cgi?id=583742">patches to Evolution</a> and <a title="The bug report about porting evolution-data-server to libgdata." href="https://bugzilla.gnome.org/show_bug.cgi?id=580021">evolution-data-server</a> to port it to use libgdata rather than its home-grown libgdata-google library. Since Evolution has switched to using CalDAV for its Google Calendar backend, libgdata is just used for the Google Contacts backend. This is the first outing into the big scary world of popular usage for libgdata&#8217;s Google Contacts support, so any and all testing of the changes would be appreciated.</p>
<p>In the meantime, I&#8217;ll get back to looking at adding support for any additional features/contact fields I can to the Google Contacts backend.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=7pNBcYVpyWU:tYAATK7O6ko:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=7pNBcYVpyWU:tYAATK7O6ko:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=7pNBcYVpyWU:tYAATK7O6ko:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=7pNBcYVpyWU:tYAATK7O6ko:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=7pNBcYVpyWU:tYAATK7O6ko:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=7pNBcYVpyWU:tYAATK7O6ko:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=7pNBcYVpyWU:tYAATK7O6ko:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/7pNBcYVpyWU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/04/20/evolution-kicks-the-libgdata-google-habit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/04/20/evolution-kicks-the-libgdata-google-habit/</feedburner:origLink></item>
		<item>
		<title>Use of the pure attribute for GObject convenience getters</title>
		<link>http://feedproxy.google.com/~r/drboblog/~3/dX3tTZOrWjc/</link>
		<comments>http://tecnocode.co.uk/2010/04/02/use-of-the-pure-attribute-for-gobject-convenience-getters/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 20:45:31 +0000</pubDate>
		<dc:creator>Philip Withnall</dc:creator>
				<category><![CDATA[GNOME]]></category>
		<category><![CDATA[const]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[GLib]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[pure]]></category>

		<guid isPermaLink="false">http://tecnocode.co.uk/?p=328</guid>
		<description><![CDATA[In my quest to make my code completely correct and beautiful, largely through the liberal application of obscure and anal-retentive attributes like __warn_unused_result__ and __malloc__, I&#8217;ve hit a problem. Is it safe and correct to use __pure__ with GObject convenience getter functions? As far as the literature explains it, “pure” C functions (no relation to [...]]]></description>
			<content:encoded><![CDATA[<p>In my quest to make my code completely correct and beautiful, largely through the liberal application of obscure and anal-retentive attributes like <code>__warn_unused_result__</code> and <code>__malloc__</code>, I&#8217;ve hit a problem. <span style="font-weight: bold;">Is it safe and correct to use <code>__pure__</code> with GObject convenience getter functions?</span></p>
<p>As far as <a title="gcc's documentation on the pure attribute." href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bpure_007d-function-attribute-2396">the literature</a> <a title="LWN article on the differences between and implications of pure and const functions." href="http://lwn.net/Articles/285332/">explains it</a>, “pure” C functions (no relation to pure mathematical or functional functions) can access pointers and global memory, but must not write to them, and cannot use system resources. In return, gcc can apply extra optimisations to calls to pure functions, since it can assume the return value of a pure function (for a given set of arguments) will not change, <em>no matter how many times the function is called</em>, until memory is written or a non-pure function is called. This allows for elimination of redundant calls to pure functions (since they&#8217;re known to not have any side-effects) or, conversely, for gcc to add in calls to a pure function in preference to storing the result in memory, if it thinks that will perform better. Furthermore, gcc can perform loop optimisations on loops which just use pure functions.</p>
<p>This is all good, and I think I&#8217;ve done a good job of regurgitating the gcc manual here, but it doesn&#8217;t answer the question. There are loads of GObject-based libraries out there, and none of them (as far as I can tell) are using pure convenience getters. I must be missing something from the wisdom of the masses.</p>
<p>The only situation I can think of where using the <code>__pure__</code> attribute on a convenience getter function could result in incorrect code is if the object in question is modified from a thread (2) other than the one (1) calling the getter. For example, thread 1&#8242;s <code>frobnicate()</code> function calls <code>my_object_get_property_foo()</code> a couple of times in a function at the same time as thread 2 calls <code>my_object_set_property_foo()</code>. Normally, let&#8217;s say, the first call to <code>my_object_get_property_foo()</code> would return the old value, and the second call would return the new value. If <code>my_object_get_property_foo()</code> was a pure function, though, the compiler could potentially optimise out the second call, and so thread 1 would never see the new value of the “foo” property.</p>
<p>There are fairly few places where this is the desired behaviour with or without use of <code>__pure__</code>, though. The <code>frobnicate()</code> function is likely to have locking in this situation, which would prevent the race condition as normal, while still allowing the compiler to optimise out some of the calls to the pure <code>my_object_get_property_foo()</code> function.</p>
<p>In summary, what I&#8217;m proposing is that people use the <a title="Documentation for the G_GNUC_PURE macro in GLib." href="http://library.gnome.org/devel/glib/unstable/glib-Miscellaneous-Macros.html#G-GNUC-PURE:CAPS"><code>G_GNUC_PURE</code></a> attribute on their GObject convenience getter functions as much as appropriate. From my tests adding the attribute to functions in libgdata, it doesn&#8217;t make much of a difference in performance but does reduce the code size of applications which use libgdata. (These tests weren&#8217;t particularly thorough, though; they were actually just done against one function, looking at the disassembly of a test program which called it.)</p>
<p>Just as an example, here&#8217;s a pure convenience getter function I wrote earlier:</p>
<pre class="brush: cpp;">GList *gdata_entry_get_categories (GDataEntry *self) G_GNUC_PURE;

GList *
gdata_entry_get_categories (GDataEntry *self)
{
	g_return_val_if_fail (GDATA_IS_ENTRY (self), NULL);
	return self-&gt;priv-&gt;categories;
}</pre>
<p><span style="font-style: italic; font-size: 0.9em;">On another note, that return type should really be <code>const GList*</code>, but <a title="GLib bug report for making its list functions const-correct." href="https://bugzilla.gnome.org/show_bug.cgi?id=401176">GLib&#8217;s list functions aren&#8217;t const-correct</a>.</span></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/drboblog?a=dX3tTZOrWjc:pTmWgptPOwI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/drboblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dX3tTZOrWjc:pTmWgptPOwI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/drboblog?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dX3tTZOrWjc:pTmWgptPOwI:YwkR-u9nhCs"><img src="http://feeds.feedburner.com/~ff/drboblog?d=YwkR-u9nhCs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dX3tTZOrWjc:pTmWgptPOwI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/drboblog?i=dX3tTZOrWjc:pTmWgptPOwI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/drboblog?a=dX3tTZOrWjc:pTmWgptPOwI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/drboblog?i=dX3tTZOrWjc:pTmWgptPOwI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/drboblog/~4/dX3tTZOrWjc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tecnocode.co.uk/2010/04/02/use-of-the-pure-attribute-for-gobject-convenience-getters/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://tecnocode.co.uk/2010/04/02/use-of-the-pure-attribute-for-gobject-convenience-getters/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.392 seconds -->
