<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-22080276</id><updated>2026-09-11T00:40:36.376-07:00</updated><category term="Tools"/><category term="C"/><category term="Programming"/><category term="gcc"/><category term="Windows"/><category term="Ace"/><category term="Softwares"/><category term="kernel"/><category term="make"/><category term="Internet"/><category term="Router NAS Linux"/><category term="Shopping"/><category term="Compiler"/><category term="Embedded Arm LPC1768 JTAG"/><category term="Friends"/><category term="Tips"/><title type='text'>Samuel Jacob&#39;s Web Log</title><subtitle type='html'>Here I log some of the technical things that I come across.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>40</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-22080276.post-6585676135085284628</id><published>2013-08-29T10:30:00.000-07:00</published><updated>2013-08-29T10:30:55.756-07:00</updated><title type='text'></title><content type='html'>&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;Moved to &lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;a href=&quot;http://samueldotj.com/blog&quot;&gt;samueldotj.com/blog&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/6585676135085284628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/6585676135085284628' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/6585676135085284628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/6585676135085284628'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2013/08/moved-to-samueldotj.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-1545391765856570314</id><published>2013-05-11T11:59:00.000-07:00</published><updated>2013-05-11T11:59:49.548-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ace"/><title type='text'>Self Balancing Tree as Heap</title><content type='html'>In this post I will try to explain how to combine a Heap and AVL tree and get benefit of both them from a single structure.
&lt;br /&gt;
&lt;br /&gt;
A &lt;a href=&quot;http://en.wikipedia.org/wiki/Self-balancing_binary_search_tree&quot;&gt;self balancing binary search tree&lt;/a&gt; such as &lt;a href=&quot;http://en.wikipedia.org/wiki/AVL_tree&quot;&gt;AVL tree&lt;/a&gt; can do faster lookup for a item in the tree in O(log n).&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Heap_(data_structure)&quot;&gt;Heap&lt;/a&gt;&amp;nbsp;s mainly used implement priority queues which needs to find min/max elements quickly. Heap&amp;nbsp;achieve&amp;nbsp;this in O(1) time complexity.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgupnU5r8MncZwqXHewLEdUngqFO7W3FVooQwLHzaeQzYdPzSRQ1SYOvnzxjr0FbJ-q7p4TeR6AeIKuuTLBHFl5Wes7o65XiLDdChKV5pPuWjWGTZRwMf3fg5Fejh36jRMQ3cPFlA/s1600/Balanced+BST1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;217&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgupnU5r8MncZwqXHewLEdUngqFO7W3FVooQwLHzaeQzYdPzSRQ1SYOvnzxjr0FbJ-q7p4TeR6AeIKuuTLBHFl5Wes7o65XiLDdChKV5pPuWjWGTZRwMf3fg5Fejh36jRMQ3cPFlA/s320/Balanced+BST1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Min element of a BST is always at the left most&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Lets revisit a basic property of binary search tree - In a binary search tree min element is at the left most leaf position. Similarly in a BST max element is at the right most leaf position. So finding min/max element in a BST is O(h) where h is the depth of the tree. If the BST is a balanced tree then O(h) is O(log n) in worst case(otherwise the worst case O(n), since we considering only balanced trees here lets ignore the unbalanced cases). The picture in the right illustrates this basic property of the BST.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxkVBGadwlhRuKxdSb7SCV12QblacGR_ffdlCyehWQCbqHkIg6LpGNi6rHUS2JeMUUTbvPhPczgScU-W-qwWq2FqQOgx_t0EfJbHzq_dDHs-Qk_p1qtZIJrPmEw8_5rngTasOwlQ/s1600/BST+PointerToMin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;217&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxkVBGadwlhRuKxdSb7SCV12QblacGR_ffdlCyehWQCbqHkIg6LpGNi6rHUS2JeMUUTbvPhPczgScU-W-qwWq2FqQOgx_t0EfJbHzq_dDHs-Qk_p1qtZIJrPmEw8_5rngTasOwlQ/s320/BST+PointerToMin.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Cached pointer to Min element at the root&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The first and simplest optimization comes to mind is store a pointer to min/max elements. This caching will result in O(1) time complexity for finding min/max elements. However this would increase the cost of node insert/delete because the min/max pointer has to be updated during insert and deletion. The cost of finding and deleting a min node is O(log(n)) which is same as if we havent had the cache pointers. The picture in the right shows&amp;nbsp;advantage&amp;nbsp;of having cached pointer to find a min element.&amp;nbsp;Obviously&amp;nbsp;this method cant be used for priority queues where find min/delete operation is used together.&lt;br /&gt;
&lt;br /&gt;
In the above method the problem was the complexity finding next smallest element in the tree from min element is O(log n). So if we have pointer to next smallest element from all nodes then find and delete opearation would be of complexity O(1). &lt;br /&gt;
&lt;br /&gt;
Lets look at the BST from slightly different angle. Usual declaration of BST in C as follows:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/samueldotj/5560834.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_OGyQI31JVtwC51NV0lm6WAxsXL9DQoWaHyFuX9XmdaH-JAD1D8B3588AIlo7XZbVS7oVeuU2p-rhxd_xOMLqwkKu2xTKpygG-CKcmfr7d4Vzjp2RbUutV3LAinkIBcufGHEvdQ/s1600/Balanced+BST1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;215&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_OGyQI31JVtwC51NV0lm6WAxsXL9DQoWaHyFuX9XmdaH-JAD1D8B3588AIlo7XZbVS7oVeuU2p-rhxd_xOMLqwkKu2xTKpygG-CKcmfr7d4Vzjp2RbUutV3LAinkIBcufGHEvdQ/s320/Balanced+BST1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;When we(me and&amp;nbsp;&lt;a class=&quot;g-profile&quot; href=&quot;http://plus.google.com/105622177928011443688&quot; target=&quot;_blank&quot;&gt;+Dilip Simha&lt;/a&gt;)&amp;nbsp;were implementing ADT for AceOS we decided to&amp;nbsp;experiment BST in a different way. We saw tree as recursive lists rather than a recursive pointers. In the following picture you could see 6 lists(not counting sub-lists):&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;(300, 200, 100, 50)&lt;/li&gt;
&lt;li&gt;(300, 400, 500, 600)&lt;/li&gt;
&lt;li&gt;(200, 250, 275)&lt;/li&gt;
&lt;li&gt;(100, 150)&lt;/li&gt;
&lt;li&gt;(400, 350)&lt;/li&gt;
&lt;li&gt;(500, 450)&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIb3N3cZFIgm8KlBUzk6UeEOZkWfM4vA2svt-ekhCXcuDEBTkrOwzyPLGhpsf3x7T9tqXmn38pCcPiLvRlw33wjAPH9_ivZUL7eB5OheMxRAiObgDoskqYeUwQ-vkmDCvm8N6C_A/s1600/Binary+Search+Tree+Doule+Pointer.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;219&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIb3N3cZFIgm8KlBUzk6UeEOZkWfM4vA2svt-ekhCXcuDEBTkrOwzyPLGhpsf3x7T9tqXmn38pCcPiLvRlw33wjAPH9_ivZUL7eB5OheMxRAiObgDoskqYeUwQ-vkmDCvm8N6C_A/s320/Binary+Search+Tree+Doule+Pointer.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;Now consider this list is a doubly linked circular list. This is illustrated in the following figure. You may argue that this will make the BST to become acyclic directed graph. But for the sake of simplicity lets continue to call this as balanced BST. The picture I left out few arrows to keep it cleaner.&lt;br /&gt;
&lt;br /&gt;
AVL tree in Ace OS &amp;nbsp;is implemented in this way. You can see the data structure declarations below.&amp;nbsp;Initially&amp;nbsp;we did it for reusing the code. But after implementing this we&amp;nbsp;figured out some interesting properties. This balanced tree/graph can find any node in O(log(n)) and also offers findmin&amp;nbsp;operation&amp;nbsp;in O(1) complexity. This also reduces the complexity of delete&amp;nbsp;operation(since we can find right node&#39;s left most child in O(1) operation). But delete operation might result in balancing the tree.&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/samueldotj/5560818.js&quot;&gt;&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/1545391765856570314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/1545391765856570314' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1545391765856570314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1545391765856570314'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2013/05/self-balancing-tree-as-heap.html' title='Self Balancing Tree as Heap'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgupnU5r8MncZwqXHewLEdUngqFO7W3FVooQwLHzaeQzYdPzSRQ1SYOvnzxjr0FbJ-q7p4TeR6AeIKuuTLBHFl5Wes7o65XiLDdChKV5pPuWjWGTZRwMf3fg5Fejh36jRMQ3cPFlA/s72-c/Balanced+BST1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-3276587076420433240</id><published>2012-03-31T16:21:00.001-07:00</published><updated>2013-05-02T15:29:06.260-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>GCOV internals overview</title><content type='html'>Sometime back I worked on a small project to extract &lt;a href=&quot;http://en.wikipedia.org/wiki/Code_coverage&quot;&gt;code coverage&lt;/a&gt; information created by gcc from a &lt;a href=&quot;http://www.freebsd.org/&quot;&gt;kernel&lt;/a&gt;. 
During that time I didn&#39;t find any good internal documentation about &lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc/Gcov.html&quot;&gt;gcov&lt;/a&gt;. So here I discuss about internals of GCOV.
Before jumping to the internals of GCOV here is an example from the &lt;a href=&quot;http://nixdoc.net/man-pages/openbsd/man1/gcov.1.html&quot;&gt;man &lt;/a&gt;page.

&lt;br /&gt;
&lt;pre class=&quot;mycode&quot;&gt;$ gcov -b tmp.c
&lt;span style=&quot;color: green;&quot;&gt;87.50% of 8 source lines executed in file tmp.c
80.00% of 5 branches executed in file tmp.c
80.00% of 5 branches taken  at  least  once  in  file tmp.c
50.00% of 2 calls executed in file tmp.c
Creating tmp.c.gcov.&lt;/span&gt;
Here is a sample of a resulting tmp.c.gcov file:

      main()
      {
    &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;        int i, total;
    &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;        total = 0;
   &lt;span style=&quot;color: blue;&quot;&gt;11&lt;/span&gt;        for (i = 0; i &amp;lt; 10; i++)
&lt;span style=&quot;color: green;&quot;&gt;branch 0 taken = 91%
branch 1 taken = 100%
branch 2 taken = 100%&lt;/span&gt;
   &lt;span style=&quot;color: blue;&quot;&gt;10&lt;/span&gt;        total += i;
   &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;         if (total != 45)
&lt;span style=&quot;color: green;&quot;&gt;branch 0 taken = 100%&lt;/span&gt;
  &lt;span style=&quot;color: red;&quot;&gt;######&lt;/span&gt;          printf (&quot;Failure0);
&lt;span style=&quot;color: green;&quot;&gt;call 0 never executed&lt;/span&gt;
&lt;span style=&quot;color: green;&quot;&gt;branch 1 never executed&lt;/span&gt;
             else
    &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;             printf (&quot;Success0);
&lt;span style=&quot;color: green;&quot;&gt;call 0 returns = 100%&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;    }
&lt;/pre&gt;
Note - gcov has a cool graphical frontend in Linux - &lt;a href=&quot;http://ltp.sourceforge.net/coverage/lcov/output/example/example.c.gcov.frameset.html&quot;&gt;lcov&lt;/a&gt;.

&lt;br /&gt;
As shown above gcov can show what all code path executed and how many time executed. &lt;br /&gt;
Want to try? Here is the quick example.&lt;br /&gt;
&lt;pre class=&quot;mycode&quot;&gt;$ gcc &lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html&quot;&gt;-fprofile-arcs -ftest-coverage&lt;/a&gt; your_program.c
$ ./a.out
$ gcov your_program.c
&lt;/pre&gt;
During compilation with -ftest-coverage option gcc generates a &lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Gcov-Data-Files.html&quot;&gt;&quot;.gcno&quot;&lt;/a&gt; file. It contains information about each branches in your code. While finishing execution, ./a.out creates &lt;b&gt;.gcda&lt;/b&gt; file(s) which actually contains which all branches taken. Using these there files .c(source), .gcno(block info) and .gcda(block execution count) gcov command prints the code coverage information in a human readable format.
&lt;br /&gt;
You might wonder how your ./a.out would create .gcda while exiting. It is because of &quot;-fprofile-arcs&quot; automatically includes &lt;a href=&quot;http://gcc.gnu.org/viewcvs/trunk/libgcc/libgcov.c?view=markup&quot;&gt;libgcov &lt;/a&gt;. Libgcov registers itself to be invoked during program exit by using &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/009604599/functions/atexit.html&quot;&gt;atexit()&lt;/a&gt;. (Yes - it wont generate .gcda files if you exit abnormally). And during program &lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html&quot;&gt;exit&lt;/a&gt; it just dumps all the branch information to one or more gcda file. 
&lt;br /&gt;
The coverage information is &quot;just&quot; dumped into files by libgcov. So who collects the the coverage information at run time? Actually the program itself collects the coverage information. In-fact only it can collect because only it knew which all code path it takes. The code coverage information is collected at runtime on the fly. It is accomplished by having a counter for each branch. For example consider the following program.
&lt;br /&gt;
&lt;pre class=&quot;mycode&quot;&gt;  &lt;span style=&quot;color: red;&quot;&gt;int if_counter = 0, else_counter = 0;&lt;/span&gt;

  &lt;span style=&quot;color: green;&quot;&gt;void dump_counters()
  {
      int fd;
      fd = open(strcat(filename, &quot;.gcda&quot;), &quot;w&quot;);
      write(fd, if_counter, sizeof(if_counter));
      write(fd, else_counter, sizeof(else_counter));
  }&lt;/span&gt;

  int main()
  {
     int a = 1;

     &lt;span style=&quot;color: green;&quot;&gt;atexit(dump_counters);&lt;/span&gt;

     a = a++ + (a * --a) + a--;
     if(a) {
        &lt;span style=&quot;color: red;&quot;&gt;if_counter++;&lt;/span&gt;
        printf(&quot;not zero\n&quot;);
     } else {
        &lt;span style=&quot;color: red;&quot;&gt;else_counter++;&lt;/span&gt;
        printf(&quot;zero\n&quot;);
     }
  }
&lt;/pre&gt;
In the above example if you replace the colored code with gcov equivalent then green colored code is implemented inside libgcov and red colored code is implanted inside your code by gcc. It is easy to understand how the increment operation can be implanted inside your code by gcc. It just inserts &lt;b&gt;&quot;inc &lt;i&gt;x-counter&lt;/i&gt;&quot;&lt;/b&gt; machine instruction before and after every branch. It should be noted that &quot;inc&quot; machine specific instruction might have side effect on some programs which uses asm inside C. For example in x86 the &quot;&lt;a href=&quot;http://maven.smith.edu/~thiebaut/ArtOfAssembly/CH06/CH06-2.html#HEADING2-117&quot;&gt;inc&lt;/a&gt;&quot; instruction affects &lt;a href=&quot;http://en.wikibooks.org/wiki/X86_Assembly/X86_Architecture#EFLAGS_Register&quot;&gt;carry flag&lt;/a&gt;. Some assembly code might depends on this and if gcc inserts &quot;inc counter&quot; instruction then it will result in error. I had hard time figuring this out when compiled with -fprofile-arcs a kernel was booting but not able to receive any network packets(it was discarding all packets because the network stack found the &lt;a href=&quot;http://www.netfor2.com/checksum.html&quot;&gt;checksum&lt;/a&gt; was wrong).
&lt;br /&gt;

&lt;pre class=&quot;mycode&quot;&gt;
  1 int main()
  2 {
  3     int a = 1;
  4
  5     if (a) {
  6         a++;
  7     } else {
  8         a--;
  9     }
 10
 11     return a;
 12 }
 13
&lt;/pre&gt;

Here is the disassembly (&lt;b&gt;gcc -g3 test.c;objdump -S -d ./a.out&lt;/b&gt;)

&lt;pre class=&quot;mycode&quot;&gt;
int main()
{
  4004b4:       55                      push   %rbp
  4004b5:       48 89 e5                mov    %rsp,%rbp
    int a = 1;
  4004b8:       c7 45 fc 01 00 00 00    movl   $0x1,-0x4(%rbp)

    if (a) {
  4004bf:       83 7d fc 00             cmpl   $0x0,-0x4(%rbp)
  4004c3:       74 06                   je     4004cb &amp;lt;main+0x17&amp;gt;
        a++;
  4004c5:       83 45 fc 01             addl   $0x1,-0x4(%rbp)
  4004c9:       eb 04                   jmp    4004cf &amp;lt;main+0x1b&amp;gt;
    } else {
        a--;
  4004cb:       83 6d fc 01             subl   $0x1,-0x4(%rbp)
    }

    return a;
  4004cf:       8b 45 fc                mov    -0x4(%rbp),%eax
}
&lt;/pre&gt;

After compiling with profile-arcs, the disassembly looks like

&lt;pre class=&quot;mycode&quot;&gt;
int main()
{
  400c34:       55                      push   %rbp
  400c35:       48 89 e5                mov    %rsp,%rbp
  400c38:       48 83 ec 10             sub    $0x10,%rsp
    int a = 1;
  400c3c:       c7 45 fc 01 00 00 00    movl   $0x1,-0x4(%rbp)

    if (a) {
  400c43:       83 7d fc 00             cmpl   $0x0,-0x4(%rbp)
  400c47:       74 18                   je     400c61 &amp;lt;main+0x2d&amp;gt;
        a++;
  400c49:       83 45 fc 01             addl   $0x1,-0x4(%rbp)
&lt;span style=&quot;color: red;&quot;&gt;  400c4d:       48 8b 05 3c 25 20 00    mov    0x20253c(%rip),%rax        # 603190 &amp;lt;dtor_idx.6460+0x8&amp;gt;
  400c54:       48 83 c0 01             add    $0x1,%rax
  400c58:       48 89 05 31 25 20 00    mov    %rax,0x202531(%rip)        # 603190 &amp;lt;dtor_idx.6460+0x8&amp;gt;&lt;/span&gt;
  400c5f:       eb 16                   jmp    400c77 &amp;lt;main+0x43&amp;gt;
    } else {
        a--;
  400c61:       83 6d fc 01             subl   $0x1,-0x4(%rbp)
&lt;span style=&quot;color: red;&quot;&gt;  400c65:       48 8b 05 2c 25 20 00    mov    0x20252c(%rip),%rax        # 603198 &amp;lt;dtor_idx.6460+0x10&amp;gt;
  400c6c:       48 83 c0 01             add    $0x1,%rax
  400c70:       48 89 05 21 25 20 00    mov    %rax,0x202521(%rip)        # 603198 &amp;lt;dtor_idx.6460+0x10&amp;gt;&lt;/span&gt;
    }

    return a;
  400c77:       8b 45 fc                mov    -0x4(%rbp),%eax
}
  400c7a:       c9                      leaveq
  400c7b:       c3                      retq
&lt;/pre&gt;

From the above disassembly it might seem putting inc instruction while compiling is easy. But how/where storage for the counters(dtor_idx.6460 and dtor_idx.6460 in above example) are created. GCC uses statically allocated memory. Dynamically allocating space is one way but it would complicate the code(memory allocation operations during init) and might slow down execution of program(defer pointer). To avoid that gcc allocates storage as a loadable section.

&lt;br /&gt;

The compiler keep tracks of all the counters in a single file. The data structure outlined in the below picture.
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVZlO4PfXILrTxxfrF0AIoHVnEnMHOL3X6i2ZCGU828dnW0PmaH9YlcrMfSgrOsmyikUH2tMeyu7q-R2fuq8EZImx0JQPQLv4Vk-RXEDQ5P3BKg6GcIif7UINaZ2ioCtff1up83g/s1600/gcov.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;293&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVZlO4PfXILrTxxfrF0AIoHVnEnMHOL3X6i2ZCGU828dnW0PmaH9YlcrMfSgrOsmyikUH2tMeyu7q-R2fuq8EZImx0JQPQLv4Vk-RXEDQ5P3BKg6GcIif7UINaZ2ioCtff1up83g/s400/gcov.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;br /&gt;&lt;br /&gt;

There is a single gcov_info structure for a C file. And multiple gcov_fn_info and gcov_ctr_info. During program exit() these structures are dumped into the .gcda file. For a project(with multiple C files) each C file will have a gcov_info structure. These gcov_info structures should be linked together so that during exit() the program can generate .gcda file for all the C files. This is done by using constructors and destructors. 

&lt;br /&gt;&lt;br /&gt;
Generic C constructor:&lt;br\&gt;
gcc generates constructors for all program. C constructors are accomplished by using &quot;.ctors&quot; section of ELF file. This section contains array of function pointers. This array is iterated and each function is invoked by _init()-&gt;__do_global_ctors_aux() during program start. _init() is placed &quot;.init&quot; section so it will be called during program initialization. A function can be declared as constructor by using function &lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Function-Attributes.html&quot;&gt;attribute&lt;/a&gt;.
&lt;br /&gt;&lt;br /&gt;

&quot;-ftest-coverage&quot; creates a constructor per file. This constructor calls __gcov_init() and passes the gcov_info as argument.

&lt;pre class=&quot;mycode&quot;&gt;
samuel@ubuntu:~$objdump  -t ./a.out  | grep -i _GLOBAL__
0000000000400c7c l     F .text  0000000000000010              _GLOBAL__sub_I_65535_0_main
&lt;/pre&gt;

And disassembly of _GLOBAL__sub_I_65535_0_main
&lt;pre class=&quot;mycode&quot;&gt;
 954 0000000000400c7c &lt;_GLOBAL__sub_I_65535_0_main&gt;:
 955   400c7c:       55                      push   %rbp
 956   400c7d:       48 89 e5                mov    %rsp,%rbp
 957   400c80:       bf 00 31 60 00          mov    $0x603100,%edi
 958   400c85:       e8 a6 12 00 00          callq  401f30 &lt;__gcov_init&gt;
 959   400c8a:       5d                      pop    %rbp
 960   400c8b:       c3                      retq
 961   400c8c:       90                      nop
 962   400c8d:       90                      nop
 963   400c8e:       90                      nop
 964   400c8f:       90                      nop
&lt;/pre&gt;

gcov_init() implemented in libgcov stores all the gcov_info() passed in a linked list. This linked list is used to walk through all the gcov_info during program termination.</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/3276587076420433240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/3276587076420433240' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3276587076420433240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3276587076420433240'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2012/04/gcov-internal-overview.html' title='GCOV internals overview'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVZlO4PfXILrTxxfrF0AIoHVnEnMHOL3X6i2ZCGU828dnW0PmaH9YlcrMfSgrOsmyikUH2tMeyu7q-R2fuq8EZImx0JQPQLv4Vk-RXEDQ5P3BKg6GcIif7UINaZ2ioCtff1up83g/s72-c/gcov.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-6833503327160749250</id><published>2012-02-27T19:27:00.000-08:00</published><updated>2012-04-01T18:57:41.637-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Graph your data</title><content type='html'>System statistics are hard interpolate since usually they are collected in large quantities and sometimes represents large numbers. Recently I was doing a prototype and wanted to measure how much damage it would to the main project (in terms of performance); so used &lt;a href=&quot;http://software.intel.com/en-us/articles/intel-performance-counter-monitor/&quot;&gt;performance counter feature&lt;/a&gt; in the processor to measure some events(cache miss, memory read etc) with and without my code change. But after looking at the numbers I realized it is difficult to analyze such a data. Because each number is 8 digit and I had 16 columns(16 cpu) and 100 rows of data(100 seconds of run).
So I decided to use some graph so that it would be easy to understand the data. 

&lt;br /&gt;
Googled for a GNU graph tool and found &lt;a href=&quot;http://gnuplot.info/&quot;&gt;gnu plot&lt;/a&gt; - this blog is to show how good it is and how easy it is to use. Consider using it if you have lot of numbers.

For this post I took some sample data from my ubuntu machine while running &lt;a href=&quot;http://weather.ou.edu/~apw/projects/stress/&quot;&gt;stress &lt;/a&gt;command.(&lt;i&gt;stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --hdd 2  --timeout 200s&lt;/i&gt;)
&lt;br /&gt;
&lt;pre class=&quot;mycode&quot;&gt;#sudo vmstat -n 1 200 &amp;gt; stat.txt
#cat stat.txt
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0 251124 1827388   4720  32704    6   34    19    38   42   74  1  0 98  1
 0  0 251124 1827388   4720  32708    0    0     0     0  104   71  0  0 100  0
13  3 251108 1349912   4728 322540    4    0     4    20  683 1789 42 12 47  0
11  3 251008 1382620   4728 322520  180    0   180     0 1604 1233 89 12  0  0
11  3 251008 1432052   4728 322520    0    0     0     0 1361 1237 90 10  0  0
11  3 251008 1298352   4728 322668    0    0     0     0 1392 1275 90 10  0  0
 2  3 251008 1512576   4728 323524    0    0     0     0 20077 14827 59 16 13 12
 0  0 251008 1826388   4728  32756    0    0     0     0 45069 25566  0  4 25 71
 0  0 251008 1826444   4728  32708    0    0     0     0   59   46  0  0 100  0
...
&lt;/pre&gt;
The following example shows how to create line graph for us,sy columns in the above against time(seconds).

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicg7wPb3iEpyerHWNUAOfmq7mZWbMwrf9jDqSlm9PWLUsZuYmMSRBLbAAWgYi4eQribT-47bKk3C-RDpfzYznlzKfvAUGb7LJ12WQAzkw8h4N7ULlgPBoRcGSVGwwlS2kwHIumgA/s1600/output.jpg&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicg7wPb3iEpyerHWNUAOfmq7mZWbMwrf9jDqSlm9PWLUsZuYmMSRBLbAAWgYi4eQribT-47bKk3C-RDpfzYznlzKfvAUGb7LJ12WQAzkw8h4N7ULlgPBoRcGSVGwwlS2kwHIumgA/s1600/output.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
This graph might not be impressive because it deals with only numbers ranging from 0-100 and the numbers are very steady. Consider a range 0-99999999 and the numbers are fluctuating too much then it will be to graph.

The above graph was created by running &quot;gnuplot&quot; with following commands

&lt;br /&gt;
&lt;pre class=&quot;mycode&quot;&gt;set title &#39;CPU usage&#39;
#set terminal svg butt enhanced dynamic
set terminal jpeg
set output &#39;output.jpg&#39;
set xlabel &#39;seconds&#39;
#set logscale y
set ylabel &#39;cpu&#39;
set key below
plot \
    &quot;stat.txt&quot; using :13 title &#39;Application&#39; with lines lc rgb &#39;blue&#39;, \
    &quot;stat.txt&quot; using :14 title &#39;Kernel&#39; with lines lc rgb &#39;green&#39;
&lt;/pre&gt;
You can also intermix two or more datafiles. The following example shows how to graph two different samples collected during different time period.
&lt;br /&gt;
&lt;pre class=&quot;mycode&quot;&gt;set title &#39;CPU usage&#39;
#set terminal svg butt enhanced dynamic
set terminal jpeg
set output &#39;output.jpg&#39;
set xlabel &#39;seconds&#39;
#set logscale y
set ylabel &#39;cpu&#39;
set key below
plot \
    &quot;stat.txt&quot; using :13 title &#39;Application&#39; with lines lc rgb &#39;light-green&#39;, \
    &quot;stat.txt&quot; using :14 title &#39;Kernel&#39; with lines lc rgb &#39;light-red&#39;, \
    &quot;stat1.txt&quot; using :13 title &#39;Application1&#39; with lines lc rgb &#39;dark-green&#39;, \
    &quot;stat1.txt&quot; using :14 title &#39;Kernel1&#39; with lines lc rgb &#39;dark-red&#39;
&lt;/pre&gt;
The stat1.txt file is generated by running &lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl8_vmstat.htm&quot;&gt;vmstat &lt;/a&gt;while the system was stressed by &lt;i&gt;stress --cpu 4 --io 2 --vm 4 --vm-bytes 1M --hdd 2 --hdd-bytes 4096 --timeout 200s&lt;/i&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEictjH9myDgiFO_gw9zfcaboS0WeXHTz0riqUVwKh8spKx-HOLfMbd1WaHtf0-_KoZoVFs2wcApHuGPnHceE5KPUGcijng72Eqf907HUszKemXz1t1LniVou4MSOe22RSxz4orTxg/s1600/output.jpg&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEictjH9myDgiFO_gw9zfcaboS0WeXHTz0riqUVwKh8spKx-HOLfMbd1WaHtf0-_KoZoVFs2wcApHuGPnHceE5KPUGcijng72Eqf907HUszKemXz1t1LniVou4MSOe22RSxz4orTxg/s1600/output.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
The nice thing about gnuplot is it will skip the row(line) in the data file if it cant recognize the columns. And also it supports svg and pdf outputs.

See what all gnuplot can do at the official &lt;a href=&quot;http://gnuplot.sourceforge.net/demo/&quot;&gt;demo page&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/6833503327160749250/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/6833503327160749250' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/6833503327160749250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/6833503327160749250'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2012/02/graph-your-data.html' title='Graph your data'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicg7wPb3iEpyerHWNUAOfmq7mZWbMwrf9jDqSlm9PWLUsZuYmMSRBLbAAWgYi4eQribT-47bKk3C-RDpfzYznlzKfvAUGb7LJ12WQAzkw8h4N7ULlgPBoRcGSVGwwlS2kwHIumgA/s72-c/output.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-288083102394070600</id><published>2011-05-22T06:04:00.002-07:00</published><updated>2011-05-29T09:42:00.568-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Arm LPC1768 JTAG"/><title type='text'>OpenOCD and NGX USB ARM JTAG</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhreJ1aILtvoipOiGwvcTKW-Nc5JvXOMe6zsnG9Yx0UVY_BFn0F6euewZ9Gruj2Bri2oeqZhUEYM0lTz4qgz5KF_vKjV9m-76WyNsFt5rkq99thJUoqL3JcH89bt73LLdlyJuv4nA/s1600/usb_jtag.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhreJ1aILtvoipOiGwvcTKW-Nc5JvXOMe6zsnG9Yx0UVY_BFn0F6euewZ9Gruj2Bri2oeqZhUEYM0lTz4qgz5KF_vKjV9m-76WyNsFt5rkq99thJUoqL3JcH89bt73LLdlyJuv4nA/s320/usb_jtag.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;This post describes the steps needed to make &lt;a href=&quot;http://shop.ngxtechnologies.com/product_info.php?cPath=26&amp;amp;products_id=30&quot;&gt;NGX’s USB ARM JTAG&lt;/a&gt; to work with &lt;a href=&quot;http://openocd.berlios.de/web/&quot;&gt;OpenOCD &lt;/a&gt;in windows 7. This &lt;a href=&quot;http://en.wikipedia.org/wiki/Joint_Test_Action_Group&quot;&gt;JTAG &lt;/a&gt;is compatible with &lt;a href=&quot;http://www.coocox.org/Colink.htm&quot;&gt;colink &lt;/a&gt;JTAG and works with&lt;a href=&quot;http://www.iar.com/&quot;&gt; IAR Workbench&lt;/a&gt; and &lt;a href=&quot;http://www.keil.com/uvision/&quot;&gt;Keil uVision&lt;/a&gt;. To use with these IDEs there is a well defined methods/plug-ins available in the product page and in internet. However to use this JTAG with OpenOCD there is scarce resource in the internet.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;OpenOCD can be used to low level debugging, source level debugging (through GDB) and can be used for flashing. OpenOCD exposes a command line interface which can be accessed through telnet. It also provides remote GDB server which also can be reached through TCP connection.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Steps needed for Windows:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;1)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Plug-In the JTAG to a available USB connector&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;2)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Download libusb-win32 from &lt;a href=&quot;http://sourceforge.net/projects/libusb-win32/files/&quot;&gt;http://sourceforge.net/projects/libusb-win32/files/&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;3)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Extract libusb-win32 to a folder and run “inf-wizard.exe”&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;4)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Select “USB Serial Converter A” and install driver&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;5)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Download and install openocd from &lt;a href=&quot;http://www.freddiechopin.info/index.php/en/download/category/4-openocd&quot;&gt;http://www.freddiechopin.info/index.php/en/download/category/4-openocd&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;6)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Attach the JTAG probe to your target ARM board and poweron the target board&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;7)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Create a openocd configurations file (see at the end)&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;8)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Run openocd.exe –f &lt;file&gt; &lt;/file&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;&quot;&gt;9)&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Run putty or telnet and connect to port localhost:4444&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;After this the target board will respond to JTAG commands which can be issued through the telnet session.&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;For GDB debugging, you need a cross compiled GDB which can be downloaded from&amp;nbsp;&lt;/o:p&gt;&lt;a href=&quot;http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite&quot;&gt;http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite&lt;/a&gt;.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;After launching&amp;nbsp;arm-none-eabi-gdb.exe run &quot;target remote localhost:3333&quot; to start remote debugging. You can execute low level JTAG commands from GDB by using &quot;monitor &lt;jtag command=&quot;&quot;&gt;&quot; command.&lt;/jtag&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;Flashing can be done using the following commands:&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;reset&lt;br /&gt;
halt&lt;br /&gt;
sleep 200&lt;br /&gt;
wait_halt&lt;br /&gt;
flash probe 0&lt;br /&gt;
flash info 0&lt;br /&gt;
flash write_image erase unlock &lt;br /&gt;
sleep 200&lt;br /&gt;
reset run&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Open OCD configuration file: &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;# openocd configurations&lt;br /&gt;
telnet_port 4444&lt;br /&gt;
&lt;br /&gt;
# gdb configuration&lt;br /&gt;
gdb_port 3333&lt;br /&gt;
&lt;br /&gt;
# cpu configuration&lt;br /&gt;
source [find target/lpc1768.cfg]&lt;br /&gt;
&lt;br /&gt;
# interface configuration&lt;br /&gt;
interface ft2232&lt;br /&gt;
ft2232_vid_pid 0x0403 0x6010&lt;br /&gt;
ft2232_device_desc &quot;NGX JTAG&quot;&lt;br /&gt;
ft2232_layout &quot;oocdlink&quot;&lt;br /&gt;
ft2232_latency 2&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/288083102394070600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/288083102394070600' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/288083102394070600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/288083102394070600'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2011/05/openocd-and-ngx-usb-arm-jtag.html' title='OpenOCD and NGX USB ARM JTAG'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhreJ1aILtvoipOiGwvcTKW-Nc5JvXOMe6zsnG9Yx0UVY_BFn0F6euewZ9Gruj2Bri2oeqZhUEYM0lTz4qgz5KF_vKjV9m-76WyNsFt5rkq99thJUoqL3JcH89bt73LLdlyJuv4nA/s72-c/usb_jtag.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-1303793687576670374</id><published>2011-03-12T07:43:00.004-08:00</published><updated>2011-06-10T02:58:55.133-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Router NAS Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Softwares"/><title type='text'>Wirless Router, Network Storage and Media Server: Software Pieces</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
This is the followup post of &lt;a href=&quot;http://samueldotj.blogspot.com/2011/02/how-to-create-your-own-wireless-router.html&quot;&gt;Router/Network Storage Server&lt;/a&gt;. Here I document about the different software used to make my RCN. Here is the different pieces needed.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Operating System&lt;/li&gt;
&lt;li&gt;Router&lt;/li&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;li&gt;Media Server&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Operating System&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
There are two open source choices &lt;a href=&quot;http://www.freebsd.org/&quot;&gt;BSD &lt;/a&gt;(FreeBSD) or &lt;a href=&quot;http://www.ubuntu.com/&quot;&gt;Linux&lt;/a&gt;(ubuntu). After few days of analysis I decided to go with Linux - because in my work I use FreeBSD. In either case I didnt want to use &lt;a href=&quot;http://freenas.org/&quot;&gt;FreeNAS &lt;/a&gt;or &lt;a href=&quot;http://www.openfiler.com/&quot;&gt;OpenFiler &lt;/a&gt;or anyother ready made distro. Since I am familiar with Ubuntu - I decided to use it - the &lt;a href=&quot;http://www.ubuntu.com/business/server/overview&quot;&gt;Ubuntu server&lt;/a&gt; version.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;File System&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Wanted to use &lt;a href=&quot;http://en.wikipedia.org/wiki/ZFS&quot;&gt;ZFS &lt;/a&gt;on my main storage disk but it is not available on Linux yet, so decided to go with &lt;a href=&quot;http://en.wikipedia.org/wiki/XFS&quot;&gt;XFS&lt;/a&gt;.  EXT3/4 on the boot disk because it is natively supported and no extra package needed. The boot media is 8GB flash disk.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Installation&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Since there is no optical disk, installation should be through network or USB. Since most of the Linux distributions supports that I decided to use USB.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.ubuntu.com/business/get-ubuntu/download&quot;&gt;Download ubuntu 10.10 server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/&quot;&gt;Download universal USB installer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Create bootable install media using the installer&lt;/li&gt;
&lt;li&gt;Boot the system with boot media - My dual port monitor and wireless keyboards came handy in this situation because I could switch between Windows and Linux installation.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;b&gt;Partitions&lt;/b&gt;&lt;br /&gt;
Although no data is going to be stored in the boot media, it would be good to have separate partitions to store the config files and home directory. Otherwise re-installation would wipe out all the data.&lt;br /&gt;
&lt;br /&gt;
I chose to create 5 partitions &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;/     - EXT4 - 2GB&lt;br /&gt;
/usr  - EXT4 - 2GB &lt;br /&gt;
/var  - EXT4 - 2GB&lt;br /&gt;
/home - EXT4 - 1GB&lt;br /&gt;
swap  -      - 1GB&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Administration&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Since this device will run without any Monitor and Keyboard only way to communicate with the system is through network interface. Having SSH access is good but still having a web interface for common administration access is better. Few Linux applications are available for that my choice is &lt;a href=&quot;http://www.webmin.com/&quot;&gt;Webmin&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.webmin.com/deb.html&quot;&gt;How to install webmin on Ubuntu&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;sudo vi /etc/apt/sources.list &lt;br /&gt;
wget http://www.webmin.com/jcameron-key.asc &lt;br /&gt;
sudo apt-key add jcameron-key.asc &lt;br /&gt;
sudo apt-get update &lt;br /&gt;
sudo apt-get install webmin &lt;/div&gt;&lt;br /&gt;
After this the machine can be controlled from local network - https://hostname:10000/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Shutdown&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Shutting down the system should be easy. Since the storage is connected to the system it cant be power off directly. The file system data should be syncd first. Using command line or web interface is not realistic. So programming the ATX power switch is the only way - acpid does that.&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;sudo apt-get install acpid&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Storage&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The goal was to create file based storage which is accessible from my home network. The &lt;a href=&quot;http://en.wikipedia.org/wiki/Network-attached_storage&quot;&gt;NAS server&lt;/a&gt; should be big enough for atleast next 2 years. It should be fast enough to view videos from it without flickering. It should have hardware fault tolerance. It should have a back up facility.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Space&lt;/b&gt;: 1TB is big enough for me.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Speed&lt;/b&gt;: Each disk has 64MB cache on board which is sufficient to buffer the read/write operations. RAID 1 can fasten read operations by queuing it on different disks(write it cant.Yet to check how Linux implements this.)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Backup&lt;/b&gt;: cron job to write create compressed tars on external disks? Need to explore other better software availability.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Fault Tollernce&lt;/b&gt;: &lt;a href=&quot;http://en.wikipedia.org/wiki/RAID&quot;&gt;RAID &lt;/a&gt;(Redundant arrays of inexpensive disks)&lt;br /&gt;
&lt;br /&gt;
Although few of my desktop boards had RAID option in the BIOS menu, I never used it and never explored it.I thought RAID chipsets in a motherboard is equivalent to RAID controllers/adapters. It was one of the decideding factor I favoured for Gigabyte(GA-D425TUD) motherboard with JMicron RAID chipset over Intel(D525MO) motherboard.&lt;br /&gt;
&lt;br /&gt;
After configuring RAID in the BIOS and starting Linux I realized it is not true raid. Because Linux recognized as fakeraid. In simple terms fakeraid is a firmware based RAID. That is all the work is still to be done in software yielding no performance benefit. Advantage of fakeraid is multiple OS which runs on same box can utiltize the same RAID. Since my setup wont have multiboot option, I dont want the fakeraid so decided to go with pure software RAID 0.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Create software raid using multiple devices(md) interface.&lt;br /&gt;
&lt;b&gt;mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;The above command will take some time (around 6 hours) because it needs to sync the contents of both disks. While it is doing that the status can be checked by using the following command&lt;br /&gt;
&lt;b&gt;cat /proc/mdstat&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Then create a XFS file system on the md device&lt;br /&gt;
&lt;b&gt;mkfs.xfs /dev/md0&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Store the configuration&lt;br /&gt;
&lt;b&gt;mdadm --detail --scan &amp;gt; /etc/mdadm/mdadm.conf&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Create mount point and add the mount information in the /etc/fstab&lt;br /&gt;
&lt;b&gt;mkdir /mnt/raid&lt;br /&gt;
echo &quot;/dev/md0        /mnt/raid       xfs     defaults            1       2&quot; &amp;gt;&amp;gt; /etc/fstab&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
After this /mnt/raid can be made accessible to remote machines through either NFS or through Windows File Sharing.&amp;nbsp;For Windows File Sharing&amp;nbsp;&lt;a href=&quot;http://www.samba.org/&quot;&gt;samba &lt;/a&gt;service needed to installed&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;sudo apt-get install samba&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Use webmin to configure samba “Servers”-&amp;gt;”Samba File sharing”. Add the storage mount point here.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Router&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The routing functionality is very simple - handle all 3 interfaces with some limitations.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;First interface eth0 is a Gigabit ethernet interface which is directly connected to the a desktop computer.&lt;/li&gt;
&lt;li&gt;Second interface eth1 is a Fast ethernet interface which is directly connected to internet(connected to a ADSL modem).&lt;/li&gt;
&lt;li&gt;Third interface is 802.11n wireless network.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Network and IP&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
All interfaces are in different networks. All interface should get static interface while booting up. This router should provide dynamic IP to the other machines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrXuakEv9tuDlJIK9tPOGJ_BW-qrGxTge-g3aLNlaLRoVns_4BRepERd_PC7oq7pJov4179nPdRPIN1OSu8NanPlE8BAdIAkQE5XVc26Igy2HawpjGsI5rsBXoD0aS5TIjVqmldg/s1600/Network.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrXuakEv9tuDlJIK9tPOGJ_BW-qrGxTge-g3aLNlaLRoVns_4BRepERd_PC7oq7pJov4179nPdRPIN1OSu8NanPlE8BAdIAkQE5XVc26Igy2HawpjGsI5rsBXoD0aS5TIjVqmldg/s400/Network.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Modify &lt;b&gt;/etc/network/interface&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;# This file describes the network interfaces available on your system&lt;br /&gt;
# and how to activate them. For more information, see interfaces(5).&lt;br /&gt;
&lt;br /&gt;
# The loopback network interface&lt;br /&gt;
auto lo&lt;br /&gt;
iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
# The primary network interface&lt;br /&gt;
auto eth0&lt;br /&gt;
iface eth0 inet static&lt;br /&gt;
address 192.168.1.2&lt;br /&gt;
netmask 255.255.255.0&lt;br /&gt;
gateway 192.168.100.2&lt;br /&gt;
post-up iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
up /etc/init.d/dhcp3-server start&lt;br /&gt;
&lt;br /&gt;
#wireless network&lt;br /&gt;
auto wlan0&lt;br /&gt;
iface wlan0 inet static&lt;br /&gt;
address 192.168.2.1&lt;br /&gt;
netmask 255.255.255.0&lt;br /&gt;
gateway 192.168.100.2&lt;br /&gt;
up /etc/init.d/dhcp3-server start&lt;br /&gt;
&lt;br /&gt;
#wan interface&lt;br /&gt;
auto eth1&lt;br /&gt;
iface eth1 inet static&lt;br /&gt;
address 192.168.100.2&lt;br /&gt;
netmask 255.255.255.0&lt;br /&gt;
gateway 192.168.100.1&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Modify&lt;b&gt; /etc/dhcp3/dhcpd.conf&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;subnet 192.168.1.0 netmask 255.255.255.0 {&lt;br /&gt;
range 192.168.1.100 192.168.1.200;&lt;br /&gt;
option domain-name-servers 208.67.222.222, 208.67.220.220;&lt;br /&gt;
option routers 192.168.1.2;&lt;br /&gt;
option broadcast-address 192.168.1.255;&lt;br /&gt;
default-lease-time 600;&lt;br /&gt;
max-lease-time 7200;&lt;br /&gt;
}&lt;br /&gt;
subnet 192.168.2.0 netmask 255.255.255.0 {&lt;br /&gt;
range 192.168.2.100 192.168.2.200;&lt;br /&gt;
option domain-name-servers 208.67.222.222, 208.67.220.220;&lt;br /&gt;
option routers 192.168.2.1;&lt;br /&gt;
option broadcast-address 192.168.2.255;&lt;br /&gt;
default-lease-time 600;&lt;br /&gt;
max-lease-time 7200;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
Finally enable forwarding in Linux kernel by setting the system tunable &quot;/proc/sys/net/ipv4/ip_forward&quot; to 1&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To set it during boot set it in &lt;b&gt;/etc/sysctl.conf&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Still few work is pending to make the desktop to connect to network - &lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;NAT and Firewall.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Network_address_translation&quot;&gt;NAT - Network Address Translation&lt;/a&gt;&lt;br /&gt;
NAT is required on eth1 to translate addresses on any outgoing packets and incoming packets. &lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;INTIF=&quot;eth0&quot;&lt;br /&gt;
EXTIF=&quot;eth1&quot;&lt;br /&gt;
&lt;br /&gt;
#set default polices and flush&lt;br /&gt;
iptables -P INPUT ACCEPT&lt;br /&gt;
iptables -F INPUT&lt;br /&gt;
iptables -P OUTPUT ACCEPT&lt;br /&gt;
iptables -F OUTPUT&lt;br /&gt;
iptables -P FORWARD DROP&lt;br /&gt;
iptables -F FORWARD&lt;br /&gt;
#setup NAT&lt;br /&gt;
iptables -t nat -F&lt;br /&gt;
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE&lt;br /&gt;
&lt;br /&gt;
iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
INTIF1=&quot;wlan0&quot;&lt;br /&gt;
iptables -A FORWARD -i $EXTIF -o $INTIF1 -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
iptables -A FORWARD -i $INTIF1 -o $EXTIF -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
iptables -A FORWARD -i $INTIF -o $INTIF1 -j ACCEPT&lt;br /&gt;
iptables -A FORWARD -i $INTIF1 -o $INTIF -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
#unblock certain services&lt;br /&gt;
#webmin&lt;br /&gt;
iptables -A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Wireless&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Now it is time to setup the wireless interface. Assuming the wireless are drivers are present in the kernel. The other tool requied is &lt;b&gt;hostapd&lt;/b&gt;. hostapd&amp;nbsp;implements IEEE 802.11 access point management.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;mycode&quot;&gt;interface=wlan0&lt;br /&gt;
driver=nl80211&lt;br /&gt;
&lt;br /&gt;
ctrl_interface=/var/run/hostapd&lt;br /&gt;
ctrl_interface_group=0&lt;br /&gt;
&lt;br /&gt;
ssid=rcnap&lt;br /&gt;
hw_mode=g&lt;br /&gt;
channel=11&lt;br /&gt;
&lt;br /&gt;
ieee80211n=1&lt;br /&gt;
#ht_capab=[HT40-][SHORT-GI-40]&lt;br /&gt;
&lt;br /&gt;
wpa_pairwise=TKIP CCMP&lt;br /&gt;
wpa=1&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Media Servers&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Yet to be filled&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Download  Manager&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small; font-weight: normal;&quot;&gt;Yet to be filled&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/1303793687576670374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/1303793687576670374' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1303793687576670374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1303793687576670374'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2011/03/rcn-software-pieces.html' title='Wirless Router, Network Storage and Media Server: Software Pieces'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrXuakEv9tuDlJIK9tPOGJ_BW-qrGxTge-g3aLNlaLRoVns_4BRepERd_PC7oq7pJov4179nPdRPIN1OSu8NanPlE8BAdIAkQE5XVc26Igy2HawpjGsI5rsBXoD0aS5TIjVqmldg/s72-c/Network.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-3552151826736795052</id><published>2011-02-14T07:20:00.000-08:00</published><updated>2011-02-14T07:20:57.830-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Router NAS Linux"/><title type='text'>How to create your own wireless router, network storage server and media server</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I have replaced my Buffalo WRT-G54 wireless router with my own custom built router. This blog explains how I did that. I call this device as RCN (Router cum NAS). &lt;br /&gt;
&lt;br /&gt;
To create your own RCN, you need:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Hardware&lt;/li&gt;
&lt;li&gt;Software&lt;/li&gt;
&lt;li&gt;Motivation&lt;/li&gt;
&lt;/ul&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;  Motivation &lt;/b&gt;&lt;/span&gt;for me was &lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;Storage&lt;/b&gt; - I was afraid of storing all my family photos/videos in a single drive. I wanted to have RAID 1 setup.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Power Saving&lt;/b&gt; - I hate running my i5 24x7 to download stuffs.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Media server&lt;/b&gt; – I want to get rid of copying photos/videos/movies on my Play Station 3 before watching it – it spoils the mood.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Exploration&lt;/b&gt; - Fun building new thing.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;The above list is in reverted priority order. &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Hardware&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
I began my hardware hunt 45 days back – it was difficult because of my requirements and availability in Indian Market. &lt;br /&gt;
&lt;br /&gt;
Here is the initial requirement list (strikethrough indicates I gave up that requirement because the items are too costly or not available in India): &lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Total board TDP should be less than 40watts&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;s&gt;Passively cooled&lt;/s&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Mini-ITX form factor&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Onboard RAID is preferred&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;DDR3 support is preferred&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;s&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Dual core&lt;/span&gt;&lt;/s&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Hardware should be available in India&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;s&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Should be less than Rs.10K&amp;nbsp;&lt;/span&gt;&lt;/s&gt;&lt;/li&gt;
&lt;/ul&gt;Here is the final products I purchased:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #351c75;&quot;&gt;&lt;a href=&quot;http://www.gigabyte.com/products/product-page.aspx?pid=3550#ov&quot;&gt;Gigabyte GA-D425TUD&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #351c75;&quot;&gt;&lt;a href=&quot;http://iball.co.in/Product.aspx?c=5&quot;&gt;iBall Baby 306&lt;/a&gt; Cabinet&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #351c75;&quot;&gt;DDR-3 2GB RAM&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #351c75;&quot;&gt;2 x 1TB Western Digital &lt;a href=&quot;http://www.wdc.com/en/products/products.aspx?id=120&quot;&gt;WD10EARS&lt;/a&gt; SATA&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #351c75;&quot;&gt;USB to Ethernet&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #351c75;&quot;&gt;USB Flash Drive&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #351c75;&quot;&gt;PCI Wifi Adapter &lt;a href=&quot;http://www.dlink.com/products/?pid=531&quot;&gt;DLink 552 Xtreme N&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;Here is some pictures of my RCN (Ignore the fancy cabling)&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihdLnLySog5Q7-U4pcReJTup1vWLUCZjZ788yuxBpX0ZhbpU3BQEe4y-1yZ0i9dForCut_GmZVT7TyKz054FAKeb0nY-p9MedSxdcUaY9jnqm_x9f6QhOVvTWYaZUHLRt2DXQHlA/s1600/RCN+006.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihdLnLySog5Q7-U4pcReJTup1vWLUCZjZ788yuxBpX0ZhbpU3BQEe4y-1yZ0i9dForCut_GmZVT7TyKz054FAKeb0nY-p9MedSxdcUaY9jnqm_x9f6QhOVvTWYaZUHLRt2DXQHlA/s320/RCN+006.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Mini-ITX board - I didnt expect this board to be so small - Compare it with the building set block&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTBp4nW2zcvDzTjfAv_cf74m7d1P83rRbjusSWnud5Z5BEQW6Jhij-DrBKiKv2eVkXHEAi2UlgD1FSdYmNg56V-S4ah3hPj_B8xnzZ13FKmyIyh0SjaES17jfILvp15Ig1Z5_80w/s1600/RCN+007.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTBp4nW2zcvDzTjfAv_cf74m7d1P83rRbjusSWnud5Z5BEQW6Jhij-DrBKiKv2eVkXHEAi2UlgD1FSdYmNg56V-S4ah3hPj_B8xnzZ13FKmyIyh0SjaES17jfILvp15Ig1Z5_80w/s320/RCN+007.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;I got two noisy fans with this cabinet - I yet to shutdown and close the holes&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhStpz84JPXfxNHYEiJh9Yop8YYMQyjv26LDZGDXu7OEgWMA5G_7ncbBpHamtKAku31YGiqANaX8FagMkCvMHllVLzHUb6ev3gQ486z15MmJWQma3xewvHUDhSHSmVa-TiZWil2zA/s1600/RCN+010.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhStpz84JPXfxNHYEiJh9Yop8YYMQyjv26LDZGDXu7OEgWMA5G_7ncbBpHamtKAku31YGiqANaX8FagMkCvMHllVLzHUb6ev3gQ486z15MmJWQma3xewvHUDhSHSmVa-TiZWil2zA/s320/RCN+010.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqoIrH7sSCzZrhJZriS6sMrEAJi16d5GlMqDuORGNtBSv5Jn1Cwys5USAjeibOVROfsW5gun9MxWeRpQ2YTY_JHpXvxkjGKVNtXS9TrM5C5kbE43ZwR5H_unsGwLnn7P97hA1OaA/s1600/RCN+012.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqoIrH7sSCzZrhJZriS6sMrEAJi16d5GlMqDuORGNtBSv5Jn1Cwys5USAjeibOVROfsW5gun9MxWeRpQ2YTY_JHpXvxkjGKVNtXS9TrM5C5kbE43ZwR5H_unsGwLnn7P97hA1OaA/s320/RCN+012.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;After Attaching the Wireless PCI card&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhan1JprgBwWuDZvWQfA-JWhr0oCItgWNpjmHtnwd8iwNOzAmwq2CPs5o0xNIPBFHBbo0-Ox4EM2HCp-wGSXGV49oTg5NmwW2WuTXICYb0JVndcU3E2HnGjKb8xEAse9wUeU0Fs5Q/s1600/RCN+013.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhan1JprgBwWuDZvWQfA-JWhr0oCItgWNpjmHtnwd8iwNOzAmwq2CPs5o0xNIPBFHBbo0-Ox4EM2HCp-wGSXGV49oTg5NmwW2WuTXICYb0JVndcU3E2HnGjKb8xEAse9wUeU0Fs5Q/s320/RCN+013.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Interesting fact about&amp;nbsp;&lt;a href=&quot;http://www.wdc.com/en/products/products.aspx?id=120&quot;&gt;WD10EARS&lt;/a&gt;&amp;nbsp;is it use 4KB sectors instead of the conventional 512byte sectors. Since this is a breakthrough software support is not much there. Looks like these drives perform poor if not partitioned properly - Since my requirement demands creating single partition, I purchased this drive and it performs well.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Will post the software things needed in the next post...&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/3552151826736795052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/3552151826736795052' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3552151826736795052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3552151826736795052'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2011/02/how-to-create-your-own-wireless-router.html' title='How to create your own wireless router, network storage server and media server'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihdLnLySog5Q7-U4pcReJTup1vWLUCZjZ788yuxBpX0ZhbpU3BQEe4y-1yZ0i9dForCut_GmZVT7TyKz054FAKeb0nY-p9MedSxdcUaY9jnqm_x9f6QhOVvTWYaZUHLRt2DXQHlA/s72-c/RCN+006.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-8610478141056044629</id><published>2011-02-09T02:22:00.002-08:00</published><updated>2012-04-02T16:39:32.444-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>USB image creation using dd command</title><content type='html'>Wrote this post while waiting for a &quot;dd&quot; command to finish USB image creation. So this post is mainly for dd tips.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) How to create a USB drive clone?&lt;/div&gt;&lt;div&gt;&lt;b&gt;sudo dd of=/dev/xxx if=clone.img&lt;/b&gt;&lt;/div&gt;&lt;div&gt;The output image will be in clone.img. If you want to restore to the original disk or another usb drive use &lt;b&gt;sudo dd if=/dev/xxx of=clone.img&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2) How to find where my usb drive is attached?&lt;/div&gt;&lt;div&gt;&lt;b&gt;dmesg | less&lt;/b&gt;&lt;/div&gt;&lt;div&gt;This will tell which device name is attached to the usb drive.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3) How long will it take for a 4GB drive?&lt;/div&gt;&lt;div&gt;Depends on your usb drive transfer rate.&lt;/div&gt;&lt;div&gt;But also depends on the buffer size used by dd, I use &lt;/div&gt;&lt;div&gt;&lt;b&gt;sudo dd of=/dev/xxx if=clone.img bs=10M&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;&lt;b&gt;sudo dd if=/dev/xxx of=clone.img bs=10M&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;iostat &lt;/b&gt;will give you the transfer rate of your devices&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4) Dont know whether dd is dead or not?&lt;/div&gt;&lt;div&gt;If you send USR1 signal to dd it will print the status.&lt;br /&gt;&lt;b&gt;sudo kill -USR1 `pidof dd`&lt;/b&gt;&lt;/div&gt;&lt;div&gt;If you want auto update every 10 sec, try&lt;/div&gt;&lt;div&gt;&lt;b&gt;watch -n 10 sudo kill -USR1 `pidof dd`&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/8610478141056044629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/8610478141056044629' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8610478141056044629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8610478141056044629'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2011/02/usb-image-creation-using-dd-command.html' title='USB image creation using dd command'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-4745382766646656931</id><published>2010-12-21T07:20:00.005-08:00</published><updated>2012-04-02T16:39:54.715-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>PS3 File Conversion(mkv to vob)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div&gt;PlayStation 3 supports lot of &lt;a href=&quot;http://manuals.playstation.net/document/en/ps3/current/video/filetypes.html&quot;&gt;file formats&lt;/a&gt;. However PS3 doesnt play most famous HD files container &lt;a href=&quot;http://www.matroska.org/&quot;&gt;mkv&lt;/a&gt;. Another limitation of PS3 is it doesn&#39;t support any file system except FAT32. And FAT32 has limitation of &lt;a href=&quot;http://www.ntfs.com/ntfs_vs_fat.htm&quot;&gt;4GB&lt;/a&gt; file size. And most of the HD files will easily cross 4GB limit.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I used to watch HD movies on my PS3 since it is connected to TV and HT; and other movies(which doesnt require special video/audio effects) on my desktop computer. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;So to watch movie in mkv format on PS3, it should be converted to PS3 compatible format(&lt;a href=&quot;http://en.wikipedia.org/wiki/VOB&quot;&gt;VOB&lt;/a&gt;) and the output file(s) size should be less than 4GB. For this I have been using &lt;a href=&quot;http://www.mkv2vob.com/&quot;&gt;mkv2vob&lt;/a&gt;, this tool transcodes DTS to AC3(if necessary) otherwise just copies video/audio streams to output file which in vob format. It also does good job by splitting the files so that a single file is always &amp;lt;&amp;gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Recently this tool was not able to convert a mkv file, so I have to try different tools. The first tool I tried was&lt;a href=&quot;http://www.mediacoderhq.com/&quot;&gt; media coder&lt;/a&gt;; after few trial and errors I was able to convert mkv to vob. However it doesnt have provision for splitting the file. So I went through few forums to find &lt;a href=&quot;http://www.videohelp.com/tools/GOTSent&quot;&gt;GOTSent&lt;/a&gt;. It did the job but took lot of time(~15-20min) than mkv2vob.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;After all this, I started watching that movie and realized that particular doesn&#39;t have any special effects(audio/video) but needs subtitles; instead of transcoding it again - I just watched it in my computer. Either I should lay cable between my router and PS3 so that&lt;a href=&quot;http://ps3mediaserver.blogspot.com/&quot;&gt; PS3 Media Server&lt;/a&gt; or I should develop a wireless router which can communicate at 1G speed. I feel the later more interesting :)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/4745382766646656931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/4745382766646656931' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/4745382766646656931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/4745382766646656931'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2010/12/ps3-file-conversionmkv-to-vob.html' title='PS3 File Conversion(mkv to vob)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-1813697094568603665</id><published>2010-12-10T10:03:00.002-08:00</published><updated>2012-04-02T16:39:32.397-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>mount: Invalid Argument</title><content type='html'>This post regarding a simple problem which took almost 10 hours to realize my mistake.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I am working on PowerPC FreeBSD system where no harddisk is attached instead USB flash drive is used as storage. I needed to edit file system layout and content extensively. So I took the USB flash drive from the that machine and came back to my desk. Time 3PM.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) Inserted into my Linux desktop and did &quot;&lt;b&gt;dmesg&lt;/b&gt;&quot; - the kernel was able to detect the usb drive and print the partitions inside it. But when I tried &lt;b&gt;mount &lt;/b&gt;it failed. After some googling I found that UFS file system can be mounted in Linux only in RO mode. So I tried mount -r but still it failed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2) So I tried &lt;b&gt;Windows &lt;/b&gt;next, by googling UFS driver/utility for windows. The free one I could find which has write access it ffsdrv. I avoid posting its link because it is not helpful and I &lt;b&gt;wont recommend&lt;/b&gt; that utility to anyone. Since it has file system driver it can easily crash the windows. It showed me &lt;b&gt;BSOD &lt;/b&gt;three times to me. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3) Then I decided to try mounting the USB on a FreeBSD machine. I couldnt find one, so I decided to use &lt;b&gt;VirtualBox&lt;/b&gt;. Since I already had virtual box installed and FreeBSD vm in it, it was easier to &quot;start&quot;. I started the FreeBSD vm  but it couldnt detect the host USB device. So searched and found that when I installed I should have omitted the VirtualBox usb driver which is causing the issue, so downloaded the latest version of VirtualBox. After installing VirtualBox also it couldnt detect the USB drive. Few googling revealed there is a bug in VirtualBox implementation of USB EHCI controller 2, so I unselected it and VirtualBox is able to detect my drive. But when I tried to mount the drive, FreeBSD failed with &quot;Invalid Argument&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4) At this time I lost hope with VirtualBox, so I installed Vmware and started FreeBSD on it. There were no glitches, the drive got detected immediately and FreeBSD was able to detect it too. However when it came to mount, again same problem. Ahhh&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5) Ok - this is time to blame emulators - I thought both VirtualBox&#39;s and VMware&#39;s  USB simulation is bad :), so I decided to try with real hardware. Since it was late around 8PM, I went to home -  I booted my machine with a FreeBSD Live CD and tried to mount - same problem.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6) Now I started suspecting the drive/data. I ran &lt;b&gt;fsck &lt;/b&gt;- it complaint it couldnt find super block and alternative super block. &lt;b&gt;newfs -N&lt;/b&gt; said the alternative should be at 32. So I tried &lt;b&gt;fsck_ffs -b 32&lt;/b&gt; and no luck.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;7) Time 11.xxPM, bulb:&gt; &quot;you are using i386(Little Endian) machine to  read file system which was created by powerpc(Big Endian). &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/1813697094568603665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/1813697094568603665' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1813697094568603665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1813697094568603665'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2010/12/mount-invalid-argument.html' title='mount: Invalid Argument'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-7074186070446363731</id><published>2010-07-31T02:55:00.002-07:00</published><updated>2012-04-02T16:40:17.519-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Compiler"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Eva</title><content type='html'>&lt;div&gt;I have created a small utility which can evaluate &quot;C&quot; expressions and print it in Hex/Binary formats. The name of the project is Eva.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The core part - Parser is created using &lt;a href=&quot;http://antlr.org/&quot;&gt;ANTLR&lt;/a&gt;. Actually the parser part contains 3 modules - Lexer, Parser and Tree walker. The GUI part is developed using &lt;a href=&quot;www.wxwidgets.org/&quot;&gt;WxWidgets&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since it is a small project, I decided to post it in google code hosting rather than sourceforge. Here is the link to the project - &lt;a href=&quot;http://code.google.com/p/eva-c/&quot;&gt;http://code.google.com/p/eva-c/&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/7074186070446363731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/7074186070446363731' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/7074186070446363731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/7074186070446363731'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2010/07/eva.html' title='Eva'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-2112093992227553473</id><published>2010-02-10T03:17:00.002-08:00</published><updated>2010-02-10T03:22:47.400-08:00</updated><title type='text'>Kernel(FreeBSD) Concurrency</title><content type='html'>&lt;div&gt;Today, I had to revisit how FreeBSD system call path was synchronized. And here it is:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Kernel data structures are tradionally protected by the following synchronization methods.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Interrupt disabling&lt;/li&gt;&lt;li&gt;Spinlock&lt;/li&gt;&lt;li&gt;System priority level&lt;/li&gt;&lt;li&gt;Mutex&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Disabling interrupts is the easiest method because only one code path can be executed with in a interrupt disbale/enable boundary.  However exceptions are there which dont honour interrupts disabled attribute.&lt;/div&gt;&lt;div&gt;Eg:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Exceptions&lt;/li&gt;&lt;li&gt;Faults&lt;/li&gt;&lt;li&gt;NMI&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Disabling interrupts wont work on SMP because interrupts can be disabled/enabled only on current CPU. Disabling interrupts is problematic if the code path takes longer time to complete. Because the kernel would have lost interrupts from devices.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Spinlocks is a datastructure residing on memory and acceissible from all the processors on the system.  Before entering a critical code path spinlock is taken and all other access to that code path is prohibted and the other cpus will be in a loop trying to get the lock and enter. There are certain rules while creating a spinlock to avoid dead locks and gain performance from SMP.&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Locking order heierarchy should be maintained to avoid dead locks.&lt;/li&gt;&lt;li&gt;Fine grained locks instead of single big lock to gain performance on SMP.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Spinlock alone would cause a dead lock in a preemptive kernel. Avoiding this in easy way is disabling interrupt because scheduler wont run. However it again would introduce a problem of losing interrupts. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;system priority level or SPL is the prefered method to use with spinlock to avoid lock issues and also get interrupts from devices. SPL rules:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;And all spinlocks are at greater SPL than scheduler.&lt;/li&gt;&lt;li&gt;All spinlocks should have a associated SPL and at that or greater SPL level only the spinlock should be taken.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Note: &lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;In simpler term spl is equivalent to masking interrupts.&lt;/li&gt;&lt;li&gt;SPL is per processor, so the spinlock should have locking order hierarchy, otherwise deadlock for sure.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Mutexes used because even with fine grained spinlock there is performance penalty when other CPUs are waiting(looping) for a spinlock. Mutex solves this problem by scheduling out the looping threads in the other CPUs and selecting other threads to run.&lt;/div&gt;&lt;div&gt;Note:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Mutex cant be used in certain situations eg: a interrupt handler which runs without context cant take mutex because it might be put into sleep.&lt;/li&gt;&lt;li&gt;Combining mutex and spinlock requires only one condition - after a spinlock is taken no mutex acquire should be attempted.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;FreeBSD 6.x&lt;/b&gt; uses mutex and spinlock - MUTEX_DEF and MUTEX_SPIN.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;MUTEX_DEF - Is a mutex which result in going to sleep.&lt;/div&gt;&lt;div&gt;MUTEX_SPIN - Is a spinlock which never puts the caller into sleep but spins and also disables interrupts.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When FreeBSD was optimized for SMP, spinlocks were removed and mutex was introduced.&lt;/div&gt;&lt;div&gt;It also introduced context full interrupt handlers; now interrupt handlers can sleep, so can use mutex. Since most of the system calls was not ported to SMP, they were protected using a big mutex called Giant.&lt;/div&gt;&lt;div&gt;&lt;b&gt;Giant &lt;/b&gt;- Gaint is a MUTEX_DEF which protects the code path of most system calls.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/2112093992227553473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/2112093992227553473' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/2112093992227553473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/2112093992227553473'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2010/02/kernelfreebsd-concurrency.html' title='Kernel(FreeBSD) Concurrency'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-8387717447086831970</id><published>2009-11-19T02:58:00.003-08:00</published><updated>2012-04-02T16:39:32.438-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Size of all structures in your program</title><content type='html'>There are some cases when you want to find size of all structures in your program/project. For a given program it is easy because we can manually calculate or put a printf sizeof() to calculate a few structures.  But for a project with few hundred files it is difficult. There is noway AFAIK in gcc to dump all the structure sizes while it compiles.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is a way todo it using dwarf debugging info if you are using gnu compiler tools. Compile your project output file with &lt;b&gt;-g&lt;/b&gt; option, this will generate debugging information in your program. Then run &lt;b&gt;objdump&lt;/b&gt; to dump the debug info. This debugging information contains all the information about your program, filter the output for &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Calibri, sans-serif; font-size: 15px; &quot;&gt;DW_TAG_structure_type&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; font-size: 16px; &quot;&gt;&quot; and you will get only structure information.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Calibri, sans-serif; font-size: 15px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; font-size: 16px; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Here is how I did it:&lt;/div&gt;&lt;div&gt;&lt;p class=&quot;MsoPlainText&quot;&gt;&lt;/p&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;p class=&quot;MsoPlainText&quot;&gt;&lt;b&gt;objdump -W kernel.debug.reloc &gt; debug.info&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class=&quot;MsoPlainText&quot;&gt;&lt;b&gt;grep -e &quot;DW_TAG_structure_type&quot; debug.info --after-context=5 --mmap &gt; structs.txt           &lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/8387717447086831970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/8387717447086831970' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8387717447086831970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8387717447086831970'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/11/size-of-all-structures-in-your-program.html' title='Size of all structures in your program'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-1931084898756173009</id><published>2009-10-29T09:21:00.005-07:00</published><updated>2012-04-02T16:39:32.407-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>SLOC</title><content type='html'>&lt;span&gt;&lt;span&gt;Recently I was browsing some open source project&#39;s(as usual I forgot the name) web site and the author has put &lt;a href=&quot;http://en.wikipedia.org/wiki/Source_lines_of_code&quot;&gt;SLOC &lt;/a&gt;report for his project. It was pretty cool. I wanted to try it on some of my projects and tried sloccount(&lt;a href=&quot;http://www.dwheeler.com/sloccount/&quot;&gt;http://www.dwheeler.com/sloccount/&lt;/a&gt;) in my office but since my office PC doesnt have my personal project sources I was not able to get SLOC report for my projects.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;Today I suddenly, I remembered about SLOC and tried it on my Ace project. And here is the output&lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Sam@samxp /cygdrive/e/Projects&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;$ sloccount ace_test/src&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Creating filelist for app&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Creating filelist for drivers&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Creating filelist for include&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Creating filelist for kernel&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Creating filelist for lib&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Have a non-directory at the top, so creating directory top_dir&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Adding /cygdrive/e/Projects/ace_test/src/wscript to top_dir&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Categorizing files.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Finding a working MD5 command....&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Found a working MD5 command.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Computing results.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;SLOC    Directory       SLOC-by-Language (Sorted)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;13716   include         ansic=13699,sh=17&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;9045    kernel          ansic=8810,asm=221,python=14&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;3712    lib             ansic=3691,sh=11,python=10&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;1062    drivers         ansic=1051,python=11&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;41      top_dir         python=41&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;10      app             ansic=6,python=4&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Totals grouped by language (dominant language first):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;ansic:        27257 (98.81%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;asm:            221 (0.80%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;python:          80 (0.29%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;sh:              28 (0.10%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Total Physical Source Lines of Code (SLOC)                = 27,586&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Development Effort Estimate, Person-Years (Person-Months) = 6.51 (78.15)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt; (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Schedule Estimate, Years (Months)                         = &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;1.09 (13.10)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt; (Basic COCOMO model, Months = 2.5 * (person-months**0.38))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Estimated Average Number of Developers (Effort/Schedule)  = &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;5.97&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Total Estimated Cost to Develop                           = &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;$ 879,761&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt; (average salary = $56,286/year, overhead = 2.40).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;SLOCCount, Copyright (C) 2001-2004 David A. Wheeler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;redistribute it under certain conditions as specified by the GNU GPL license;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;see the documentation for details.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#6600CC;&quot;&gt;Please credit this data as &quot;generated using David A. Wheeler&#39;s &#39;SLOCCount&#39;.&quot;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;Pretty cool isnt it? &lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;:)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/1931084898756173009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/1931084898756173009' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1931084898756173009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1931084898756173009'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/10/sloc.html' title='SLOC'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-4285563194187640503</id><published>2009-10-27T02:01:00.002-07:00</published><updated>2012-04-02T16:39:32.426-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Funny numbers</title><content type='html'>&lt;div&gt;Freebsd kernel source files count vs Makefile count. Just from the numbers it looks like for every 4 source files there is an Makefile. I ran these commands when I thought of converting FreeBSD build system(make) to use waf(&lt;a href=&quot;http://code.google.com/p/waf/&quot;&gt;http://code.google.com/p/waf/&lt;/a&gt;) or scons(&lt;a href=&quot;http://www.scons.org/&quot;&gt;http://www.scons.org/&lt;/a&gt;). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;root@freebsd-sam:/sys#find . -name &quot;*.c&quot; | wc -l&lt;/div&gt;&lt;div&gt;    3171&lt;/div&gt;&lt;div&gt;root@freebsd-sam:/sys#find . -name &quot;*.h&quot; | wc -l&lt;/div&gt;&lt;div&gt;    3004&lt;/div&gt;&lt;div&gt;root@freebsd-sam:/sys#find . -name &quot;*.s&quot; | wc -l&lt;/div&gt;&lt;div&gt;      44&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;root@freebsd-sam:/sys#find . -name &quot;Makefile*&quot;  | wc -l&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;     746&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And yes, after seeing this number I let me thought to stay inside for sometime.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/4285563194187640503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/4285563194187640503' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/4285563194187640503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/4285563194187640503'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/10/funny-numbers.html' title='Funny numbers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-3005459215998423887</id><published>2009-10-03T13:04:00.005-07:00</published><updated>2012-04-02T16:39:32.415-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Call Trace without modifying the source</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
While investigating about gcc flag &quot;-fprofile-arcs&quot;, I came to know about a new(to me) gcc flag and this blog entry is about it. For any large C project it is hard to learn/find call graph through code walk. From C prospective unless otherwise you put a printf in each function entry/exit it is hard to find the call trace.&amp;nbsp;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;GCC and ICC has a wonderful option &quot;-finstrument-functions&quot; to solve this. This option instructs the compiler to emit instructions to call a external function on each function&#39;s entry/exit. Defining these two functions like the following and adding the above option -finstrument-function to your makefile will do the magic.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;void noinstrument&amp;nbsp;__cyg_profile_func_enter(void *this_fn, void *call_site)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;%p called from %p\n&quot;, this_fn, call_site);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void noinstrument&amp;nbsp;__cyg_profile_func_exit(void *this_fn, void *call_site)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;%p returns\n&quot;, this_fn);&lt;br /&gt;
}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Of course, you can do anything in these functions, for simplicity sake I just defined them as printfs.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/3005459215998423887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/3005459215998423887' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3005459215998423887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3005459215998423887'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/10/call-trace-without-modifying-source.html' title='Call Trace without modifying the source'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-4699571412938984862</id><published>2009-09-03T22:30:00.002-07:00</published><updated>2012-04-02T16:39:32.431-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Tracing ld</title><content type='html'>&lt;blockquote&gt;&lt;/blockquote&gt;I was trying to do something with customized FreeBSD kernel which required constructors(.ctors) and destructor(.dtors) sections to be included in the final binary. So I used the normal gnu practice of including the following code into my linker script(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&lt;b&gt;/sys/conf/ldscript.i386&lt;/b&gt;&lt;/span&gt;).&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;   .&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;data.gcov :&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;     &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;__CTOR_LIST__ = .;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    LONG((__CTOR_END__ - __CTOR_LIST__) /&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;        (__CTOR_LIST2__ - __CTOR_LIST__) - 2 )&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    __CTOR_LIST2__ = .;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    KEEP(*(.ctors))&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    LONG(0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    __CTOR_END__ = .;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    __DTOR_LIST__ = .;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    LONG(( __DTOR_END__ - __DTOR_LIST__ )/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;        (__CTOR_LIST2__ - __CTOR_LIST__) - 2)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    KEEP(*(.dtors))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    LONG(0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;    __DTOR_END__ = .;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;But when I tried to see the contents of of the linked kernel there were no constructors. Because &lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; ;font-size:medium;&quot;&gt;__CTOR_LIST__ and __CTOR_END__ are placed next to each other, from the linker script you can see the .ctors comes in between them.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;$objdump -t kernel | grep __CTOR&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;c049cb8c &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;g       .data.gcov     00000000 __CTOR_LIST__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;c049cb94 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;g       .data.gcov     00000000 __CTOR_END__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;c049cb90 g       .data.gcov     00000000 __CTOR_LIST2__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;$objdump -s -j .data.gcov kernel | head&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;kernel:     file format elf32-i386-freebsd&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;Contents of section .data.gcov:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; c049cb8c &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;00000000 00000000 00000000 00000000&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;  ................&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; c049cb9c 5f090000 e7124ac0 e7124ac0 1b4a4ac0  _.....J...J..JJ.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; c049cbac 1b4a4ac0 085c4ac0 085c4ac0 06234bc0  .JJ..\J..\J..#K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; c049cbbc 06234bc0 1f374bc0 1f374bc0 d43b4bc0  .#K..7K..7K..;K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; c049cbcc d43b4bc0 b1414bc0 b1414bc0 b2494bc0  .;K..AK..AK..IK.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt; c049cbdc b2494bc0 d77b4bc0 d77b4bc0 0e894bc0  .IK..{K..{K...K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;I tried to find what ld is doing by enabling &lt;b&gt;--verbose&lt;/b&gt; option in &lt;b&gt;SYSTEM_LD&lt;/b&gt; (&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;/sys/conf/kern.pre.mk&lt;/span&gt;&lt;/b&gt;) but it did not help. Then I tried -Map option to ask ld to generate map file and it helped me. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In my environment the kernel is generated in step. First all system objects are partially linked(&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000066;&quot;&gt;-r/-Ur &lt;/span&gt;&lt;/b&gt;option) to generate relocatable kernel. Then this relocatable kernel is linked with some other static modules to create the kernel. From the map files I could see the constructors are present in the relocatable kernel and dropped while creating the proper kernel. I guess it is a bug with ld. So I merged the two step process into one and it worked.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;$&lt;b&gt;objdump -t kernel | grep __CTOR&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;c049cf50 &lt;/span&gt;g       .data.gcov     00000000 __CTOR_LIST__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;c049f4e4 &lt;/span&gt;g       .data.gcov     00000000 __CTOR_END__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;c049cf54 g       .data.gcov     00000000 __CTOR_LIST2__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;$&lt;b&gt;objdump -s -j .data.gcov kernel | head&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;kernel:     file format elf32-i386-freebsd&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;Contents of section .data.gcov:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt; c049cf50 &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#006600;&quot;&gt;63090000 a7164ac0 a7164ac0 db4d4ac0&lt;/span&gt;  c.....J...J..MJ.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt; c049cf60 db4d4ac0 c85f4ac0 c85f4ac0 c6264bc0  .MJ.._J.._J..&amp;amp;K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt; c049cf70 c6264bc0 df3a4bc0 df3a4bc0 943f4bc0  .&amp;amp;K..:K..:K..?K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt; c049cf80 943f4bc0 71454bc0 71454bc0 724d4bc0  .?K.qEK.qEK.rMK.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt; c049cf90 724d4bc0 977f4bc0 977f4bc0 ce8c4bc0  rMK...K...K...K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt; c049cfa0 ce8c4bc0 bbf74bc0 bbf74bc0 bb0a4cc0  ..K...K...K...L.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/4699571412938984862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/4699571412938984862' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/4699571412938984862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/4699571412938984862'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/09/tracing-ld.html' title='Tracing ld'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-8877293892210461888</id><published>2009-08-28T02:23:00.004-07:00</published><updated>2012-04-02T16:39:32.450-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="kernel"/><category scheme="http://www.blogger.com/atom/ns#" term="make"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Debugging gcc behavior</title><content type='html'>&lt;div&gt;While compiling a FreeBSD kernel I encountered the following error message from GNU assembler&lt;/div&gt;&lt;div&gt;Error: suffix or operands invalid for `mov&#39;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was not sure whether the error is because of my changes are not. But still I have to debug the problem and solve it, so I decided to find what is wrong with the mov instruction. But since gcc created a temporary file and invoked as to assemble it, I couldn’t find the temp file anymore.&lt;/div&gt;&lt;div&gt;Googled and find the following gcc options to find what gcc does.&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;gcc –v is verbose mode, which prints all the action/scripts gcc is doing.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;gcc -### similar to –v but wont execute any commands.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;gcc –save-temps saves all the temporary files generated by the gcc. Useful if you want to see the assembly output passed to gnu assembler.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;gcc –E Just preprocess the c file&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;gcc –S generate assembly file.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;With gcc –v –save-temps, I got the temporary assembler file used by assembler. Since reading machine generated assembly file is difficult, I tried to find the C source code corresponding to the error. From nearest .file &lt;a href=&quot;http://sourceware.org/binutils/docs-2.19/as/Pseudo-Ops.html#Pseudo-Ops&quot;&gt;assembler directive&lt;/a&gt; I found the C file name and from the .loc directive I found the line number. And the following was the inline assembly in the C file.&lt;/div&gt;&lt;div&gt;__asm __volatile(&quot;&lt;b&gt;movl &lt;/b&gt;%%ss,%0&quot; : &quot;=rm&quot; (sel));&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Was surprised what is wrong with this and why my assembler giving error. Googled again and found this link - &lt;a href=&quot;http://kerneltrap.org/node/5785&quot;&gt;http://kerneltrap.org/node/5785&lt;/a&gt;. It seems newer gnu assembler(&gt;=2.16) wont support long read/write operations(mov) on segment registers(ds,ss...). So changed the above source to &lt;b&gt;movw&lt;/b&gt; %%ss, %o and it compiled perfectly. :)&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/8877293892210461888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/8877293892210461888' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8877293892210461888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8877293892210461888'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/08/debugging-gcc-behavior.html' title='Debugging gcc behavior'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-1203944236296685294</id><published>2009-04-09T04:22:00.005-07:00</published><updated>2012-04-02T16:39:32.380-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ace"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Unreferenced symbols - EXPORT_SYMBOL</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;I wrote ACPI driver for Ace and try to load it into kernel. It was failing with the error message symbol not found. &lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;The log file content says AcpiGetName was not found.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;blockquote&gt;$ cat log.txt&lt;br /&gt;Driver for id acpi : acpi.sys&lt;br /&gt;../src/kernel/pm/elf.c:343:FindElfSymbolByName(): Symbol not found AcpiGetName(c01a2148:1869) string table c01aa619&lt;/blockquote&gt; &lt;/span&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;After exploring the Acpi-CA source code and Ace kernel code, I couldn’t figure out why the symbol is missing. Then I tried to dump the symbol table for Acpi library and kernel.sys. &lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;$ nm build/default/src/kernel/libacpi.a | grep GetName&lt;br /&gt;        U AcpiExGetNameString&lt;br /&gt;000001e3 T AcpiExGetNameString&lt;br /&gt;000001b7 T AcpiPsGetName&lt;br /&gt;000000f4 T AcpiGetName&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;$ nm build/default/src/kernel/kernel.sys | grep GetName&lt;br /&gt;c0135163 T AcpiExGetNameString&lt;br /&gt;c0137bfb T AcpiPsGetName&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;It is obvious during kernel link process some how the linker is losing AcpiGetName. Within few seconds I realized that the linker is doing optimization on the output to remove unreferenced sections. So I googled for how to avoid this and found --no-gc-sections is the ld option to do it. However even after giving this option to linker to was removing the unreferenced symbols; I kept on trying to find a solution for making the linker to include unreferenced symbols in the output… I didn’t find the solution.&lt;/div&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;Then I started thinking how linux kernel is avoiding this problem and I it flashed seeing EXPORT_SYMBOL kind of macro in some source. So I googled for it and got the answer – use the symbol in storage, so that it will be referenced, so that linker will include it in the output.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;struct kernel_symbol&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;unsigned long symbol;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;char * name;&lt;br /&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;#ifndef MODULE_SYMBOL_PREFIX&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;#define MODULE_SYMBOL_PREFIX &quot;&quot;&lt;br /&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;#define __EXPORT_SYMBOL(sym, sec) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;static const char __kstrtab_##sym[] \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;__attribute__((section(&quot;__ksymtab_strings&quot;))) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;= MODULE_SYMBOL_PREFIX#sym; \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;static const struct kernel_symbol __ksymtab_##sym \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;__attribute__((section(&quot;__ksymtab&quot; sec), unused)) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;= { (unsigned long)&amp;amp;sym, __kstrtab_##sym }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;#define EXPORT_SYMBOL(sym) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;__EXPORT_SYMBOL(sym, &quot;&quot;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:verdana;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:100%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/1203944236296685294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/1203944236296685294' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1203944236296685294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1203944236296685294'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/04/unreferenced-symbols-exportsymbol.html' title='Unreferenced symbols - EXPORT_SYMBOL'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-8135446797884719058</id><published>2009-03-17T03:54:00.003-07:00</published><updated>2009-03-17T04:06:23.622-07:00</updated><title type='text'>Better build system</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;I was using “make”(&lt;a href=&quot;http://en.wikipedia.org/wiki/GNU_build_system&quot;&gt;http://en.wikipedia.org/wiki/GNU_build_system&lt;/a&gt;) to build and clean my projects. The makefiles grew bigger enough to not maintainable state. Recently I came to know about waf(&lt;a href=&quot;http://code.google.com/p/waf/&quot;&gt;http://code.google.com/p/waf/&lt;/a&gt;) from a forum, so decided to give a try. I went through the waf documentation and it took 2 hours to understand how it works and it took 2 days to convert all my makefiles to waf wscripts and wscript_build files.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;The basic problem with make was I have write rules to how to build object files from source and&lt;/p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfi-X2irec1DyywAqL-jvwJCsUaMWoyNE9AAQJ8dMrN34UGKSdGCqU_MGalfOXfwNFYY7bA8nDuH_hSFM9CpNTxOGiccEddakvnLFR5hjc_JkOrnaZsWtL3v2BK3y0RZjdae-0Yg/s320/ace_compile.jpg&quot; style=&quot;float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 183px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5314110712577836018&quot; /&gt;then to clean I have to write how to delete the object files. With waf the problem is simplified, you have to tell what all source files and it will take care of how to compile and link. It will also take care of how to clean the project and the dependency between files are also taken care, so no need for gcc –M and dependency files etc. The feature I liked in waf is it has colored output with progress bar :)&lt;p class=&quot;MsoNormal&quot;&gt;The other problem solved in Ace project compilation was build configuration. Waf will configure the project for the first time, so it solved the different cross compiler required for Ace OS.&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;Waf(&lt;a href=&quot;http://code.google.com/p/waf/&quot;&gt;http://code.google.com/p/waf/&lt;/a&gt;) is really good alternative/replacement for make tools.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/8135446797884719058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/8135446797884719058' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8135446797884719058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/8135446797884719058'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2009/03/better-build-system.html' title='Better build system'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfi-X2irec1DyywAqL-jvwJCsUaMWoyNE9AAQJ8dMrN34UGKSdGCqU_MGalfOXfwNFYY7bA8nDuH_hSFM9CpNTxOGiccEddakvnLFR5hjc_JkOrnaZsWtL3v2BK3y0RZjdae-0Yg/s72-c/ace_compile.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-5137064110273817805</id><published>2008-12-15T22:47:00.005-08:00</published><updated>2009-02-01T22:13:41.161-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Softwares"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows"/><title type='text'>Putty Tips</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(204, 0, 0);&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:large;&quot;&gt;Putty title&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;I wanted to change putty title to reflect current working directory of the remote machine to distinguish multiple putty windows easily. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;PUTTY_TITLE=`hostname`:`tty | cut -f 4 -d &quot;/&quot;`&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;export PS1=&#39;$PWD&gt;^[]2;$PWD:$PUTTY_TITLE^G&#39;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;To insert in vi editor the &quot;^[&quot; character in insert mode press control-V and then the Escape key. ^G is created by pressing control-G.&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Reference: &lt;a href=&quot;http://www.unix.com/sun-solaris/23038-change-terminal-title-2.html&quot;&gt;http://www.unix.com/sun-solaris/23038-change-terminal-title-2.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; ;font-family:&#39;Times New Roman&#39;;&quot;&gt;&lt;div style=&quot;border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; &quot;&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(204, 0, 0);&quot;&gt;Passwordless connection to HPUX machines&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Since I was forgetting my passwords for HPUX machines, I decided to try SSH public/private key authentication to get rid of passwords. After some struggle I managed to login in to HPUX machines using Putty without entering a password.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Before I forget all those steps which are not part of my daily job, I wanted to log them and so here it is.&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Login to HPUX machine using your login and password&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Create a .ssh directory under your home directory &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;mkdir .ssh&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Create public/private key pair &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;ssh-keygen –t rsa&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add the public key to authorized_keys2 file &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;cat id_rsa.pub&gt;&gt; authorized_keys2&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;Now ftp the private key file(id_rsa) to your Windows machine.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;Covert the private key file format to putty private key file format. (Use puttygen.exe and then load and save the private key file).&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;Now in putty, select the host and select SSH as protocol and in SSH options on the left hand tab select Auth and select the private key file.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;If you get “server refused our key” error then I would suggest running sshd with debug option. (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;/usr/sbin/sshd -d -d -d &amp;amp;&lt;/span&gt;)&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can also check the permission of your files and folders.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;chmod 600 authorized_keys2&lt;br /&gt;&lt;/li&gt;&lt;li&gt;chmod 700 .ssh&lt;/li&gt;&lt;li&gt;Also check your home directory permission.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;It should work. If it is not, you can try running the ssh client in debug mode from the same server. (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;ssh -l &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: italic; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;username servername&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt; -v -v -v&lt;/span&gt;)&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; ;font-size:18px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(204, 0, 0); &quot;&gt;Passwordless connection to Tru64 machines&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;It is almost same as HPUX configuration but the directory name should be &quot;.ssh2&quot; instead of &quot;.ssh&quot;. And it should contain a text file named &quot;authorization&quot;; the contents of that file should be list of public key files separated by newline.&lt;/div&gt;&lt;div&gt;Example:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;/home/samuel/.ssh2&gt;ls&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;authorization      id_rsa_2048_a      id_rsa_2048_a.pub  random_seed&lt;/div&gt;&lt;div&gt;/home/samuel/.ssh2&gt;cat authorization&lt;/div&gt;&lt;div&gt;Key id_rsa_2048_a.pub&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(204, 0, 0); &quot;&gt;Someother tools&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; I came to know when I was searching Putty enchancements&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;I wanted some small utility to avoid digging through Start menu Programsto find Putty or any other program to launch it. I want a small command line kind of utility and found &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 0, 153);&quot;&gt;&lt;a href=&quot;http://www.launchy.net/&quot;&gt;Launchy&lt;/a&gt; &lt;/span&gt;&lt;/span&gt; it can launch any program by typing few letters of that program.&lt;/li&gt;&lt;li&gt;Sometime I start source control/compilation of kernel from my office and want to continue things from my home. But since terminal emulators such as Putty are bound to local machine, I used to open new terminal session or use remote desktop connection to my office machine to continue my work. One of my colleagues told me about &lt;a href=&quot;http://www.gnu.org/software/screen/&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;GNU screen&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;  and how it can solve the problem.  Here is some good&lt;a href=&quot;http://www.kuro5hin.org/story/2004/3/9/16838/14935&quot;&gt; introduction to screen&lt;/a&gt;.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(204, 0, 0);&quot;&gt;Putty sessions&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;I was searching for method to launch Putty session quickly and saw the following article Multiple putty addons &lt;a href=&quot;http://www.thegeekstuff.com/2008/08/turbocharge-putty-with-12-powerful-add-ons-software-for-geeks-3/&quot;&gt;http://www.thegeekstuff.com/2008/08/turbocharge-putty-with-12-powerful-add-ons-software-for-geeks-3/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Previously I was using &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;Putty Session Manager&lt;/span&gt;&quot; to categorize and lanuch putty sessions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC0000;&quot;&gt;Enabling colors in vim in putty terminal&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Using_vim_color_schemes_with_Putty&quot;&gt;http://vim.wikia.com/wiki/Using_vim_color_schemes_with_Putty&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/5137064110273817805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/5137064110273817805' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/5137064110273817805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/5137064110273817805'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2008/12/putty-tips.html' title='Putty Tips'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-5590876626919114639</id><published>2008-11-22T04:36:00.002-08:00</published><updated>2009-01-07T21:05:58.747-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ace"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="make"/><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Porting to “Intel C Compiler”</title><content type='html'>&lt;div&gt;In this post, I will explain how to easy it is to compile/port C programs and makefiles designed for GCC(GNU compiler collection) can be used with ICC(intel c compiler)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The necessity for using ICC happened to me because gcc was generating much bigger object files. Ace is using ACPI-CA(http://acpica.org/) as it is ACPI driver. After compilation the ACPI library is around 7M in debug version and around 500K in non-debug version. But from http://acpica.org/download/changes.txt it seems Microsoft C compiler produce smaller code.&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;    Non-Debug Version:  81.2K Code, 17.0K Data,  98.2K Total&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;    Debug Version:     155.8K Code, 49.1K Data, 204.9K Total&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So I decided to try “Intel Compiler” as replacement for GCC. Things were easy, since icc has options which is similar to gcc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can get the details of portability options from icc documentation -http://www.intel.com/software/products/compilers/docs/clin/main_cls/index.htm.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I just changed my make.conf file to check the compiler in use and use appropriate options. I removed -fno-leading-underscore and –Wall. I removed –Wall because it was giving lot of warnings, we have to fix our code sometime soon. I removed -fno-leading-underscore because there is no equivalent option in icc, however icc does not adds underscores to symbols anyway. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I added –O1 option because the kernel was panicked during boot with invalid opcode exception, I believe it was because of some MMX register usage by icc. So I settled with –O1 now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;ifeq ($(CC),gcc)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;    DEBUG_FLAGS= -gdwarf-2 -g3&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;    CFLAGS+= -Wall -Wno-multichar $(DEFINES) -nostartfiles -ffreestanding -funsigned-char -fno-leading-underscore -c -fno-stack-protector $(DEBUG_FLAGS) $(CUSTOM_FLAG)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;    DEBUG_FLAGS= -gdwarf-2 -g&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;    CFLAGS+= -O1 -Wno-multichar $(DEFINES) -nostartfiles -ffreestanding -funsigned-char -c -fno-stack-protector $(DEBUG_FLAGS) $(CUSTOM_FLAG)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;endif&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I also made some static variables in kernel/i386/gdb_stub.c to non-static because icc appends .0 to static variables but it forgets the same name when referenced in a inline assembly code in the same file. After removing the static attribute it is working fine.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;gcc compiler took the following time to compile Ace source code.&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 153, 0);&quot;&gt;real    0m51.125s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 153, 0);&quot;&gt;user    0m36.975s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 153, 0);&quot;&gt;sys     0m11.185s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;icc compiler took the following time to compile Ace source code.&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;; font-size: 13px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 102, 255);&quot;&gt;real    1m44.366s&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 102, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 102, 255);&quot;&gt;user    0m59.107s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 102, 255);&quot;&gt;sys     0m20.946s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Gcc produced double the size of kernel.sys produced by icc. (I used GNU linker(ld) and ar).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;gcc output size:&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;; font-size: 13px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;[samuel@linux Ace3]$ ls -lh /home/samuel/Projects/Ace3/obj/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;; font-size: 13px;&quot;&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel 372K 2008-11-22 18:17 acpi.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel 545K 2008-11-22 18:17 arch.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rwxrwxr-x 1 samuel samuel 1.3M 2008-11-22 18:17 kernel.sys&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel  62K 2008-11-22 18:17 libds.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel  40K 2008-11-22 18:17 libheap.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel  39K 2008-11-22 18:17 libstring.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel 9.5K 2008-11-22 18:17 libsync.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel  91K 2008-11-22 18:17 pic.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel  23K 2008-11-22 18:17 pit.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 102, 0);&quot;&gt;-rw-rw-r-- 1 samuel samuel  21K 2008-11-22 18:17 rtc.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;icc output:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;[samuel@linux Ace3]$ ls -lh /home/samuel/Projects/Ace3/obj/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel 352K 2008-11-22 16:25 acpi.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel 230K 2008-11-22 16:24 arch.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rwxrwxr-x 1 samuel samuel 528K 2008-11-22 16:25 kernel.sys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel  38K 2008-11-22 16:23 libds.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel  22K 2008-11-22 16:23 libheap.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel  21K 2008-11-22 16:23 libstring.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel  11K 2008-11-22 16:23 libsync.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel  19K 2008-11-22 16:24 pic.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel 8.4K 2008-11-22 16:24 pit.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 153);&quot;&gt;-rw-rw-r-- 1 samuel samuel  13K 2008-11-22 16:24 rtc.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So it is easy to use icc instead of gcc. However since I am using Windows and icc is free only for Linux for non commerical purposes. I stick to gcc to compile Ace in Windows. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/5590876626919114639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/5590876626919114639' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/5590876626919114639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/5590876626919114639'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2008/11/porting-to-intel-c-compiler.html' title='Porting to “Intel C Compiler”'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-3288424217832800283</id><published>2008-11-06T07:58:00.005-08:00</published><updated>2008-11-12T09:20:17.260-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="make"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>GNU make slow build process</title><content type='html'>&lt;div&gt;While building one my project it was taking too much time; the project was taking around 40-60 seconds to build and around 20 seconds to clean. I was frustrated with this because the debugging cycle time for my project was going high.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So I decided to stop debugging my project and start debugging the build process. In my makefile I had .SILENT option and I removed it to see what is going.  The following was the output&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;make[1]: Entering directory `/cygdrive/g/Projects/Ace3/src/lib&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;make[2]: Entering directory `/cygdrive/g/Projects/Ace3/src/lib/string&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;make[2]: Nothing to be done for `all&#39;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;..&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;make[1]: Leaving directory `/cygdrive/g/Projects/Ace3/src/lib&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;make[1]: Entering directory `/cygdrive/g/Projects/Ace3/src/kernel&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;..&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;make[2]: Leaving directory `/cygdrive/g/Projects/Ace3/src/kernel/pic&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;New kernel is at /cygdrive/g/Projects/Ace3/obj/kernel.sys&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;/cygdrive/g/Projects/Ace3/img/create_bootcd.sh&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Everything was fast, however there was huge delay before getting the output “&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: italic;&quot;&gt;make[1]: Leaving directory `/cygdrive/g/Projects/Ace3/src/lib&lt;/span&gt;&#39;”&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then I tried invoking make with &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;–d (debug)&lt;/span&gt; option and it gave the following output&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;This program built for i686-pc-cygwin&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Reading makefiles...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Reading makefile `makefile&#39;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Reading makefile `/cygdrive/g/Projects/Ace3/make.conf&#39; (search path) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Reading makefile `boot_module.d&#39; (search path) (don&#39;t care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Reading makefile `interrupt.d&#39; (search path) (don&#39;t care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Reading makefile `ktrace.d&#39; (search path) (don&#39;t care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Reading makefile `main.d&#39; (search path) (don&#39;t care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;And it took lot of time before continuing the from the above step, so I knew something wrong with the main.c dependency file, so I opened it and it had too many entries. I casually checked the size of the file and it was 50MB. That explained why make was slow. I carefully examined the dependency entries and found they were repeating. I opened make.conf and checked the rule for making dependency file and found the culprit &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:&#39;courier new&#39;;&quot;&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;%.d:    %.c&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;@$(CC) -c -M $&lt; -I$(INCLUDE) $(CFLAGS) &gt;&gt; $@&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The output redirection symbol &gt;&gt; caused the problem. It appended the dependency rules every time I compiled and increased the size of .d file.  I replaced &gt;&gt; with &gt; and now incremental build process completes in 3 seconds.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/3288424217832800283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/3288424217832800283' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3288424217832800283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/3288424217832800283'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2008/11/gnu-make-slow.html' title='GNU make slow build process'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-2746596602519155628</id><published>2008-10-15T04:37:00.000-07:00</published><updated>2008-10-15T05:17:53.450-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>Editing PDF files</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;Today, I have to fill a form which is in the form of PDF and send it to some other city. Although it is a PDF file, it doesn’t have any input fields, so I have to take print out of the form and fill and then send it through postal mail. Instead I decided to try some pdf converters and after some searches got the link for &lt;a href=&quot;http://www.pdfonline.com/pdf2word/index.asp&quot;&gt;http://www.pdfonline.com/pdf2word/index.asp&lt;/a&gt;. It is fast and produces rtf files.&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;I also got the following comparison pdf to word conversion utilities &lt;a href=&quot;http://www.freewaregenius.com/2008/03/28/how-to-convert-pdf-to-word-doc-for-free-a-comparative-test/&quot;&gt;http://www.freewaregenius.com/2008/03/28/how-to-convert-pdf-to-word-doc-for-free-a-comparative-test/&lt;/a&gt;&lt;/o:p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/2746596602519155628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/2746596602519155628' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/2746596602519155628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/2746596602519155628'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2008/10/editing-pdf-files.html' title='Editing PDF files'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-22080276.post-1094555097120608965</id><published>2008-09-21T23:33:00.012-07:00</published><updated>2008-10-29T10:05:03.364-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Softwares"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows"/><title type='text'>CodeLite - IDE for C</title><content type='html'>For my C projects I was using Notepad++ as my editor/IDE for some time. Although notepad++ is good, it is lacking the integration with a code browser, source control and debugger.&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ5CbmGssETiXkM98vSXeiLjEcQ7nnzTkptaxSjPwh7CWAC2eDt0kcA-JUeCHK6H5RXFMdXTvWjFRyTaVJvjdkh-F3PkSE3ksSrfofIMPreaqtj9VSlwGxmtOHPQChaF2KjSvrKg/s320/screen.JPG&quot; style=&quot;margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5248731904014254498&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;I came to know about &lt;a href=&quot;http://www.blogger.com/www.codelite.org&quot;&gt;CodeLite &lt;/a&gt;when I was searching for ctags for windows. It has integrated &lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;Subversion&lt;/a&gt;, &lt;a href=&quot;http://ctags.sourceforge.net/&quot;&gt;ctags&lt;/a&gt;, &lt;a href=&quot;http://sourceware.org/gdb&quot;&gt;gdb&lt;/a&gt; under one roof.&lt;br /&gt;&lt;br /&gt;Since it is multiplatform GUI, I was little reluctant to install and try(I have tried lot of multiplatform GUI applications and never satisfied with the look and feel of them). But wxWidgets makes the CodeLite to look like native windows application.&lt;br /&gt;&lt;br /&gt;CodeLite has lot of features and it looks very similar to VC++ IDE.&lt;br /&gt;&lt;br /&gt;Code browsing is very easy with CodeLite. It is has a very light explorer and also workspace view through which you can browse your project “easily”. You can switch between header and c file “easily” using the “Swap Header/implementation file” in the context menu. Context menus “Goto declaration” and “Goto Implementation” are handy to browse through code quickly.&lt;br /&gt;&lt;br /&gt;If you are using cygwin and custom makefile - you can use a script as custom build command -&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt; &lt;/span&gt;see &lt;a href=&quot;http://samueldotj.blogspot.com/2007/10/notepad-as-ide.html&quot;&gt;http://samueldotj.blogspot.com/2007/10/notepad-as-ide.html&lt;/a&gt; for more details.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I use the following command to build(because I use gcc cross compiler)&lt;/div&gt;&lt;div&gt;c:\cygwin\bin\bash -l -c &#39;cd $ACE_ROOT/src;PATH=/usr/cross/i586-elf/bin/:$PATH:;make 2&gt; err; sed -e &quot;s@\(\/cygdrive\/\)\([a-zA-Z]\)@\2:@g&quot; err; rm err’. And the following command to clean&lt;/div&gt;&lt;div&gt;c:\cygwin\bin\bash -l -c &#39;cd $ACE_ROOT/src;PATH=/usr/cross/i586-elf/bin/:$PATH:;make clean’&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Codelite supports debugging through gdb; embedded and remote targets also supported. Since I am using a emulator to test my kernel, I have to use remote debugging in GDB to test my OS. Codelite integrates well with GDB remote debugging. I use the following GDB commands as startup gdb commands.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set print pretty on&lt;/div&gt;&lt;div&gt;directory src/kernel &lt;br /&gt;&lt;/div&gt;&lt;div&gt;symbol obj/kernel.sys&lt;/div&gt;&lt;div&gt;source img/gdb/general.gdb&lt;br /&gt;&lt;/div&gt;&lt;div&gt;source img/gdb/stack.gdb&lt;/div&gt;&lt;div&gt;source img/gdb/vm.gdb&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If SVN is configured, using codelite you can see difference between two versions of a same file. By default codelite uses the default diff viewer. It can be changed from Plugins menu -&gt; Subversion-&gt;Options and setting the value appropriately. I use &lt;a href=&quot;http://www.winmerge.org/&quot;&gt;WinMerge &lt;/a&gt;to see differnece of source files and have the following settings:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;External Diff viewer: &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;C:\Program Files\WinMerge\WinMergeU.exe&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Arguments&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt; : /dl %bname /dr %mname %base %mine &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Another good thing about CodeLite is still under development and your bug report/feature requests are solved within short time frame.&lt;br /&gt;&lt;br /&gt;You can download CodeLite from &lt;cite&gt;&lt;a href=&quot;http://www.codelite.org/&quot;&gt;www.&lt;b&gt;codelite&lt;/b&gt;.org&lt;/a&gt;. It has installer for Windows and Linux also.&lt;/cite&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://samueldotj.blogspot.com/feeds/1094555097120608965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/22080276/1094555097120608965' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1094555097120608965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/22080276/posts/default/1094555097120608965'/><link rel='alternate' type='text/html' href='http://samueldotj.blogspot.com/2008/09/codelite-ide-for-c.html' title='CodeLite - IDE for C'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ5CbmGssETiXkM98vSXeiLjEcQ7nnzTkptaxSjPwh7CWAC2eDt0kcA-JUeCHK6H5RXFMdXTvWjFRyTaVJvjdkh-F3PkSE3ksSrfofIMPreaqtj9VSlwGxmtOHPQChaF2KjSvrKg/s72-c/screen.JPG" height="72" width="72"/><thr:total>5</thr:total></entry></feed>