大統一Debian勉強会 gdb+python拡張を使ったデバッグ手法

Similar documents

ex01.dvi

2 1. Ubuntu 1.1 OS OS OS ( OS ) OS ( OS ) VMware Player VMware Player jp/download/player/ URL VMware Plaeyr VMware

ex01.dvi

r07.dvi

bash on Ubuntu on Windows bash on Ubuntu on Windows bash on Ubuntu on Windows bash on Ubuntu on Windows bash on Ubuntu on Windows ˆ Windows10 64bit Wi

ohp07.dvi

waylandを動かす

GNU/Linux on SuperH g,,,,, GNU/Linux on SuperH [1] SuperH (SH-3 SH-4) GNU/Linux g linux-kernel 1998 Linux (SH-3) g GD

Microsoft Word - PSB導入ガイド_ docx

C

東京エリアDebian勉強会 - 第91回 2012年9月度/OSC2012 Tokyo/Fall)

joho07-1.ppt

MINI2440マニュアル

double float

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

東京エリアDebian勉強会 Debian JP Project - OSC 2017 Tokyo/Fall (第154回出張勉強会)

programmingII2019-v01

Java updated

E2 Spider 2018/08/03 Intel NUC Core i7 PC 2.5 /M.2 SSD BOXNUC7I7BNH PC DDR4-2133(PC ) 8GBX2 260pin 1.2V CL15 SP016GBSFU213B22 WD SSD M /51

(2 Linux Mozilla [ ] [ ] [ ] [ ] URL 2 qkc, nkc ~/.cshrc (emacs 2 set path=($path /usr/meiji/pub/linux/bin tcsh b

untitled

インストール取扱説明書

64bit SSE2 SSE2 FPU Visual C++ 64bit Inline Assembler 4 FPU SSE2 4.1 FPU Control Word FPU 16bit R R R IC RC(2) PC(2) R R PM UM OM ZM DM IM R: reserved

1.ppt

東京エリアDebian勉強会 - systemd

Condition DAQ condition condition 2 3 XML key value

Debian での数学ことはじめ。 - gnuplot, Octave, R 入門

エラー処理・分割コンパイル・コマンドライン引数

知っておきたいLinuxの知識

Microsoft Word - C.....u.K...doc

( CUDA CUDA CUDA CUDA ( NVIDIA CUDA I

WinHPC ppt

新コンフィギュレータのフレームワークについて

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

Armadillo-9 ソフトウェアマニュアル

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

Raspberry Pi3 / arm64 - Debian/Ubuntu ミートアップ in 札幌

Raspberry Pi 2 Model B に Debian Jessie / armhf をインストールする - 第125回 2015年3月度

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

3 Ubuntu Linux Ubuntu Linux Debian Linux DistroWatch.com 1 Debian Ubuntu Linux 1 Debian CD(4.1 ) Knoppix Debian CentOS Linux CentOS 1 Ubuntu L

HTML5無料セミナ.key

A Responsive Processor for Parallel/Distributed Real-time Processing

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

CX-Checker CX-Checker (1)XPath (2)DOM (3) 3 XPath CX-Checker. MISRA-C 62%(79/127) SQMlint 76%(13/17) XPath CX-Checker 3. CX-Checker 4., MISRA-C CX- Ch

yacc.dvi

新・明解C言語 実践編

第168回東京エリアDebian勉強会   debianにおけるnginxの設定例

第173回東京エリアDebian勉強会   grml-debootstrapを用いた USB起動メモリの作成

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

新版明解C言語 実践編

Compiled MODELSでのDFT位相検出装置のモデル化と評価

Debian GNU/kFreeBSDで暮らせる環境を構築してみる - 第38回関西Debian勉強会

3.2 Linux root vi(vim) vi emacs emacs 4 Linux Kernel Linux Git 4.1 Git Git Linux Linux Linus Fedora root yum install global(debian Ubuntu apt-get inst

NI P1200 Release Notes Cover

東京エリアDebian勉強会 - 第85回 2012年2月度

Linuxデバイスドライバ.PDF

64bit SSE2 SSE2 FPU Visual C++ 64bit Inline Assembler 4 FPU SSE2 4.1 FPU Control Word FPU 16bit R R R IC RC(2) PC(2) R R PM UM OM ZM DM IM R: reserved

UNIX

07-二村幸孝・出口大輔.indd

174 Debian.Deb 銀河系唯一の Debian 専門誌 /usr Merge

Apache Web Server 2 Compaq ActiveAnswers Deskpro Compaq Insight Manager Fastart Systempro Systempro/LT ProLiant ROMPaq Qvision SmartStart NetFlex Quic

K227 Java 2

たのしいプログラミング Pythonではじめよう!

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )


ohp03.dvi

1 CUI CUI CUI 1.1 cout cin redirect.cpp #i n c l u d e <s t r i n g > 3 using namespace std ; 5 6 i n t main ( void ) 7 { 8 s t r i n g s ; 10 c

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

Transcription:

Debian 2013 gdb+python nozzy@debian.or.jp 2013 6 29

Level Debian Up

Debian

Debian debian sid unstable

Debian debian sid unstable *-dbg

Debian debian sid unstable *-dbg gdb

Debian debian sid unstable *-dbg gdb gdb python

Debian!

Debian! debian sid unstable level up debian sid unstable!

Debian! debian sid unstable level up debian sid unstable! *-dbg aptitude install XXXX-dbg XXXX

Debian! debian sid unstable level up debian sid unstable! *-dbg aptitude install XXXX-dbg XXXX gdb /gdb python

Debian

Debian 1 Debian debian sid (jessie/sid) 2 CPU amd64 ( i386 3 OS linux 4 php version 5.5.0 (debian sid ) 5 gdb version 7.6 (debian sid ) kfreebsd Hurd ARM CPU......

*-dbg Debian *-dbg debian *-dbg 2012 Debian debug.debian.net http: // gum. debian. or. jp/ 2012/ ( )

gdb+python Debian gdb+python 98 Debian http: // tokyodebian. alioth. debian. org/ 2013-03. html ( )

*-dbg

*-dbg Debian 1 *-dbg -dbg 2 COMPATIBILITY LEVEL 9 : COMPATIBILITY LEVEL 9 : BuildID 3 COMPATIBILITY LEVEL 9 : /usr/lib/debug/ /usr/bin/php5 /usr/lib/debug/usr/bin/php5 COMPATIBILITY LEVEL 9 : /usr/lib/debug/.build-id/

*-dbg *-dbg $ cat /etc/debian_version jessie/sid $ aptitude search.*-dbg p 0ad-dbg - Real-time strategy game of p 389-ds-base-dbg - 389 Directory Server suite p 389-ds-base-libs-dbg - 389 Directory Server suite p 7kaa-dbg - Seven Kingdoms Ancient...... $ aptitude search.*-dbg wc -l 2272 $ debian sid(jessie/sid) 2272

*-dbg php5 $ aptitude install php5-dbg $ apt-get source php5/sid $ ls php5-5.5.0+dfsg php5_5.5.0+dfsg-1.dsc php5_5.5.0+dfsg-1.debian.tar.gz php5_5.5.0+dfsg.orig.tar.xz $ pwd /home/yours/php5-src/ $ gdb --args /usr/bin/php5 -r phpinfo() (gdb) set substitute-path /tmp/buildd/ /home/yours/php5-src/ (gdb) b main (gdb) run (gdb) l 1197 #else 1198 int main(int argc, char *argv[]) 1199 #endif 1200 { 1201 #ifdef ZTS 1202 void ***tsrm_ls;

COMPATIBILITY LEVEL Debian debhelper COMPATIBILITY LEVEL debian/ debian sid LEVEL debian/compat COMPATIBILITY LEVEL $ apt-get source php5 $ cat php5-5.5.0+dfsg/debian/compat 5 $ apt-get source gstreamer0.10 $ cat gstreamer0.10-0.10.36/debian/compat 9

COMPATIBILITY LEVEL 9 *-dbg debhelper COMPATIBILITY LEVEL 9 *-dbg php5-dbg $ dpkg -L php5-dbg...... /usr/lib/debug /usr/lib/debug/usr /usr/lib/debug/usr/bin /usr/lib/debug/usr/bin/php5 /usr/lib/debug/usr/bin/php5-cgi /usr/lib/debug/usr/sbin /usr/lib/debug/usr/sbin/php5-fpm...... $ php5 /usr/bin/php5 /usr/lib/debug/usr/bin/php5

COMPATIBILITY LEVEL 9 *-dbg debhelper COMPATIBILITY LEVEL 9 *-dbg libgstreamer0.10-0-dbg $ dpkg -L libgstreamer0.10-0-dbg...... /usr/lib/debug/.build-id/3f/bdb94562139d00e153a2fc6c 720772ca28acad.debug /usr/lib/debug/.build-id/86 /usr/lib/debug/.build-id/86/cc80bb6f2bdb31a2ed02973d 54530b3d99846f.debug /usr/lib/debug/.build-id/44 /usr/lib/debug/.build-id/44/ff321f11ffd750f8c351ffa3 f5d20028d2f6a6.debug /usr/share /usr/share/doc...... $

COMPATIBILITY LEVEL 9 *-dbg $ file /usr/lib/x86_64-linux-gnu/libgstreamer-0.10. so.0.30.0 /usr/lib/x86_64-linux-gnu/libgstreamer-0.10.so.0.30.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=44ff321f11ffd750f8c351ffa3f5d20028d2f6a6, stripped $ BuildID[sha1] /usr/lib/debug/.buildid/44/ff321f11ffd750f8c351ffa3f5d20028d2f6a6.debug libgstreamer-0.10.so.0.30.0

BuildID ID $ readelf -n /usr/lib/x86_64-linux-gnu/libgstreamer- 0.10.so.0 Notes at offset 0x000001c8 with length 0x00000024: Owner Data size Description GNU 0x00000014 NT_GNU_BUILD_ID Build ID: 44ff321f11ffd750f8c351ffa3f5d20028d2f6a6 BuildID BuildID http://fedoraproject.org/wiki/rolandmcgrath/ BuildID BuildID binutils http://sourceware.org/ml/binutils/2007-07/ msg00012.html

gdb.gnu_debuglink $ readelf -x.gnu_debuglink /usr/bin/php5 Hex dump of section.gnu_debuglink : 0x00000000 70687035....0dd10 php5..... $ readelf -x.gnu_debuglink /usr/lib/x86_64-linux-gnu/ libgstreamer-0.10.so.0.30.0 Hex dump of section.gnu_debuglink : 0x00000000 66663332....06638 ff321f11ffd750f8 0x00000010 63333531....03238 c351ffa3f5d20028 0x00000020 64326636....00000 d2f6a6.debug... 0x00000030 0da0b0f5... php5 php5 libgstreamer-0.10.so.0.30.0 ff321f11ffd750f8c351ffa3f5d20028d2f6a6.debug

/usr/bin/php5 gdb set substitute-path $ gdb --args /usr/bin/gst-launch (gdb) set substitute-path /tmp/buildd/ /home/yours/gstreamer/ (gdb) b main (gdb) run Breakpoint 1, main...... at gst-run.c:318 318 gst-run.c:.

gst-launch gstreamer0.10-0.10.36 gcc (php5 gcc gdb dir

gdb dir $ gdb --args /usr/bin/gst-launch (gdb) dir /home/yours/gstreamer/gstreamer0.10-0.10.36/ tools (gdb) b main (gdb) run (gdb) l 314 } 315 316 int 317 main (int argc, char **argv) 318 { 319 GHashTable *candidates; 320 gchar *dir;

dir gdb dir gdb dir

2013/7/22( ) 2013/7/20( ) Debian Debhelper dir set substitue-path http://tokyodebian.alioth.debian.org/2013-07.html

gdb+python gdb.value

gdb+python gdb python gdb 7.6 1 python-interactive python $ gdb (gdb) pi >>> import sys >>> print sys.version_info sys.version_info(major=2, minor=7, micro=5, releaselevel= final, serial=0) >>> gdb python 1 gdb 7.6 released! http://lwn.net/articles/548781/

gdb.value gdb python gdb.value 1 structure gdb.value structure 2 python 3 structure 4

gdb.value $ sudo aptitude install php5-dbg $ cat./phpinfo.php <?php phpinfo()?> $ gdb --args /usr/bin/php5./phpinfo.php (gdb) b zend_vm_execute.h:356 (gdb) run (gdb) pi >>> edata=gdb.parse_and_eval(... "executor_globals.current_execute_data") >>> print edata.address 0xe60920 <executor_globals+1120> >>> print edata.dereference() {opline = 0x7ffff7fbd778, function_state = {function = 0x7ffff7fbd498, arguments = 0x0},......,call = 0x0} >>> print edata[ op_array ][ filename ] 0x7ffff7fbd640 "/home/yours/phpinfo.php" >>> [Ctrl+D]

gdb.value $ gdb --args /usr/bin/php5./phpinfo.php (gdb) b zend_vm_execute.h:356 (gdb) run (gdb) pi >>> phpfile=(gdb.parse_and_eval(... "zend_get_executed_filename")).dereference() >>> print phpfile {const char *(void)} 0x6c7600 <zend_get_executed_filename> >>> print phpfile() 0x7ffff7fc4418 "/home/yours/phpinfo.php >>> [Ctrl+D] (gdb)

gdb.value gdb.value str() gdb p pointer str.partition(" ") $ gdb --args /usr/bin/php5./phpinfo.php (gdb) b zend_vm_execute.h:356 (gdb) run (gdb) pi >>> phpfile=(gdb.parse_and_eval(... "zend_get_executed_filename")).dereference() >>> filename=phpfile() >>> print str(filename) 0x7ffff7fc4418 "/home/yours/phpinfo.php" >>> print (str(filename).partition(" "))[2] "/home/yours/phpinfo.php"

php5.5.0

php5.5.0 php5.5.0 execute_ex()(zend/zend_vm_execue.h) execute_internal()(zend/zend_execute.c) php C

gdb execute_ex() gdb Zend/zend_vm_execute.h 330 ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC) 331 { 332 DCL_OPLINE 333 zend_bool original_in_execution;...... 356 if ((ret = OPLINE->handler( <--- execute_data TSRMLS_CC)) > 0) { 357 switch (ret) {

php5.5.0 API php5.5.0 Zend Engine API zend_get_executed_filename() (Zend/zend_execute_API.c) php get_active_function_name() (Zend/zend_execute_API.c) zend_get_executed_lineno() (Zend/zend_execute_API.c)

php

gdb php php xdebug vim-nox+debugger plugin/netbean/eclipse php xdebug gdb php

php 7/22( ): http://tokyodebian.alioth.debian.org/pdf/ debianmeetingresume2013-gum.pdf

gdb+python php gdb python php php gdb php php executor_globals php5.5.0 Zend API php API gdb php