Saturday, April 10, 2010

Google App Engine SDK needs python >= 2.6.4

If you're getting "ImportError: No module named _multiprocessing" when using the Google App Engine SDK:

$ ./google-appengine-sdk/dev_appserver.py --debug itrs-test
/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
import sha
/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
import md5
INFO 2010-04-09 21:08:33,956 appengine_rpc.py:159] Server: appengine.google.com
Allow dev_appserver to check for updates on startup? (Y/n):
dev_appserver will check for updates on startup. To change this setting, edit /home/scottt/.appcfg_nag
INFO 2010-04-09 21:08:37,314 appcfg.py:357] Checking for updates to the SDK.
DEBUG 2010-04-09 21:08:37,317 appengine_rpc.py:345] Sending HTTP request:
POST /api/updatecheck?release=1.3.2&timestamp=1266535890&api_versions=%5B%271%27%5D HTTPS/1.1
Host: appengine.google.com
X-appcfg-api-version: 1
Content-type: application/octet-stream
User-agent: appcfg_py/1.3.2 Linux/2.6.32.10-90.fc12.x86_64 Python/2.6.2.final.0


INFO 2010-04-09 21:08:38,355 appcfg.py:371] The SDK is up to date.
WARNING 2010-04-09 21:08:38,355 datastore_file_stub.py:623] Could not read datastore data from /tmp/dev_appserver.datastore
INFO 2010-04-09 21:08:38,458 dev_appserver_main.py:399] Running application itrs-test on port 8080: http://localhost:8080
DEBUG 2010-04-09 21:08:47,801 dev_appserver.py:488] Matched "/" to CGI dispatcher with path hello.py
DEBUG 2010-04-09 21:08:47,841 dev_appserver.py:1685] Could not import "_multiprocessing": Disallowed C-extension or built-in module
ERROR 2010-04-09 21:08:47,846 dev_appserver.py:3225] Exception encountered handling request
Traceback (most recent call last):
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 3185, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 3128, in _Dispatch
base_env_dict=env_dict)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 515, in Dispatch
base_env_dict=base_env_dict)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 2387, in Dispatch
self._module_dict)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 2295, in ExecuteCGI
logging.debug('Executing CGI with env:\n%s', pprint.pformat(env))
File "/usr/lib64/python2.6/logging/__init__.py", line 1459, in debug
root.debug(*((msg,)+args), **kwargs)
File "/usr/lib64/python2.6/logging/__init__.py", line 1018, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/lib64/python2.6/logging/__init__.py", line 1142, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/lib64/python2.6/logging/__init__.py", line 1117, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/lib64/python2.6/logging/__init__.py", line 272, in __init__
from multiprocessing import current_process
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1272, in Decorate
return func(self, *args, **kwargs)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1922, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1272, in Decorate
return func(self, *args, **kwargs)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1824, in FindAndLoadModule
description)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1272, in Decorate
return func(self, *args, **kwargs)
File "/home/scottt/work/google-appengine/google_appengine_1.3.2/google/appengine/tools/dev_appserver.py", line 1775, in LoadModuleRestricted
description)
File "/usr/lib64/python2.6/multiprocessing/__init__.py", line 83, in
import _multiprocessing
ImportError: No module named _multiprocessing

Your options are:
  1. Apply this patch by hand
  2. Upgrade to python >= 2.6.4

See http://bugs.python.org/issue7120 for the details.

Thursday, February 11, 2010

Ftrace Tutorials

LWN.net Ftrace Articles by Steven Rostedt


 Ever wanted to see what functions are called in a running Linux kernel?
  
    [tracing]# cd /sys/kernel/debug/tracing
[tracing]# echo function_graph > current_tracer
[tracing]# cat trace | head -20
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
1) 1.015 us | _spin_lock_irqsave();
1) 0.476 us | internal_add_timer();
1) 0.423 us | wake_up_idle_cpu();
1) 0.461 us | _spin_unlock_irqrestore();
1) 4.770 us | }
1) 5.725 us | }
1) 0.450 us | mutex_unlock();
1) + 24.243 us | }
1) 0.483 us | _spin_lock_irq();
1) 0.517 us | _spin_unlock_irq();
1) | prepare_to_wait() {
1) 0.468 us | _spin_lock_irqsave();
1) 0.502 us | _spin_unlock_irqrestore();
1) 2.411 us | }
1) 0.449 us | kthread_should_stop();
1) | schedule() {


Friday, January 22, 2010

KGDB Tutorial

KGDB Tutorial


Upstrteam documentation: Using kgdb, kdb and the kernel debugger internals by Jason Wessel

Building a Kernel that supports KGDB

menuconfig KGDB
        bool "KGDB: kernel debugging with remote gdb"
        depends on HAVE_ARCH_KGDB
        depends on DEBUG_KERNEL && EXPERIMENTAL
        help
          If you say Y here, it will be possible to remotely debug the
          kernel using gdb.  
config KGDB_SERIAL_CONSOLE
        tristate "KGDB: use kgdb over the serial console"
        select CONSOLE_POLL
        select MAGIC_SYSRQ
        default y
        help
          Share a serial console with kgdb. Sysrq-g must be used
          to break in initially.

KGDB Boot and Module Options

  1. Boot with kgdboc=<tty-device>,[baud] (e.g. kgdboc=ttyAMA1 for an integratorcp board emulated by qemu-system-arm, vport0p2 for virtio serial, ttyS0 for a 16550 UART on an x86 etc)
  2. (alternatively) From sysfs
    echo TTY_DEVICE > /sys/module/kgdboc/parameters/kgdboc

Connecting GDB to the Kernel through a QEMU Emulated Serial Port

  • [arm-cross: linux-2.6]$ qemu-system-arm -nographic -s -M integratorcp -kernel ./zImage-2.6.32-integratorcp-v5 -serial tcp:localhost:2345,server -append "console=ttyAMA0 root=/dev/nfs nfsroot=172.20.0.1:/nfsroot/box,nfsvers=3 rw ip=172.20.0.2::172.20.0.1:255.255.255.0 kgdboc=ttyAMA0 kgdbwait"
  • [arm-cross: linux-2.6]$ telnet localhost:2345
  • Wait till the telnet session shows "kgdb: Waiting for connection from remote gdb..." then terminate telnet with CTRL-] then CTRL-D
  • [arm-cross: linux-2.6]$ gdb ./vmlinux
  • (gdb) target remote localhost:2345
  • Trouble Shooting: (gdb) set debug remote 1

Connecting GDB to the Kernel through a Physical Serial Port

  • [scottt@2530p linux-2.6]$ gdb ./vmlinux
  • (gdb) set remotebaud 115200
  • (gdb) target remote /dev/ttyS0 # change ttyS0 to the actual serial device on your development machine