<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>just do IT</title>
	<atom:link href="http://rxwen.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rxwen.wordpress.com</link>
	<description></description>
	<lastBuildDate>Thu, 01 Dec 2011 13:47:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rxwen.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>just do IT</title>
		<link>http://rxwen.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rxwen.wordpress.com/osd.xml" title="just do IT" />
	<atom:link rel='hub' href='http://rxwen.wordpress.com/?pushpress=hub'/>
		<item>
		<title>use protobuf on iphone app</title>
		<link>http://rxwen.wordpress.com/2011/11/30/use-protobuf-on-iphone-app/</link>
		<comments>http://rxwen.wordpress.com/2011/11/30/use-protobuf-on-iphone-app/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 22:19:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/?p=305</guid>
		<description><![CDATA[This post is a step by step tutorial showing how to use protobuf in iphone application. It shows how to: Create a reusable static library Create a executable project Mix C++ code with object C code 1. Start terminal, cd to root folder of protobuf and run ./configure here to generate config.h header file and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=305&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post is a step by step tutorial showing how to use <a href="http://code.google.com/p/protobuf/">protobuf</a> in iphone application. It shows how to:</p>
<ul>
<li>Create a reusable static library</li>
<li>Create a executable project</li>
<li>Mix C++ code with object C code</li>
</ul>
<p>1. Start terminal, cd to root folder of protobuf and run ./configure here to generate config.h header file and makefile.</p>
<p>2. Start XCode and create a new project. Select iOS &#8211; Library &#8211; Cocoa Touch Static Library project template.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6223/6362901629_ca2072a466_b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="518" src="http://farm7.staticflickr.com/6223/6362901629_ca2072a466_b.jpg" width="640" /></a></div>
<p>
3. Right click Other Sources and select add Existing Files.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6238/6362901919_6712703463_b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="427" src="http://farm7.staticflickr.com/6238/6362901919_6712703463_b.jpg" width="640" /></a></div>
<p>
4. Select the src/google directory, and add the directory recursively.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6116/6362902255_4c53f3c8e3_z.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="640" src="http://farm7.staticflickr.com/6116/6362902255_4c53f3c8e3_z.jpg" width="636" /></a></div>
<p>
5. In the previous step, we add too much source files than actually needed. The sources files for the protoc compiler and unittest are included too. They&#8217;re not needed to run ios application. To filter out unnecessary files, we can refer to the <i><b>libprotobuf_lite_la_SOURCES</b></i> and <b><i>libprotobuf_la_SOURCES</i></b> variables in <i><b>src/Makefile</b></i>, which list source files needed for protobuf library.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6109/6362901767_cfbd548d24_b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm7.staticflickr.com/6109/6362901767_cfbd548d24_b.jpg" /></a></div>
<p>
6. Now we need to add header file search path. Click Edit Project Settings under Project menu item.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6221/6362901707_d95eb8aecf_z.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm7.staticflickr.com/6221/6362901707_d95eb8aecf_z.jpg" /></a></div>
<p>
7. Double click Header Search Paths.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6100/6362901839_4687c6463e_b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="640" src="http://farm7.staticflickr.com/6100/6362901839_4687c6463e_b.jpg" width="630" /></a></div>
<p>
8. Add protobuf and protobuf/src directory.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6033/6362902209_353fdcc6cd_z.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm7.staticflickr.com/6033/6362902209_353fdcc6cd_z.jpg" /></a></div>
<p>
9. Now build the project.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6110/6362901983_0bfe8f40e6_z.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="366" src="http://farm7.staticflickr.com/6110/6362901983_0bfe8f40e6_z.jpg" width="400" /></a></div>
<p>
10. In the terminal, run &#8220;<b><i>make install</i></b>&#8221; command to build protoc compiler and install it to default location(<i>/usr/local/bin/protoc</i>).</p>
<p>11. Go to examples directory and run &#8220;<b><i>protoc addressbook.proto &#8211;cpp_out=./</i></b>&#8221; to generate <i>addressbook.pb.cc</i> and <i>addressbook.pb.h</i> files.</p>
<p>12. Create a Window-Based Application.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6038/6362902061_a3198167f0_b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="515" src="http://farm7.staticflickr.com/6038/6362902061_a3198167f0_b.jpg" width="640" /></a></div>
<p>
13. Add reference to the static library we built. Right click Frameworks and select Add Existing Frameworks.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6228/6362902119_bd30b111d2_z.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm7.staticflickr.com/6228/6362902119_bd30b111d2_z.jpg" /></a></div>
<p>
14. Click Add Other button.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6056/6362902165_8ef6bc8044_z.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm7.staticflickr.com/6056/6362902165_8ef6bc8044_z.jpg" /></a></div>
<p>
15. Select the libprotobuf_ios.a file and click add button. Also, we need to add protobuf/src and protobuf/examples directory to Header Search Paths for this project. </p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6046/6362929313_39a5322ba1_b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="415" src="http://farm7.staticflickr.com/6046/6362929313_39a5322ba1_b.jpg" width="640" /></a></div>
<p>
16. Rename add_personAppDelegate.m to add_personAppDelegate.mm so that it&#8217;ll be compiled as object C++.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.staticflickr.com/6110/6362901575_ee31951000_b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="312" src="http://farm7.staticflickr.com/6110/6362901575_ee31951000_b.jpg" width="640" /></a></div>
<p>
17. The basic logic of add_personAppDelegate.mm is first create the addressbook.dat file in iphone&#8217;s document directory. Then create a new AddressBook instance and add a person to it. Finally serialize the addressbook to the file we created. The full source is :</p>
<div style="background-color:#000040;color:silver;"><span style="font-family:monospace;"><br />
<span style="color:#ff80ff;">#import&nbsp;</span><span style="color:#ffa0a0;">&#8220;add_personAppDelegate.h&#8221;</span></p>
<p>
<span style="color:#ff80ff;">#include&nbsp;</span><span style="color:#ffa0a0;">&#8220;addressbook.pb.h&#8221;</span><br />
<span style="color:#ff80ff;">#include&nbsp;</span><span style="color:#ffa0a0;">&lt;fstream&gt;</span></p>
<p><span style="color:#ffff60;">using</span>&nbsp;<span style="color:#60ff60;">namespace</span>&nbsp;std;</p>
<p><span style="color:#ffff60;">@implementation</span>&nbsp;add_personAppDelegate</p>
<p>@synthesize window;</p>
<p><span style="color:#ff80ff;">#pragma mark -</span><br />
<span style="color:#ff80ff;">#pragma mark Application lifecycle</span></p>
<p><span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">BOOL</span>)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;GOOGLE_PROTOBUF_VERIFY_VERSION;&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);<br />
&nbsp;&nbsp;&nbsp;&nbsp;NSString *documentDirectory =&nbsp;[paths objectAtIndex:<span style="color:#ffa0a0;">0</span>];<br />
&nbsp;&nbsp;&nbsp;&nbsp;NSString *filename =&nbsp;[NSString stringWithFormat:<span style="color:#ffa0a0;">@"</span><span style="color:orange;">%@</span><span style="color:#ffa0a0;">/addressbook.dat"</span>, documentDirectory];&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;ifstream input([filename UTF8String], ios::<span style="color:#60ff60;">in</span>&nbsp;| ios::binary);&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;tutorial::AddressBook address_book;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;address_book.ParseFromIstream(&amp;input);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#60ff60;">int</span>&nbsp;count = address_book.person_size();&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;tutorial::Person *person = address_book.add_person();<br />
&nbsp;&nbsp;&nbsp;&nbsp;person-&gt;set_id(<span style="color:#ffa0a0;">42</span>);<br />
&nbsp;&nbsp;&nbsp;&nbsp;person-&gt;set_name(<span style="color:#ffa0a0;">&#8220;raymond&#8221;</span>);<br />
&nbsp;&nbsp;&nbsp;&nbsp;person-&gt;set_email(<span style="color:#ffa0a0;">&#8220;raymond@gmail.com&#8221;</span>);&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;tutorial::Person_PhoneNumber *pn = person-&gt;add_phone();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;pn-&gt;set_type(tutorial::Person_PhoneType_WORK);<br />
&nbsp;&nbsp;&nbsp;&nbsp;pn-&gt;set_number(<span style="color:#ffa0a0;">&#8220;12345678&#8243;</span>);&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;fstream output([filename UTF8String], ios::<span style="color:#60ff60;">out</span>&nbsp;| ios::trunc | ios::binary);<br />
&nbsp;&nbsp;&nbsp;&nbsp;person-&gt;SerializeToOstream(&amp;output);&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;NSHomeDirectory();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#80a0ff;">// Override point for customization after application launch.</span>&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;[<span style="color:#ffff60;">self</span>.window makeKeyAndVisible];&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#ffff60;">return</span>&nbsp;YES;<br />
}</p>
<p>
<span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">void</span>)applicationWillResignActive:(UIApplication *)application {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#80a0ff;">/*</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#80a0ff;">*/</span><br />
}</p>
<p>
<span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">void</span>)applicationDidEnterBackground:(UIApplication *)application {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#80a0ff;">/*</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. </span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; If your application supports background execution, called instead of applicationWillTerminate: when the user quits.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#80a0ff;">*/</span><br />
}</p>
<p>
<span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">void</span>)applicationWillEnterForeground:(UIApplication *)application {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#80a0ff;">/*</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; Called as part of&nbsp;&nbsp;transition from the background to the inactive state: here you can undo many of the changes made on entering the background.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#80a0ff;">*/</span><br />
}</p>
<p><span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">void</span>)applicationDidBecomeActive:(UIApplication *)application {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#80a0ff;">/*</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#80a0ff;">*/</span><br />
}</p>
<p>
<span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">void</span>)applicationWillTerminate:(UIApplication *)application {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#80a0ff;">/*</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; Called when the application is about to terminate.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; See also applicationDidEnterBackground:.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#80a0ff;">*/</span><br />
}</p>
<p><span style="color:#ff80ff;">#pragma mark -</span><br />
<span style="color:#ff80ff;">#pragma mark Memory management</span></p>
<p>
<span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">void</span>)applicationDidReceiveMemoryWarning:(UIApplication *)application {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#80a0ff;">/*</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp; Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.</span><br />
<span style="color:#80a0ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#80a0ff;">*/</span><br />
}</p>
<p><span style="color:#40ffff;">-&nbsp;</span>(<span style="color:#60ff60;">void</span>)dealloc {<br />
&nbsp;&nbsp;&nbsp;&nbsp;[window release];<br />
&nbsp;&nbsp;&nbsp;&nbsp;[<span style="color:#ffff60;">super</span>&nbsp;dealloc];<br />
}</p>
<p><span style="color:#ffff60;">@end</span><br />
</span></p>
</div>
<p>
18. After build and run the application in iphone emulator, we get generated addressbook.dat file in <i>/Users/user_name/Library/</i></p>
<div id=":7v"><i>Application Support/iPhone Simulator/4.3/Applications/</i><i>9AF109CF-1B33-49DA-BE73-</i><i>603CC798408F/Documents/</i><i>addressbook.dat</i></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=305&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/11/30/use-protobuf-on-iphone-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>

		<media:content url="http://farm7.staticflickr.com/6223/6362901629_ca2072a466_b.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6238/6362901919_6712703463_b.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6116/6362902255_4c53f3c8e3_z.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6109/6362901767_cfbd548d24_b.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6221/6362901707_d95eb8aecf_z.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6100/6362901839_4687c6463e_b.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6033/6362902209_353fdcc6cd_z.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6110/6362901983_0bfe8f40e6_z.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6038/6362902061_a3198167f0_b.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6228/6362902119_bd30b111d2_z.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6056/6362902165_8ef6bc8044_z.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6046/6362929313_39a5322ba1_b.jpg" medium="image" />

		<media:content url="http://farm7.staticflickr.com/6110/6362901575_ee31951000_b.jpg" medium="image" />
	</item>
		<item>
		<title>port protobuf-lite to wince</title>
		<link>http://rxwen.wordpress.com/2011/11/25/port-protobuf-lite-to-wince/</link>
		<comments>http://rxwen.wordpress.com/2011/11/25/port-protobuf-lite-to-wince/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 22:24:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[wince]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/?p=307</guid>
		<description><![CDATA[protobuf is a wonderful project that helps us implement communication protocol. There are a lot of benefits to use it in practical project, including: It has an efficient binary serialization algorithm It runs cross platforms It support mainstream programming languages, c++, python and java. there are also lots of porting out there for other popular [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=307&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/protobuf/">protobuf</a> is a wonderful project that helps us implement communication protocol. There are a lot of benefits to use it in practical project, including:</p>
<ol>
<li>It has an efficient binary serialization algorithm</li>
<li>It runs cross platforms</li>
<li>It support mainstream programming languages, c++, python and java. there are also lots of porting out there for other popular languages.</li>
<li>It&#8217;s designed to make protocols both backward and forward compatible. </li>
<li>It enables developers to focus on protocol design.</li>
</ol>
<p>&nbsp;Currently, there is no official windows CE version for protobuf. It&#8217;s not an easy task to port protobuf full version to windows CE. But the lite version, which supports less feature than full version (check the explanation for <i>optimize_for</i> option <a href="http://code.google.com/apis/protocolbuffers/docs/proto.html">in this page</a> for what&#8217;s the difference), is easier to port. Here is how I port it:</p>
<ol>
<li>Create a Win32 Smart Device Project library project, name it protobuf-lite-ce</li>
<li>Copy all source files from protobuf-lite project to protobuf-lite-ce project in Solution Explorer</li>
<li>Create a ce_port folder in the project&#8217;s directory, and copy the errno.h header file from <i>(Visual_Studio_Root)/VC/include</i> into the folder. This is because Windows CE doesn&#8217;t have this file, so we need to provide one. Actually, this errno.h can be a pure empty file.</li>
<li>Add &#8220;<i>../src;.;./ce_port</i>&#8221; to the project&#8217;s <i>Additional Include Directories</i>.</li>
<li>The windef.h header file already defines OPTIONAL macro, it conflicts with Cardinality::OPTIONAL enum. So the <a href="http://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/extension_set.cc#207">extension_set.cc</a> fails to compile, to solve this, add following code before enum Cardinality definition to undefine OPTIONAL:</li>
</ol>
<div style="background-color:#000040;color:silver;"><span style="font-family:monospace;"><br />
<span style="color:#ff80ff;">#if defined(OPTIONAL)</span><br />
<span style="color:#ff80ff;">#if defined(_MSC_VER)</span><br />
<span style="color:#ff80ff;">#pragma message (</span><span style="color:#ffa0a0;">&#8220;Unexpected OPTIONAL macro definition, #undefine OPTIONAL&#8221;</span><span style="color:#ff80ff;">)</span><br />
<span style="color:#ff80ff;">#else</span><br />
<span style="color:#ff80ff;">#warning&nbsp;&nbsp;</span><span style="color:#ffa0a0;">&#8220;Unexpected OPTIONAL macro definition, #undefine OPTIONAL&#8221;</span><br />
<span style="color:#ff80ff;">#endif</span><br />
<span style="color:#ff80ff;">#undef OPTIONAL</span><br />
<span style="color:#ff80ff;">#endif</span><br />
<span style="color:#60ff60;">namespace</span>&nbsp;{</p>
<p><span style="color:#60ff60;">enum</span>&nbsp;Cardinality {<br />
&nbsp;&nbsp;REPEATED,<br />
&nbsp;&nbsp;OPTIONAL<br />
};</p>
<p>}&nbsp;&nbsp;<span style="color:#80a0ff;">// namespace</span></p>
<p></span></div>
<p>
Now the protobuf-lite-ce project should compiles fine.<br />
<a href="http://code.google.com/p/rxwen-blog-stuff/source/browse/trunk/wince/protobuf_for_ce/">Here </a>is the project file for downloading. Just get everything there and place them in protobuf/vsprojects/ directory.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/307/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=307&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/11/25/port-protobuf-lite-to-wince/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>
	</item>
		<item>
		<title>why can we use printf without including stdio.h</title>
		<link>http://rxwen.wordpress.com/2011/10/31/why-can-we-use-printf-without-including-stdio-h/</link>
		<comments>http://rxwen.wordpress.com/2011/10/31/why-can-we-use-printf-without-including-stdio-h/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 13:12:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/10/31/why-can-we-use-printf-without-including-stdio-h/</guid>
		<description><![CDATA[I read the c programming language again to mourn Dennis Ritchie who passed away recently. I noticed below statements in section &#8220;4.2 Functions Returning Non-integers&#8221;, which explains the question, why can we use printf without including stdio.h. The function atof must be declared and defined consistently. If atof itself and the call to it in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=301&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I read <a href="http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?ie=UTF8&amp;qid=1319980402&amp;sr=8-1">the c programming language</a> again to mourn <a href="http://en.wikipedia.org/wiki/Dennis_Ritchie">Dennis Ritchie</a> who passed away recently. </p>
<p>I noticed below statements in section <i>&#8220;4.2 Functions Returning Non-integers&#8221;</i>, which explains the question, why can we use printf without including stdio.h.</p>
<div style="margin-left:40px;">The function atof must be declared and defined consistently. If atof itself and the call to it in main have inconsistent types in the same source file, the error will be detected by the compiler. But if (as is more likely) <i>atof</i> were compiled separately, the mismatch would not be detected, <i>atof</i> would return a&nbsp; double that&nbsp; main would treat as an&nbsp; int, and meaningless answers would result.&nbsp; <br />
In the light of what we have said about how declarations must match definitions, this might seem surprising. <b>The reason a mismatch can happen is that if there is no function prototype, a function is implicitly declared by its first appearance in an expression</b>, such as <br />
&nbsp;&nbsp; <i>sum += atof(line) </i><br />
If a name that has not been previously declared occurs in an expression and is followed by a left parentheses, it is declared by context to be a function name, the function is assumed to return an&nbsp; int, and nothing is assumed about its arguments. Furthermore, if a function declaration does not include arguments, as in <br />
&nbsp;&nbsp; <i>double atof(); </i><br />
that too is taken to mean that nothing is to be assumed about the arguments of <i>atof</i>; all parameter checking is turned off. This special meaning of the empty argument list is intended to permit older C programs to compile with new compilers. But it&#8217;s a bad idea to use it with new C programs. If the function takes arguments, declare them; <b>if it takes no arguments, use </b><br />
<b>void</b>. </div>
<p>
So, let&#8217;s take a look at the hello world sample below:</p>
<div style="background-color:#000040;color:silver;"><span style="font-family:monospace;"><br />
<span style="color:yellow;"><b>1 </b></span><span style="color:cyan;"><b>//#include&nbsp;&nbsp;&lt;stdio.h&gt;</b></span><br />
<span style="color:yellow;"><b>2 </b></span><br />
<span style="color:yellow;"><b>3 </b></span><span style="color:lime;"><b>int</b></span>&nbsp;main(<span style="color:lime;"><b>int</b></span>&nbsp;argc, <span style="color:lime;"><b>char</b></span>&nbsp;*argv[])<br />
<span style="color:yellow;"><b>4 </b></span>{<br />
<span style="color:yellow;"><b>5 </b></span>&nbsp;&nbsp;&nbsp;&nbsp;printf(<span style="color:#ff40ff;"><b>&#8220;hello world!</b></span><span style="color:#ff6060;"><b>\n</b></span><span style="color:#ff40ff;"><b>&#8220;</b></span>);<br />
<span style="color:yellow;"><b>6 </b></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:yellow;"><b>return</b></span>&nbsp;<span style="color:#ff40ff;"><b>0</b></span>;<br />
<span style="color:yellow;"><b>7 </b></span>}<br />
</span></div>
<p>
When the code is compiled, the statement on line 5 implicitly declares the printf function because it&#8217;s not declared explicitly. It&#8217;s the same as if we declared printf as:<br />
<i>&nbsp; int printf();</i><br />
And there is no assumption about its argument, so the code can pass the compile phase.</p>
<p>In link phase, unlike c++, only the function name (function signature doesn&#8217;t matter) affects the symbol name. So the printf symbol name can be found from the standard c library which is linked automatically. As a result, the code above can compile and run successfully.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/301/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=301&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/10/31/why-can-we-use-printf-without-including-stdio-h/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>
	</item>
		<item>
		<title>stream audio via udp on android</title>
		<link>http://rxwen.wordpress.com/2011/10/24/stream-audio-via-udp-on-android/</link>
		<comments>http://rxwen.wordpress.com/2011/10/24/stream-audio-via-udp-on-android/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 11:30:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/10/23/stream-audio-via-udp-on-android/</guid>
		<description><![CDATA[In this post, I tried to play small audio data chunks with AudioTrack to show the feasibility of streaming audio. It&#8217;s not straightforward enough. So I updated the sample code to actually transfer audio data with udp. As the image below shows, the application is not too complicated. The two buttons will each create a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=300&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://rxwen.blogspot.com/2010/04/streaming-audio-on-android.html">this post</a>, I tried to play small audio data chunks with AudioTrack to show the feasibility of streaming audio. It&#8217;s not straightforward enough. So I updated the sample code to actually transfer audio data with udp.<br />
As the image below shows, the application is not too complicated.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.static.flickr.com/6092/6271393252_3ce1d25c7c.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="400" src="http://farm7.static.flickr.com/6092/6271393252_3ce1d25c7c.jpg" width="221" /></a></div>
<p>
The two buttons will each create a new thread to send and recv audio data respectively. And the sender will read audio data from the file /data/1.wav. Then, it sends the data to udp port 2048 on localhost. The receiver reads on 2048 port and feed data received to AudioTrack object.<br />
Full code is available at:<br />
<a href="http://code.google.com/p/rxwen-blog-stuff/source/browse/trunk/android/streaming_audio/src/rmd/media/StreamingAudio/UdpStream.java">http://code.google.com/p/rxwen-blog-stuff/source/browse/trunk/android/streaming_audio/src/rmd/media/StreamingAudio/UdpStream.java</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/300/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=300&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/10/24/stream-audio-via-udp-on-android/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>

		<media:content url="http://farm7.static.flickr.com/6092/6271393252_3ce1d25c7c.jpg" medium="image" />
	</item>
		<item>
		<title>modify CE code for our platform</title>
		<link>http://rxwen.wordpress.com/2011/08/01/modify-ce-code-for-our-platform/</link>
		<comments>http://rxwen.wordpress.com/2011/08/01/modify-ce-code-for-our-platform/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 11:57:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[wince]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/08/01/modify-ce-code-for-our-platform/</guid>
		<description><![CDATA[A majority of windows CE core and drivers code is available to us, they reside in public directory of CE installation folder. Occasionally, we may want to modify that part of code, either to change some system behaviors, or add some log messages for debugging our platform&#8217;s code. It&#8217;s strongly recommended not to change the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=298&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A  majority of windows CE core and drivers code is available to us, they reside in  public directory of CE installation folder. Occasionally, we may want to  modify that part of code, either to change some system behaviors, or  add some log messages for debugging our platform&#8217;s code.<br />
It&#8217;s  strongly recommended not to change the original code in place. Because  this part of code is shared by all platforms. All platforms will be  affected by the modification. The right way is before making any change,  copy the module into our own platform directory, and modify the copy  there.<br />
Let&#8217;s say we want to modify <i>public/common/oak/bootpart</i> module&#8217;s code.<br />
1. We first copy it into <i>platform/platform_name/src/common/bootpart</i> <br />
2. Exclude <i>public/common/oak/bootpart</i> from our build</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.static.flickr.com/6025/5993202637_5fef18fc10_z.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm7.static.flickr.com/6025/5993202637_5fef18fc10_z.jpg" /></a></div>
<p>
3. Include&nbsp; <i>platform/platform_name/src/common/bootpart</i> into our build</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm7.static.flickr.com/6135/5993761654_4a019c2b20.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm7.static.flickr.com/6135/5993761654_4a019c2b20.jpg" /></a></div>
<p>
4. The last step is to update other modules&#8217; sources file. For any module that depends our modified bootpart module, we should change its sources file so that it can find the new bootpart instead of the original bootpart shipped with CE. For instance, change <i><b>$(_COMMONOAKROOT)</b>\lib\$(_CPUINDPATH)\bootpart.lib</i> to <i><b>$(_TARGETPLATROOT)</b>\lib\$(_CPUINDPATH)\bootpart.lib</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=298&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/08/01/modify-ce-code-for-our-platform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>

		<media:content url="http://farm7.static.flickr.com/6025/5993202637_5fef18fc10_z.jpg" medium="image" />

		<media:content url="http://farm7.static.flickr.com/6135/5993761654_4a019c2b20.jpg" medium="image" />
	</item>
		<item>
		<title>addr2line for windows</title>
		<link>http://rxwen.wordpress.com/2011/06/28/addr2line-for-windows/</link>
		<comments>http://rxwen.wordpress.com/2011/06/28/addr2line-for-windows/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 11:40:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/06/28/addr2line-for-windows/</guid>
		<description><![CDATA[While debugging os or application crash bug on windows ce (the tool winaddr2line isn&#8217;t particularly used for windows CE application, it can be used for normal windows application too.) platform, developers may not always have the luxury to debug step by step within a IDE. Most of time, the only information available to us is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=297&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While  debugging os or application crash bug on windows ce (the tool  winaddr2line isn&#8217;t particularly used for windows CE application, it can be used for normal windows application too.) platform, developers may not always  have the luxury to debug step by step within a IDE. Most of time, the  only information available to us is the output on serial port. (It&#8217;s  already very fortunate if we can see serial port output every time a  crash happens.) What we get is something like:</p>
<div style="padding-left:40px;"><i>Exception  &#8216;Data Abort&#8217; (4): Thread-Id=06890fba(pth=88eb8948),  Proc-Id=06750f9e(pprc=88eb8828) &#8216;test.exe&#8217;,  VM-active=06750f9e(pprc=88eb8828) &#8216;test.exe&#8217;</i><br />
<i><span style="background-color:yellow;">PC=00011048(test.exe+0&#215;00001048)</span> RA=00011018(fff.exe+0&#215;00001018) SP=0002fb98, BVA=00000000</i><br />
<i><br />
</i><br />
<i>Unhandled exception c0000005:</i><br />
<i>Terminating thread 88eb8948</i></div>
<p>
Given the <a href="http://en.wikipedia.org/wiki/Program_counter">PC register</a>  value, we need to figure out on while line in our code did the  application crash. winaddr2line makes it an easy task as long as we have  the pdb symbol file for the application. It&#8217;s a attempt to port <a href="http://linux.die.net/man/1/addr2line">addr2line</a> to windows world.<br />
Let&#8217;s  take the preceding log for example. In order to find out the line  number of the code that incurs the crash, we need following information.</p>
<ol>
<li>In which module did the crash happen </li>
<li>What&#8217;s the address can we use to query</li>
</ol>
<p>For question 1, the module name is already available in the log. In our example, it&#8217;s <i>test.exe</i>. For question 2, we can see the PC register&#8217;s value is 0&#215;00011048. So, we run <i>&#8220;winaddr2line.exe -e test.exe 11048 -a -p -s -f&#8221; </i>command, and get this: <i>&#8220;0&#215;00011048: foo::crash at test.cpp:8&#8243;</i>. Now we open test.cpp and check what&#8217;s around line 8, the root cause is very obvious.</p>
<div style="background-color:#000040;color:silver;"><span style="font-family:monospace;">&nbsp;<span style="color:#90f020;">1 </span><br />
&nbsp;<span style="color:#90f020;">2 </span><span style="color:#60ff60;">class</span>&nbsp;foo<br />
&nbsp;<span style="color:#90f020;">3 </span>{<br />
&nbsp;<span style="color:#90f020;">4 </span>&nbsp;&nbsp;&nbsp; <span style="color:#ffff60;">public</span>:<br />
&nbsp;<span style="color:#90f020;">5 </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#60ff60;">void</span>&nbsp;crash()<br />
&nbsp;<span style="color:#90f020;">6 </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
&nbsp;<span style="color:#90f020;">7 </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#60ff60;">int</span> *a = NULL;<br />
&nbsp;<span style="color:#90f020;">8 </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#60ff60;">int</span>&nbsp;b = *a;<br />
&nbsp;<span style="color:#90f020;">9&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
<span style="color:#90f020;">10 </span>};<br />
<span style="color:#90f020;">11 </span><br />
<span style="color:#90f020;">12 </span><span style="color:#60ff60;">int</span>&nbsp;main (&nbsp;<span style="color:#60ff60;">int</span>&nbsp;argc,&nbsp;<span style="color:#60ff60;">char</span>&nbsp;*argv[] )<br />
<span style="color:#90f020;">13 </span>{<br />
<span style="color:#90f020;">14 </span>&nbsp;&nbsp;&nbsp; foo f;<br />
<span style="color:#90f020;">15 </span>&nbsp;&nbsp;&nbsp; f.crash();<br />
<span style="color:#90f020;">16 </span>&nbsp;&nbsp;&nbsp; <span style="color:#ffff60;">return</span>&nbsp;<span style="color:#ffa0a0;">0</span>;<br />
<span style="color:#90f020;">17 </span>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
</span></div>
<p>
In order for the preceding command to work correctly, we must make sure the test.exe and its symbol file test.pdb is available in current directory of the shell that we run winaddr2line. If it&#8217;s not the case, we should pass correct path to test.exe for -e argument and path to directory containing test.pdb for -y argument respectively.</p>
<p>In the example, we use PC register&#8217;s value directly to query line number. But it&#8217;s not always the case. Consider the crash log below:</p>
<div style="padding-left:40px;"><i>Exception &#8216;Raised Exception&#8217; (-1): Thread-Id=06891422(pth=88eb8948), Proc-Id=0675143e(pprc=88eb8828) &#8216;test.exe&#8217;, VM-active=0675143e(pprc=88eb8828) &#8216;test.exe&#8217;</i><br />
<i><span style="background-color:yellow;">PC=4006d270(coredll.dll+0x0005d270)</span> RA=80118a60(kernel.dll+0x00007a60) SP=0002fb8c, BVA=00000000</i><br />
<i><br />
</i><br />
<i>Unhandled exception c0000094:</i><br />
<i>Terminating thread 88eb8948</i></div>
<p>
The crash occurred in coredll.dll module. We run command <i>&#8220;winaddr2line.exe -e coredll.dll 4006d270 -a -p -s -f&#8221;</i>, but we can see it fails to find the line number. This is because we can&#8217;t use the PC register&#8217;s value directly here. The coredll.dll is loaded at 0&#215;40010000 (0x4006d270-0x0005d270), which is different from its preferred <a href="http://msdn.microsoft.com/en-us/library/ms680339%28VS.85%29.aspx">ImageBase</a> address (0&#215;10000000, which can be examined with <i>&#8220;dumpbin /headers coredll.dll&#8221;</i> command). And winaddr2line can only make use of the ImageBase address contained statically in PE header of the binary. So, we must change the address to 0x1005d270 (0&#215;10000000+0x0005d270). By using this address, we can see the crash occured at: <i>d:\dublin2-1\private\winceos\coreos\core\dll\crtsupp.cpp:240</i></p>
<p><b>Source code for winaddr2line:</b><br />
<a href="http://code.google.com/p/winaddr2line/">http://code.google.com/p/winaddr2line/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/297/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=297&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/06/28/addr2line-for-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>
	</item>
		<item>
		<title>quickswitch</title>
		<link>http://rxwen.wordpress.com/2011/06/01/quickswitch/</link>
		<comments>http://rxwen.wordpress.com/2011/06/01/quickswitch/#comments</comments>
		<pubDate>Tue, 31 May 2011 10:58:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/06/01/quickswitch/</guid>
		<description><![CDATA[One of the most used function on a pc is switching between tasks. We may write some code in vim, switch to firefox to search for the usage of an api. And then switch back to vim continue writing code. Most of time, we do this by using Alt+Tab key combination. But it&#8217;s not an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=296&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the most used function on a pc is switching between tasks. We may write some code in vim, switch to firefox to search for the usage of an api. And then switch back to vim continue writing code. Most of time, we do this by using Alt+Tab key combination. But it&#8217;s not an efficient way if there are many tasks running. It&#8217;s not quick enough to find the target task.</p>
<p>The main drawback with Alt+Tab is it forces us to deal with more problems. For example, we want to switch to firefox task, the essential problem we&#8217;re dealing with is finding the task using the clue &#8220;FIREFOX&#8221;. After we press Alt+Tab, we get a window list in which all tasks are identified by icons. Now, we have to deal with another problem, finding out the icon that represents firefox. That&#8217;s to say, our brain has to do a &#8220;<a href="http://en.wikipedia.org/wiki/Context_switch">context switch</a>&#8221; from the &#8220;word processing&#8221; problem to an &#8220;image recognition&#8221; problem.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm4.static.flickr.com/3482/5780317171_a88720dd9b.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" height="190" src="http://farm4.static.flickr.com/3482/5780317171_a88720dd9b.jpg" width="320" /></a></div>
<p>
It&#8217;s not intuitive at all. The idea of QuickSwitch is very similar to <a href="http://en.wikipedia.org/wiki/Spotlight_%28software%29">Spotlight </a>on mac and <a href="http://www.vim.org/scripts/script.php?script_id=1984">FuzzyFinder</a> on vim. We can keep concentrating on the &#8220;word processing&#8221; problem, no context switch.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm3.static.flickr.com/2049/5780317667_00ac266309.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm3.static.flickr.com/2049/5780317667_00ac266309.jpg" /></a></div>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm4.static.flickr.com/3112/5780864346_4549d21e7a.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm4.static.flickr.com/3112/5780864346_4549d21e7a.jpg" /></a></div>
<p>
QuickSwitch runs as a daemon. By using it, at any time we want to switch ao another task, press Ctrl+Alt+S key combination to bring up the QuickSwith main window, in which all tasks are listed. Then, type any part of the window title of the desired task and press enter to switch to it.</p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm3.static.flickr.com/2528/5780864374_07b30781f0.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm3.static.flickr.com/2528/5780864374_07b30781f0.jpg" /></a></div>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm6.static.flickr.com/5261/5780317811_a1676488db.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm6.static.flickr.com/5261/5780317811_a1676488db.jpg" /></a></div>
<div class="separator" style="clear:both;text-align:center;"><a href="http://farm6.static.flickr.com/5026/5780317849_20f836c927.jpg" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://farm6.static.flickr.com/5026/5780317849_20f836c927.jpg" /></a></div>
<p>
For instance, if we want to switch to firefox task. Type &#8220;firefox&#8221; in the input box. As we type, the window list is filtered. Those windows don&#8217;t contain the word we typed in title are filtered out. When there is only one result left in the list, we can press enter key once to switch to it. If there are more than one one result left, we can continuing typing more characters to filter out more un-desired tasks. Or we can press enter to bring focus to the result list and use up, down keys (or Ctrl+P, Ctrl+N) to select desired task and press enter again to switch to it.</p>
<p><b>Source code:</b><br />
<a href="http://code.google.com/p/quickswitch/">http://code.google.com/p/quickswitch/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/296/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=296&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/06/01/quickswitch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3482/5780317171_a88720dd9b.jpg" medium="image" />

		<media:content url="http://farm3.static.flickr.com/2049/5780317667_00ac266309.jpg" medium="image" />

		<media:content url="http://farm4.static.flickr.com/3112/5780864346_4549d21e7a.jpg" medium="image" />

		<media:content url="http://farm3.static.flickr.com/2528/5780864374_07b30781f0.jpg" medium="image" />

		<media:content url="http://farm6.static.flickr.com/5261/5780317811_a1676488db.jpg" medium="image" />

		<media:content url="http://farm6.static.flickr.com/5026/5780317849_20f836c927.jpg" medium="image" />
	</item>
		<item>
		<title>extend windows ce platform with oalioctl</title>
		<link>http://rxwen.wordpress.com/2011/04/15/extend-windows-ce-platform-with-oalioctl/</link>
		<comments>http://rxwen.wordpress.com/2011/04/15/extend-windows-ce-platform-with-oalioctl/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 12:09:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[wince]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/04/15/extend-windows-ce-platform-with-oalioctl/</guid>
		<description><![CDATA[Though not being a open source platform, windows ce is designed to be flexible so that device venders can extend it easily. oalioctl is a feature that makes it possible to do things in kernel space on behalf of application. Features 1. Extensibility The essential feature of oalioctl is it enables us to extend windows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=291&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Though not being a open source platform, windows ce is designed to be flexible so that device venders can extend it easily. <a href="http://msdn.microsoft.com/en-us/library/ms902823.aspx">oalioctl</a> is a feature that makes it possible to do things in kernel space on behalf of application. </p>
<p><b>Features</b><br />
1. Extensibility<br />
The  essential feature of oalioctl is it enables us to extend windows ce  kernel&#8217;s functions, and new functions are directly accessible to  application layer developers.<br />
2. Separation<br />
oalioctl is  completely separated from kernel source code. From the sense of code  organization, it doesn&#8217;t differ from a normal device driver. The  separation makes it easy to maintain and port oalioctl module.<br />
3. Easy to use<b><br />
</b><br />
Compared to a normal ce driver, the usage of oalioctl is  easier from an application developer&#8217;s perspective. In order to make use  of a normal driver, application usually follows below sequence:<br />
<a href="http://msdn.microsoft.com/en-us/library/ms923949.aspx">CreateFile</a> -&gt; <a href="http://msdn.microsoft.com/en-us/library/ms898288.aspx">DeviceIoControl</a> -&gt; <a href="http://msdn.microsoft.com/en-us/library/ms923946.aspx">CloseHandle</a><br />
But the application can simply call <a href="http://msdn.microsoft.com/en-us/library/ms886729.aspx">KernelIoControl</a> to make use of oalioctl library, which is a far more easy way.</p>
<p><b>Implementation</b><br />
oalioctl  is implemented as a standalone dynamic library. And it will be loaded  automatically during kernel initialization (relevant code is in  LoaderInit() function in  X:\WINCE600\PRIVATE\WINCEOS\COREOS\NK\KERNEL\loader.c). So it&#8217;s not  necessary to register this module in <a href="http://msdn.microsoft.com/en-us/library/ms895490.aspx">platform.reg as other stream drivers do</a>. <br />
When an application calls KernelIoControl, the call stack goes like this:</p>
<div style="margin-left:40px;"><i>IOControl //our own oalioctl.cpp</i><br />
<i>OEMIOControl&nbsp; // platform/common/src/common/ioctl/ioctl.c</i><br />
<i>IOControl // public/common/oak/oalioctl/oalioctl.cpp</i><br />
<i>EXTKernelIoCtl // private/winceos/coreos/nk/kernel/kwin32.c</i></div>
<p>
<b>How to implement our own oalioctl</b><br />
It&#8217;s a fair simple task to implement oalioctl layer for our own platform with following steps:</p>
<ol>
<li>copy <i>public/common/oak/oalioctl</i> directory to <i>platform/platform_name/src/drivers</i></li>
<li>change TARGETTYPE to DYNLINK in sources file </li>
<li>define our own iocontrol code with <a href="http://msdn.microsoft.com/en-us/library/ms902086.aspx">CTL_CODE</a> macro</li>
<li>add a case branch for the new iocontrol code</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/291/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=291&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/04/15/extend-windows-ce-platform-with-oalioctl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>
	</item>
		<item>
		<title>resolve windows ce remote tool connection issue</title>
		<link>http://rxwen.wordpress.com/2011/03/09/resolve-windows-ce-remote-tool-connection-issue/</link>
		<comments>http://rxwen.wordpress.com/2011/03/09/resolve-windows-ce-remote-tool-connection-issue/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 11:50:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[wince]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/03/09/resolve-windows-ce-remote-tool-connection-issue/</guid>
		<description><![CDATA[remote tools for windows ce is a set of powerful tools for debugging. I have Visual Studio 2005, Windows Embedded CE 6.0 R3 installed, but the remote tools don&#8217;t work. They fail to connect to device with following error message: The Microsoft ActiveSync reported the following error: Unable to load device side components. Please check [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=290&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/aa936010.aspx">remote tools</a> for windows ce is a set of powerful tools for debugging. I have Visual Studio 2005, Windows Embedded CE 6.0 R3 installed, but the remote tools don&#8217;t work. They fail to connect to device with following error message:<br />
<i>The Microsoft ActiveSync reported the following error: Unable to load device side components. Please check server configuration settings.</i></p>
<p>There are two ways to resolve the connection issue.</p>
<p><i><b>1. </b></i>Run remote tools from windows start menu (e.g., <i>Microsoft Visual Studio 2005\Visual Studio Remote Tools\Remote Process Viewer</i>, which is a shortcut to <i>C:\Program Files\CE Remote Tools\5.01\bin\ccpview.exe</i>), instead of starting from visual studio menu (e.g., <i>Target/Remote Tools/Process Viewer</i>, which is a shortcut to <i>C:\Program Files\Common Files\Microsoft Shared\Windows CE Tools\Platman\bin\wce600\cepview.exe</i>). remote tools version 5.01 work fine.</p>
<p><i><b>2. </b></i>Copy <br />
<i>c:\Program Files\Common Files\Microsoft Shared\Windows CE Tools\Platman\target\wce600\armV4i<span style="background-color:black;color:orange;"></span>\</i><br />
to<br />
<i>c:\Program Files\Common Files\Microsoft Shared\Windows CE Tools\Platman\target\wce600\armV4\</i><br />
. The lack of the second directory is a bug in remote tools version 6 that causes the connection issue.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/290/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=290&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/03/09/resolve-windows-ce-remote-tool-connection-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>
	</item>
		<item>
		<title>view call stack of crashed application on android</title>
		<link>http://rxwen.wordpress.com/2011/01/26/view-call-stack-of-crashed-application-on-android/</link>
		<comments>http://rxwen.wordpress.com/2011/01/26/view-call-stack-of-crashed-application-on-android/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 09:10:00 +0000</pubDate>
		<dc:creator>rxwen</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://rxwen.wordpress.com/2011/01/25/view-call-stack-of-crashed-application-on-android/</guid>
		<description><![CDATA[On android, when a process crashes in native code, the call stack of the process will be saved to a log file in /data/tombstomes/, and written to logcat as well. The information is helpful for debugging. Unfortunately, the call stack doesn&#8217;t show in human readable format, file name, function name. Instead, it&#8217;s shown as module [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=292&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On android, when a process crashes in native code, the call stack of the process will be saved to a log file in /data/tombstomes/, and written to logcat as well. The information is helpful for debugging.<br />
Unfortunately, the call stack doesn&#8217;t show in human readable format, file name, function name. Instead, it&#8217;s shown as module name (e.g., libc.so) and memory address of the instruction. We can use addr2line to translate the address to corresponding file name and function name if we have the binary of the module that contains symbol information.<br />
To make it easier to use, this function is included in <a href="http://www.blogger.com/goog_2030141568">agdb</a><a href="http://code.google.com/p/rxwen-blog-stuff/source/browse/trunk/tools/agdb.py"> tool</a> (see <a href="http://rxwen.blogspot.com/2011/01/utility-for-debugging-android-native.html">here</a> for more). We can use <b><i>&#8220;agdb.py -r -e module_name address&#8221;</i></b> to find out the function name of specified address within the module.</p>
<p>When we have a long call stack, instead of running the command above for each line in the call stack manually, we can feed the whole call stack to agdb through pipe and get the full resolved call stack. For example, use&nbsp; <i><b>&#8220;adb logcat | agdb.py -r&#8221;</b></i> command for adb logcat output with below contents:</p>
<div style="background-color:#000040;color:silver;">
<span style="color:yellow;"><b>22 </b></span>F/ASessionDescription(&nbsp;&nbsp; 33): frameworks/base/media/libstagefright/rtsp/ASessionDescription.cpp:264 CHECK_GT( end,s) failed:&nbsp;&nbsp;vs. <br />
<span style="color:yellow;"><b>23 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***<br />
<span style="color:yellow;"><b>24 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): Build fingerprint: &#8216;generic/generic/generic:2.3.1/GINGERBREAD/eng.raymond.20101222.130550:eng/test-keys&#8217;<br />
<span style="color:yellow;"><b>25 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): pid: 33, tid: 450&nbsp;&nbsp;&gt;&gt;&gt; /system/bin/mediaserver &lt;&lt;&lt;<br />
<span style="color:yellow;"><b>26 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad<br />
<span style="color:yellow;"><b>27 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;r0 deadbaad&nbsp;&nbsp;r1 0000000c&nbsp;&nbsp;r2 00000027&nbsp;&nbsp;r3 00000000<br />
<span style="color:yellow;"><b>28 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;r4 00000080&nbsp;&nbsp;r5 afd46668&nbsp;&nbsp;r6 40806c10&nbsp;&nbsp;r7 00000000<br />
<span style="color:yellow;"><b>29 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;r8 8031db1d&nbsp;&nbsp;r9 0000fae0&nbsp;&nbsp;10 00100000&nbsp;&nbsp;fp 00000001<br />
<span style="color:yellow;"><b>30 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;ip ffffffff&nbsp;&nbsp;sp 40806778&nbsp;&nbsp;lr afd19375&nbsp;&nbsp;pc afd15ef0&nbsp;&nbsp;cpsr 00000030<br />
<span style="color:yellow;"><b>31 </b></span><span style="color:yellow;">I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><b>#00&nbsp;&nbsp;pc 00015ef0&nbsp;&nbsp;/system/lib/libc.so</b><br />
<span style="color:yellow;"><b>32 </b></span><span style="color:yellow;">I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><b>#01&nbsp;&nbsp;pc 00001440&nbsp;&nbsp;/system/lib/liblog.so</b><br />
<span style="color:yellow;"><b>33 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): <br />
<span style="color:yellow;"><b>34 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): code around pc:<br />
<span style="color:yellow;"><b>35 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15ed0 68241c23 d1fb2c00 68dae027 d0042a00 <br />
<span style="color:yellow;"><b>36 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15ee0 20014d18 6028447d 48174790 24802227 <br />
<span style="color:yellow;"><b>37 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15ef0 f7f57002 2106eb56 ec92f7f6 0563aa01 <br />
<span style="color:yellow;"><b>38 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15f00 60932100 91016051 1c112006 e818f7f6 <br />
<span style="color:yellow;"><b>39 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15f10 2200a905 f7f62002 f7f5e824 2106eb42 <br />
<span style="color:yellow;"><b>40 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): <br />
<span style="color:yellow;"><b>41 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): code around lr:<br />
<span style="color:yellow;"><b>42 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd19354 b0834a0d 589c447b 26009001 686768a5 <br />
<span style="color:yellow;"><b>43 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd19364 220ce008 2b005eab 1c28d003 47889901 <br />
<span style="color:yellow;"><b>44 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd19374 35544306 d5f43f01 2c006824 b003d1ee <br />
<span style="color:yellow;"><b>45 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd19384 bdf01c30 000281a8 ffffff88 1c0fb5f0 <br />
<span style="color:yellow;"><b>46 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd19394 43551c3d a904b087 1c16ac01 604d9004 <br />
<span style="color:yellow;"><b>47 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): <br />
<span style="color:yellow;"><b>48 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): stack:<br />
<span style="color:yellow;"><b>49 </b></span>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; <br />
<span style="color:yellow;"><b>92 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;&nbsp;&nbsp; 408067e4&nbsp;&nbsp;6f697470<br />
<span style="color:yellow;"><b>93 </b></span>I/BootReceiver(&nbsp;&nbsp; 75): Copying /data/tombstones/tombstone_09 to DropBox (SYSTEM_TOMBSTONE)</div>
<p>
we get:</p>
<div style="background-color:#000040;color:silver;">
<span style="color:yellow;"><b>22 </b></span>F/ASessionDescription(&nbsp;&nbsp; 33): frameworks/base/media/libstagefright/rtsp/ASessionDescription.cpp:264 CHECK_GT( end,s) failed:&nbsp;&nbsp;vs.<br />
<span style="color:yellow;"><b>23 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***<br />
<span style="color:yellow;"><b>24 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): Build fingerprint: &#8216;generic/generic/generic:2.3.1/GINGERBREAD/eng.raymond.20101222.130550:eng/test-keys&#8217;<br />
<span style="color:yellow;"><b>25 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): pid: 33, tid: 450&nbsp;&nbsp;&gt;&gt;&gt; /system/bin/mediaserver &lt;&lt;&lt;<br />
<span style="color:yellow;"><b>26 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad<br />
<span style="color:yellow;"><b>27 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;r0 deadbaad&nbsp;&nbsp;r1 0000000c&nbsp;&nbsp;r2 00000027&nbsp;&nbsp;r3 00000000<br />
<span style="color:yellow;"><b>28 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;r4 00000080&nbsp;&nbsp;r5 afd46668&nbsp;&nbsp;r6 40806c10&nbsp;&nbsp;r7 00000000<br />
<span style="color:yellow;"><b>29 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;r8 8031db1d&nbsp;&nbsp;r9 0000fae0&nbsp;&nbsp;10 00100000&nbsp;&nbsp;fp 00000001<br />
<span style="color:yellow;"><b>30 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;ip ffffffff&nbsp;&nbsp;sp 40806778&nbsp;&nbsp;lr afd19375&nbsp;&nbsp;pc afd15ef0&nbsp;&nbsp;cpsr 00000030<br />
<span style="color:yellow;"><b>31 </b></span><span style="color:yellow;">I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><b>#00&nbsp;&nbsp;pc 00015ef0&nbsp;&nbsp;/system/lib/libc.so</b><br />
<span style="color:yellow;"><b>32 </b></span><span style="color:red;">I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>#00&nbsp;&nbsp;__libc_android_abort: abort.c:82</b></span><br />
<span style="color:yellow;"><b>33 </b></span><span style="color:yellow;">I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><b>#01&nbsp;&nbsp;pc 00001440&nbsp;&nbsp;/system/lib/liblog.so</b><br />
<span style="color:yellow;"><b>34 </b></span><span style="color:red;">I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>#01&nbsp;&nbsp;__android_log_assert: logd_write.c:235</b></span><br />
<span style="color:yellow;"><b>35 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30):<br />
<span style="color:yellow;"><b>36 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): code around pc:<br />
<span style="color:yellow;"><b>37 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15ed0 68241c23 d1fb2c00 68dae027 d0042a00<br />
<span style="color:yellow;"><b>38 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15ee0 20014d18 6028447d 48174790 24802227<br />
<span style="color:yellow;"><b>39 </b></span>I/DEBUG&nbsp;&nbsp; (&nbsp;&nbsp; 30): afd15ef0 f7f57002 2106eb56 ec92f7f6 0563aa01</div>
<p>
Similarly, we copy a tombstone file to our development pc, and use <i><b>&#8220;cat tombstone_01.txt | agdb.py -r&#8221; </b></i>command to resolve call stack addresses in the tombstone log file.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rxwen.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rxwen.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rxwen.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rxwen.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rxwen.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rxwen.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rxwen.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rxwen.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rxwen.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rxwen.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rxwen.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rxwen.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rxwen.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rxwen.wordpress.com/292/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rxwen.wordpress.com&amp;blog=5207424&amp;post=292&amp;subd=rxwen&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rxwen.wordpress.com/2011/01/26/view-call-stack-of-crashed-application-on-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e08b42344ff5b14aed396f9912e84f62?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rxwen</media:title>
		</media:content>
	</item>
	</channel>
</rss>
