隨筆 - 1, 文章 - 2, 評論 - 0, 引用 - 0
          數據加載中……

          2009年10月14日

          gdb調試nasm語法的匯編程序

          源代碼
           1 section .data          
           2         msg db 'Hello, world!'0xA    
           3         len equ $ - msg                 
           4 section .text            
           5 global main            
           6 main:                  
           7         mov edx, len     
           8         mov ecx, msg    
           9         mov ebx, 1       
          10         mov eax, 4      
          11         int 0x80         
          12         mov ebx, 0      
          13         mov eax, 1       
          14         int 0x80  
          開始調試javen@javen-laptop:~/study$ nasm -f elf hello.asm --F stabs
          javen@javen-laptop:~/study$ gcc -o hello hello.o -g
          javen@javen
          -laptop:~/study$ gdb hello
          GNU gdb 
          6.8-debian
          Copyright (C) 
          2008 Free Software Foundation, Inc.
          License GPLv3
          +: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
          This is free software: you are free to change and redistribute it.
          There is NO WARRANTY, to the extent permitted by law.  Type 
          "show copying"
          and 
          "show warranty" for details.
          This GDB was configured as 
          "i486-linux-gnu"
          (gdb) 
          開始運行
          (gdb) start
          Breakpoint 
          1 at 0x80483a0: file hello.asm, line 7.
          Starting program: 
          /home/javen/study/hello 
          main () at hello.asm:
          7
          7            mov edx, len     
          (gdb)
          查看反匯編,結果是AT&T語法。
          (gdb) disassemble
          Dump of assembler code 
          for function main:
          0x080483a0 <main+0>:    mov    $0xe,%edx
          0x080483a5 <main+5>:    mov    $0x804a010,%ecx
          0x080483aa <main+10>:    mov    $0x1,%ebx
          0x080483af <main+15>:    mov    $0x4,%eax
          0x080483b4 <main+20>:    int    $0x80
          0x080483b6 <main+22>:    mov    $0x0,%ebx
          0x080483bb <main+27>:    mov    $0x1,%eax
          0x080483c0 <main+32>:    int    $0x80
          0x080483c2 <main+34>:    nop    
          0x080483c3 <main+35>:    nop    
          0x080483c4 <main+36>:    nop    
          0x080483c5 <main+37>:    nop    
          0x080483c6 <main+38>:    nop    
          0x080483c7 <main+39>:    nop    
          0x080483c8 <main+40>:    nop    
          0x080483c9 <main+41>:    nop    
          0x080483ca <main+42>:    nop    
          0x080483cb <main+43>:    nop    
          0x080483cc <main+44>:    nop    
          0x080483cd <main+45>:    nop    
          0x080483ce <main+46>:    nop    
          0x080483cf <main+47>:    nop
          運行下一步,并查看寄存器,eip改變
          (gdb) n
          8            mov ecx, msg    
          (gdb) info register
          eax            
          0xbfcd9864    -1077045148
          ecx            
          0xe2d47497    -489393001
          edx            
          0xe    14
          ebx            
          0xb80c3ff4    -1207156748
          esp            
          0xbfcd97dc    0xbfcd97dc
          ebp            
          0xbfcd9838    0xbfcd9838
          esi            
          0x80483e0    134513632
          edi            
          0x80482e0    134513376
          eip            0x80483a5    0x80483a5 <main+5>
          eflags         
          0x246    [ PF ZF IF ]
          cs             
          0x73    115
          ss             
          0x7b    123
          ds             
          0x7b    123
          es             
          0x7b    123
          fs             
          0x0    0
          gs             
          0x33    51
          (gdb) n
          9            mov ebx, 1       
          (gdb) info register
          eax            
          0xbfcd9864    -1077045148
          ecx            
          0x804a010    134520848
          edx            
          0xe    14
          ebx            
          0xb80c3ff4    -1207156748
          esp            
          0xbfcd97dc    0xbfcd97dc
          ebp            
          0xbfcd9838    0xbfcd9838
          esi            
          0x80483e0    134513632
          edi            
          0x80482e0    134513376
          eip            
          0x80483aa    0x80483aa <main+10>
          eflags         
          0x246    [ PF ZF IF ]
          cs             
          0x73    115
          ss             
          0x7b    123
          ds             
          0x7b    123
          es             
          0x7b    123
          fs             
          0x0    0
          gs             
          0x33    51
          (gdb)
          查看內存
          (gdb) x  0x80483aa
          0x80483aa <main+10>:    0x000001bb
          (gdb) x  
          0x80483a5
          0x80483a5 <main+5>:    0x04a010b9
          (gdb) 

          詳細的gdb使用網上搜索。


          posted @ 2009-10-15 14:50 賈小二 閱讀(1373) | 評論 (0)編輯 收藏

          ubuntu中tomcat下jsp字體呈方塊解決方法

          在ubuntu現開發web項目,采用編碼GBK的發現,項目運行起來之后jsp頁面中從數據庫中拉取的數據中文字體顯示為小方塊。最終找到了解決方法。
          1 首先解決java代來的字體問題,對于jdk1。6解決方法比較簡單,在$JAVA_HOME/jre/lib/fonts新建目錄fallback直接把相應的中文字體(我用的simsun.ttc),復制到該目錄下。其他版本的jdk相對比較復雜一些可以到網上搜索解決方案。
          2 第一部完成之后發現,又報表聲稱圖片中的字體正常顯示,但數據中拉的中字體還是有很多。現在仔細看一下已經不是沒有字體了是亂碼問題。剩下的問題有兩種解決方法
              (1) 修改$TOMCAT_HOME/BIN/CATALINA.SH,在最上面添加一行
                           CATALINA_OPTS=-Dfile.encoding=GBK
              (2)在shell下
                        locale
                         命令發現linux默認的locale是utf-8 在命令行鍵入  LANG=“zh_CN.GBK”,然后在鍵入locale 命令,沒有一下警告
              locale: Cannot set LC_CTYPE to default locale: No such file or directory
              locale: Cannot set LC_MESSAGES to default locale: No such file or directory
                locale: Cannot set LC_ALL to default locale: No such file or directory
             則問題解決了。
          如果有此警告,sudo vi /var/lib/locales/supported.d/local
            修改在末尾加入
                      zh_CN.GBK GBK
          然后     用命令sudo locale-gen 重新生成locale。問題的一解決。

             歸根是因為jvm的編碼的問題,因為jvm默認的依賴本地編碼,在(1)中是強行設置jvm的編碼。而(2)是修改本地編碼。解決方法不一樣,但是目的卻是一樣。

          posted @ 2009-10-14 14:25 賈小二 閱讀(644) | 評論 (0)編輯 收藏

          新的開始

          新的起點,新的開始,忘記以前所學的一切 ,從頭學起!

          posted @ 2009-10-14 14:10 賈小二 閱讀(147) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 玉树县| 新竹市| 涟水县| 花莲县| 宜兰市| 桃江县| 横峰县| 金昌市| 化德县| 双流县| 双桥区| 塔城市| 鹤壁市| 屏山县| 香格里拉县| 钦州市| 个旧市| 阳西县| 长葛市| 临安市| 浑源县| 宁陕县| 越西县| 云霄县| 武强县| 沾益县| 望江县| 延川县| 景德镇市| 阿坝| 栾川县| 济宁市| 皋兰县| 敦化市| 恩平市| 延边| 都江堰市| 盐池县| 安平县| 泉州市| 龙海市|