﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-David.Ko-随笔分类-Android</title><link>http://www.blogjava.net/ThinkingTalking/category/41804.html</link><description>Follow my heart!</description><language>zh-cn</language><lastBuildDate>Sat, 20 Nov 2010 13:51:22 GMT</lastBuildDate><pubDate>Sat, 20 Nov 2010 13:51:22 GMT</pubDate><ttl>60</ttl><item><title>[转载]Android平台——Binder机制</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/11/18/338404.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Thu, 18 Nov 2010 09:15:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/11/18/338404.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/338404.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/11/18/338404.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/338404.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/338404.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 由代码来补充部分：int&nbsp;main(int&nbsp;argc,&nbsp;char** argv){&nbsp;&nbsp;&nbsp;&nbsp;sp&lt;ProcessState&gt; proc(ProcessState::self());&nbsp;&nbsp;&nbsp;&nbsp;sp&lt;IServiceManager&gt; sm = default...&nbsp;&nbsp;<a href='http://www.blogjava.net/ThinkingTalking/archive/2010/11/18/338404.html'>阅读全文</a><img src ="http://www.blogjava.net/ThinkingTalking/aggbug/338404.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-11-18 17:15 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/11/18/338404.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】Android 多个APK共享数据(Shared User ID)</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/07/28/327349.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Wed, 28 Jul 2010 09:21:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/07/28/327349.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/327349.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/07/28/327349.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/327349.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/327349.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; ">Android给每个APK进程分配一个单独的用户空间,其manifest中的userid就是对应一个Linux用户<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
(Android 系统是基于Linux)的.<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
所以不同APK(用户)间互相访问数据默认是禁止的.<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
但是它也提供了2种APK间共享数据的形式:<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
1. Share Preference. / Content Provider<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
APK可以指定接口和数据给任何其他APK读取. 需要自己实现接口和Share的数据.<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
本文对于这个不做详细解释<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
2. Shared User id<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
通过Shared User id,拥有同一个User id的多个APK可以配置成运行在同一个进程中.所以默认就是<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
可以互相访问任意数据. 也可以配置成运行成不同的进程, 同时可以访问其他APK的数据目录下的<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
数据库和文件.就像访问本程序的数据一样.<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
比如某个公司开发了多个Android 程序, 那么可以把数据,图片等资源集中放到APK A中去. 然后<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
这个公司的所有APK都使用同一个User ID, 那么所有的资源都可以从APK A中读取.<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
举个例子:<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
APK A 和APK B 都是C公司的产品,那么如果用户从APK A中登陆成功.那么打开APK B的时候就不用<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
再次登陆. 具体实现就是 A和B设置成同一个User ID:<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
* 在2个APK的AndroidManifest.xml 配置User ID:<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
package="com.android.demo.a1"<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
android:sharedUserId="com.c"&gt;<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
这个"com.c" 就是user id, 然后packagename APK A就是上面的内容, APK B可能<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
是"com.android.demo.b1" 这个没有限制<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
这个设定好之后, APK B就可以像打开本地数据库那样 打开APK A中的数据库了.<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
APK A把登陆信息存放在A的数据目录下面. APK B每次启动的时候读取APK A下面的数据库<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
判断是否已经登陆:<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
APK B中的代码:<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
friendContext = this.createPackageContext(<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
"com.android.demo.a1",<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
Context.CONTEXT_IGNORE_SECURITY);<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
通过A的package name 就可以得到A的 packagecontext<br style="line-height: 22px; " />
<br style="line-height: 22px; " />
通过这个context就可以直接打开数据库.</span>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/327349.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-07-28 17:21 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/07/28/327349.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gdb</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/07/16/326300.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Fri, 16 Jul 2010 05:39:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/07/16/326300.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/326300.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/07/16/326300.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/326300.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/326300.html</trackback:ping><description><![CDATA[转载于：<a href="http://blog.csdn.net/dadalan/archive/2009/01/12/3758025.aspx">http://blog.csdn.net/dadalan/archive/2009/01/12/3758025.aspx</a>
<div>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="font-family: verdana, sans-serif; font-size: 14px; line-height: 21px; ">用GDB调试程序&nbsp;<br />
GDB是一个强大的命令行调试工具。大家知道命令行的强大就是在于，其可以形成执行序<br />
列，形成脚本。UNIX下的软件全是命令行的，这给程序开发提代供了极大的便利，命令行<br />
软件的优势在于，它们可以非常容易的集成在一起，使用几个简单的已有工具的命令，就可<br />
以做出一个非常强大的功能。&nbsp;<br />
于是UNIX下的软件比Windows下的软件更能有机地结合，各自发挥各自的长处，组合成<br />
更为强劲的功能。而Windows下的图形软件基本上是各自为营，互相不能调用，很不利于<br />
各种软件的相互集成。在这里并不是要和Windows做个什么比较，所谓&#8220;寸有所长，尺有<br />
所短&#8221;，图形化工具还是有不如命令行的地方。&nbsp;<br />
用GDB调试程序&nbsp;<br />
GDB概述&nbsp;<br />
————&nbsp;<br />
GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具。或许，各位比较喜欢那<br />
种图形界面方式的，像VC、BCB等IDE的调试，但如果你是在UNIX平台下做软件，你<br />
会发现GDB这个调试工具有比VC、BCB的图形化调试器更强大的功能。所谓&#8220;寸有所长，<br />
尺有所短&#8221;就是这个道理。&nbsp;<br />
一般来说，GDB主要帮忙你完成下面四个方面的功能：&nbsp;<br />
1、启动你的程序，可以按照你的自定义的要求随心所欲的运行程序。&nbsp;<br />
2、可让被调试的程序在你所指定的调置的断点处停住。（断点可以是条件表达式）&nbsp;<br />
3、当程序被停住时，可以检查此时你的程序中所发生的事。&nbsp;<br />
4、动态的改变你程序的执行环境。&nbsp;<br />
从上面看来，GDB和一般的调试工具没有什么两样，基本上也是完成这些功能，不过在细<br />
节上，你会发现GDB这个调试工具的强大，大家可能比较习惯了图形化的调试工具，但有<br />
时候，命令行的调试工具却有着图形化工具所不能完成的功能。让我们一一看来。&nbsp;<br />
一个调试示例&nbsp;<br />
——————&nbsp;<br />
源程序：tst.c&nbsp;<br />
1 #include&nbsp;<br />
2&nbsp;<br />
3 int func(int n)&nbsp;<br />
4 {&nbsp;<br />
5 int sum=0,i;&nbsp;<br />
6 for(i=0; i&lt;7; i++) {
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">8 sum+=i;&nbsp;<br />
9 }&nbsp;<br />
10 return sum;&nbsp;<br />
11 }&nbsp;<br />
12&nbsp;<br />
13&nbsp;<br />
14 main()&nbsp;<br />
15 {&nbsp;<br />
16 int i;&nbsp;<br />
17 long result = 0;&nbsp;<br />
18 for(i=1; i&lt;=100; i++)&nbsp;<br />
19 {&nbsp;<br />
20 result += i;&nbsp;<br />
21 }&nbsp;<br />
22&nbsp;<br />
23 printf("result[1-100] = %d \n", result );&nbsp;<br />
24 printf("result[1-250] = %d \n", func(250) );&nbsp;<br />
25 }&nbsp;<br />
编译生成执行文件：（Linux下）&nbsp;<br />
hchen/test&gt; cc -g tst.c -o tst&nbsp;<br />
使用GDB调试：&nbsp;<br />
hchen/test&gt; gdb tst &lt;---------- 启动GDB&nbsp;<br />
GNU gdb 5.1.1&nbsp;<br />
Copyright 2002 Free Software Foundation, Inc.&nbsp;<br />
GDB is free software, covered by the GNU General Public License, and you are&nbsp;<br />
welcome to change it and/or distribute copies of it under certain conditions.&nbsp;<br />
Type "show copying" to see the conditions.&nbsp;<br />
There is absolutely no warranty for GDB. Type "show warranty" for details.&nbsp;<br />
This GDB was configured as "i386-suse-linux"...&nbsp;<br />
(gdb) l &lt;-------------------- l命令相当于list，从第一行开始例出原码。&nbsp;<br />
1 #include&nbsp;<br />
2&nbsp;<br />
3 int func(int n)&nbsp;<br />
4 {&nbsp;<br />
5 int sum=0,i;&nbsp;<br />
6 for(i=0; i 7 {&nbsp;<br />
8 sum+=i;&nbsp;<br />
9 }&nbsp;<br />
10 return sum;&nbsp;<br />
(gdb) &lt;-------------------- 直接回车表示，重复上一次命令&nbsp;<br />
11 }</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">12&nbsp;<br />
13&nbsp;<br />
14 main()&nbsp;<br />
15 {&nbsp;<br />
16 int i;&nbsp;<br />
17 long result = 0;&nbsp;<br />
18 for(i=1; i&lt;=100; i++)&nbsp;<br />
19 {&nbsp;<br />
20 result += i;&nbsp;<br />
(gdb) break 16 &lt;-------------------- 设置断点，在源程序第16行处。&nbsp;<br />
Breakpoint 1 at 0x8048496: file tst.c, line 16.&nbsp;<br />
(gdb) break func &lt;-------------------- 设置断点，在函数func()入口处。&nbsp;<br />
Breakpoint 2 at 0x8048456: file tst.c, line 5.&nbsp;<br />
(gdb) info break &lt;-------------------- 查看断点信息。&nbsp;<br />
Num Type Disp Enb Address What&nbsp;<br />
1 breakpoint keep y 0x08048496 in main at tst.c:16&nbsp;<br />
2 breakpoint keep y 0x08048456 in func at tst.c:5&nbsp;<br />
(gdb) r &lt;--------------------- 运行程序，run命令简写&nbsp;<br />
Starting program: /home/hchen/test/tst&nbsp;<br />
Breakpoint 1, main () at tst.c:17 &lt;---------- 在断点处停住。&nbsp;<br />
17 long result = 0;&nbsp;<br />
(gdb) n &lt;--------------------- 单条语句执行，next命令简写。&nbsp;<br />
18 for(i=1; i&lt;=100; i++)&nbsp;<br />
(gdb) n&nbsp;<br />
20 result += i;&nbsp;<br />
(gdb) n&nbsp;<br />
18 for(i=1; i&lt;=100; i++)&nbsp;<br />
(gdb) n&nbsp;<br />
20 result += i;&nbsp;<br />
(gdb) c &lt;--------------------- 继续运行程序，continue命令简写。&nbsp;<br />
Continuing.&nbsp;<br />
result[1-100] = 5050 &lt;----------程序输出。&nbsp;<br />
Breakpoint 2, func (n=250) at tst.c:5&nbsp;<br />
5 int sum=0,i;&nbsp;<br />
(gdb) n&nbsp;<br />
6 for(i=1; i&lt;=n; i++)&nbsp;<br />
(gdb) p i &lt;--------------------- 打印变量i的值，print命令简写。&nbsp;<br />
$1 = 134513808&nbsp;<br />
(gdb) n&nbsp;<br />
8 sum+=i;&nbsp;<br />
(gdb) n&nbsp;<br />
6 for(i=1; i&lt;=n; i++)</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">(gdb) p sum&nbsp;<br />
$2 = 1&nbsp;<br />
(gdb) n&nbsp;<br />
8 sum+=i;&nbsp;<br />
(gdb) p i&nbsp;<br />
$3 = 2&nbsp;<br />
(gdb) n&nbsp;<br />
6 for(i=1; i&lt;=n; i++)&nbsp;<br />
(gdb) p sum&nbsp;<br />
$4 = 3&nbsp;<br />
(gdb) bt &lt;--------------------- 查看函数堆栈。&nbsp;<br />
#0 func (n=250) at tst.c:5&nbsp;<br />
#1 0x080484e4 in main () at tst.c:24&nbsp;<br />
#2 0x400409ed in __libc_start_main () from /lib/libc.so.6&nbsp;<br />
(gdb) finish &lt;--------------------- 退出函数。&nbsp;<br />
Run till exit from #0 func (n=250) at tst.c:5&nbsp;<br />
0x080484e4 in main () at tst.c:24&nbsp;<br />
24 printf("result[1-250] = %d \n", func(250) );&nbsp;<br />
Value returned is $6 = 31375&nbsp;<br />
(gdb) c &lt;--------------------- 继续运行。&nbsp;<br />
Continuing.&nbsp;<br />
result[1-250] = 31375 &lt;----------程序输出。&nbsp;<br />
Program exited with code 027. &lt;--------程序退出，调试结束。&nbsp;<br />
(gdb) q &lt;--------------------- 退出gdb。&nbsp;<br />
hchen/test&gt;&nbsp;<br />
好了，有了以上的感性认识，还是让我们来系统地认识一下gdb吧。&nbsp;<br />
使用GDB&nbsp;<br />
————&nbsp;<br />
一般来说GDB主要调试的是C/C++的程序。要调试C/C++的程序，首先在编译时，我们必<br />
须要把调试信息加到可执行文件中。使用编译器（cc/gcc/g++）的 -g 参数可以做到这一点。<br />
如：&nbsp;<br />
&gt; cc -g hello.c -o hello&nbsp;<br />
&gt; g++ -g hello.cpp -o hello&nbsp;<br />
如果没有-g，你将看不见程序的函数名、变量名，所代替的全是运行时的内存地址。当你用<br />
-g把调试信息加入之后，并成功编译目标代码以后，让我们来看看如何用gdb来调试他。&nbsp;<br />
启动GDB的方法有以下几种：</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">1、gdb&nbsp;<br />
program也就是你的执行文件，一般在当然目录下。&nbsp;<br />
2、gdb core&nbsp;<br />
用gdb同时调试一个运行程序和core文件，core是程序非法执行后core dump后产生的文件。&nbsp;<br />
3、gdb&nbsp;<br />
如果你的程序是一个服务程序，那么你可以指定这个服务程序运行时的进程ID。gdb会自<br />
动attach上去，并调试他。program应该在PATH环境变量中搜索得到。&nbsp;<br />
GDB启动时，可以加上一些GDB的启动开关，详细的开关可以用gdb -help查看。我在下<br />
面只例举一些比较常用的参数：&nbsp;<br />
-symbols&nbsp;<br />
-s&nbsp;<br />
从指定文件中读取符号表。&nbsp;<br />
-se file&nbsp;<br />
从指定文件中读取符号表信息，并把他用在可执行文件中。&nbsp;<br />
-core&nbsp;<br />
-c&nbsp;<br />
调试时core dump的core文件。&nbsp;<br />
-directory&nbsp;<br />
-d&nbsp;<br />
加入一个源文件的搜索路径。默认搜索路径是环境变量中PATH所定义的路径。&nbsp;<br />
GDB的命令概貌&nbsp;<br />
———————&nbsp;<br />
启动gdb后，就你被带入gdb的调试环境中，就可以使用gdb的命令开始调试程序了，gdb<br />
的命令可以使用help命令来查看，如下所示：&nbsp;<br />
/home/hchen&gt; gdb&nbsp;<br />
GNU gdb 5.1.1&nbsp;<br />
Copyright 2002 Free Software Foundation, Inc.&nbsp;<br />
GDB is free software, covered by the GNU General Public License, and you are&nbsp;<br />
welcome to change it and/or distribute copies of it under certain conditions.&nbsp;<br />
Type "show copying" to see the conditions.&nbsp;<br />
There is absolutely no warranty for GDB. Type "show warranty" for details.&nbsp;<br />
This GDB was configured as "i386-suse-linux".&nbsp;<br />
(gdb) help</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">List of classes of commands:&nbsp;<br />
aliases -- Aliases of other commands&nbsp;<br />
breakpoints -- Making program stop at certain points&nbsp;<br />
data -- Examining data&nbsp;<br />
files -- Specifying and examining files&nbsp;<br />
internals -- Maintenance commands&nbsp;<br />
obscure -- Obscure features&nbsp;<br />
running -- Running the program&nbsp;<br />
stack -- Examining the stack&nbsp;<br />
status -- Status inquiries&nbsp;<br />
support -- Support facilities&nbsp;<br />
tracepoints -- Tracing of program execution without stopping the program&nbsp;<br />
user-defined -- User-defined commands&nbsp;<br />
Type "help" followed by a class name for a list of commands in that class.&nbsp;<br />
Type "help" followed by command name for full documentation.&nbsp;<br />
Command name abbreviations are allowed if unambiguous.&nbsp;<br />
(gdb)&nbsp;<br />
gdb的命令很多，gdb把之分成许多个种类。help命令只是例出gdb的命令种类，如果要看<br />
种类中的命令，可以使用help 命令，如：help breakpoints，查看设置断点的所有命令。也<br />
可以直接help 来查看命令的帮助。&nbsp;<br />
gdb中，输入命令时，可以不用打全命令，只用打命令的前几个字符就可以了，当然，命令<br />
的前几个字符应该要标志着一个唯一的命令，在Linux下，你可以敲击两次TAB键来补齐<br />
命令的全称，如果有重复的，那么gdb会把其例出来。&nbsp;<br />
示例一：在进入函数func时，设置一个断点。可以敲入break func，或是直接就是b func&nbsp;<br />
(gdb) b func&nbsp;<br />
Breakpoint 1 at 0x8048458: file hello.c, line 10.&nbsp;<br />
示例二：敲入b按两次TAB键，你会看到所有b打头的命令：&nbsp;<br />
(gdb) b&nbsp;<br />
backtrace break bt&nbsp;<br />
(gdb)&nbsp;<br />
示例三：只记得函数的前缀，可以这样：&nbsp;<br />
(gdb) b make_ &lt;按TAB键&gt;&nbsp;<br />
（再按下一次TAB键，你会看到:）&nbsp;<br />
make_a_section_from_file make_environ&nbsp;<br />
make_abs_section make_function_type&nbsp;<br />
make_blockvector make_pointer_type</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">make_cleanup make_reference_type&nbsp;<br />
make_command make_symbol_completion_list&nbsp;<br />
(gdb) b make_&nbsp;<br />
GDB把所有make开头的函数全部例出来给你查看。&nbsp;<br />
示例四：调试C++的程序时，有可以函数名一样。如：&nbsp;<br />
(gdb) b 'bubble( M-?&nbsp;<br />
bubble(double,double) bubble(int,int)&nbsp;<br />
(gdb) b 'bubble(&nbsp;<br />
你可以查看到C++中的所有的重载函数及参数。（注：M-?和&#8220;按两次TAB键&#8221;是一个意思）&nbsp;<br />
要退出gdb时，只用发quit或命令简称q就行了。&nbsp;<br />
GDB中运行UNIX的shell程序&nbsp;<br />
————————————&nbsp;<br />
在gdb环境中，你可以执行UNIX的shell的命令，使用gdb的shell命令来完成：&nbsp;<br />
shell&nbsp;<br />
调用UNIX的shell来执行，环境变量SHELL中定义的UNIX的shell将会被用来执行，如<br />
果SHELL没有定义，那就使用UNIX的标准shell：/bin/sh。（在Windows中使用Command.com<br />
或cmd.exe）&nbsp;<br />
还有一个gdb命令是make：&nbsp;<br />
make&nbsp;<br />
可以在gdb中执行make命令来重新build自己的程序。这个命令等价于&#8220;shell make &#8221;。&nbsp;<br />
在GDB中运行程序&nbsp;<br />
————————&nbsp;<br />
当以gdb 方式启动gdb后，gdb会在PATH路径和当前目录中搜索的源文件。如要确认gdb<br />
是否读到源文件，可使用l或list命令，看看gdb是否能列出源代码。&nbsp;<br />
在gdb中，运行程序使用r或是run命令。程序的运行，你有可能需要设置下面四方面的事。&nbsp;<br />
1、程序运行参数。&nbsp;<br />
set args 可指定运行时参数。（如：set args 10 20 30 40 50）&nbsp;<br />
show args 命令可以查看设置好的运行参数。&nbsp;<br />
2、运行环境。&nbsp;<br />
path&nbsp;<br />
可设定程序的运行路径。&nbsp;<br />
show paths 查看程序的运行路径。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">set environment varname [=value] 设置环境变量。如：set env USER=hchen&nbsp;<br />
show environment [varname] 查看环境变量。&nbsp;<br />
3、工作目录。&nbsp;<br />
cd&nbsp;<br />
相当于shell的cd命令。&nbsp;<br />
pwd 显示当前的所在目录。&nbsp;<br />
4、程序的输入输出。&nbsp;<br />
info terminal 显示你程序用到的终端的模式。&nbsp;<br />
使用重定向控制程序输出。如：run &gt; outfile&nbsp;<br />
tty命令可以指写输入输出的终端设备。如：tty /dev/ttyb&nbsp;<br />
调试已运行的程序&nbsp;<br />
————————&nbsp;<br />
两种方法：&nbsp;<br />
1、在UNIX下用ps查看正在运行的程序的PID（进程ID），然后用gdb PID格式挂接正在<br />
运行的程序。&nbsp;<br />
2、先用gdb 关联上源代码，并进行gdb，在gdb中用attach命令来挂接进程的PID。并用<br />
detach来取消挂接的进程。&nbsp;<br />
暂停 / 恢复程序运行&nbsp;<br />
—————————&nbsp;<br />
调试程序中，暂停程序运行是必须的，GDB可以方便地暂停程序的运行。你可以设置程序<br />
的在哪行停住，在什么条件下停住，在收到什么信号时停往等等。以便于你查看运行时的变<br />
量，以及运行时的流程。&nbsp;<br />
当进程被gdb停住时，你可以使用info program 来查看程序的是否在运行，进程号，被暂停<br />
的原因。&nbsp;<br />
在gdb中，我们可以有以下几种暂停方式：断点（BreakPoint）、观察点（WatchPoint）、捕<br />
捉点（CatchPoint）、信号（Signals）、线程停止（Thread Stops）。如果要恢复程序运行，可<br />
以使用c或是continue命令。&nbsp;<br />
一、设置断点（BreakPoint）&nbsp;<br />
我们用break命令来设置断点。正面有几点设置断点的方法：&nbsp;<br />
break&nbsp;<br />
在进入指定函数时停住。C++中可以使用class::function或function(type,type)格式来指定函</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">数名。&nbsp;<br />
break&nbsp;<br />
在指定行号停住。&nbsp;<br />
break +offset&nbsp;<br />
break -offset&nbsp;<br />
在当前行号的前面或后面的offset行停住。offiset为自然数。&nbsp;<br />
break filename:linenum&nbsp;<br />
在源文件filename的linenum行处停住。&nbsp;<br />
break filename:function&nbsp;<br />
在源文件filename的function函数的入口处停住。&nbsp;<br />
break *address&nbsp;<br />
在程序运行的内存地址处停住。&nbsp;<br />
break&nbsp;<br />
break命令没有参数时，表示在下一条指令处停住。&nbsp;<br />
break ... if&nbsp;<br />
...可以是上述的参数，condition表示条件，在条件成立时停住。比如在循环境体中，可以设<br />
置break if i=100，表示当i为100时停住程序。&nbsp;<br />
查看断点时，可使用info命令，如下所示：（注：n表示断点号）&nbsp;<br />
info breakpoints [n]&nbsp;<br />
info break [n]&nbsp;<br />
二、设置观察点（WatchPoint）&nbsp;<br />
观察点一般来观察某个表达式（变量也是一种表达式）的值是否有变化了，如果有变化，马<br />
上停住程序。我们有下面的几种方法来设置观察点：&nbsp;<br />
watch&nbsp;<br />
为表达式（变量）expr设置一个观察点。一量表达式值有变化时，马上停住程序。&nbsp;<br />
rwatch&nbsp;<br />
当表达式（变量）expr被读时，停住程序。&nbsp;<br />
awatch&nbsp;<br />
当表达式（变量）的值被读或被写时，停住程序。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">info watchpoints&nbsp;<br />
列出当前所设置了的所有观察点。&nbsp;<br />
三、设置捕捉点（CatchPoint）&nbsp;<br />
你可设置捕捉点来补捉程序运行时的一些事件。如：载入共享库（动态链接库）或是C++<br />
的异常。设置捕捉点的格式为：&nbsp;<br />
catch&nbsp;<br />
当event发生时，停住程序。event可以是下面的内容：&nbsp;<br />
1、throw 一个C++抛出的异常。（throw为关键字）&nbsp;<br />
2、catch 一个C++捕捉到的异常。（catch为关键字）&nbsp;<br />
3、exec 调用系统调用exec时。（exec为关键字，目前此功能只在HP-UX下有用）&nbsp;<br />
4、fork 调用系统调用fork时。（fork为关键字，目前此功能只在HP-UX下有用）&nbsp;<br />
5、vfork 调用系统调用vfork时。（vfork为关键字，目前此功能只在HP-UX下有用）&nbsp;<br />
6、load 或 load 载入共享库（动态链接库）时。（load为关键字，目前此功能只在HP-UX<br />
下有用）&nbsp;<br />
7、unload 或 unload 卸载共享库（动态链接库）时。（unload为关键字，目前此功能只在<br />
HP-UX下有用）&nbsp;<br />
tcatch&nbsp;<br />
只设置一次捕捉点，当程序停住以后，应点被自动删除。&nbsp;<br />
四、维护停止点&nbsp;<br />
上面说了如何设置程序的停止点，GDB中的停止点也就是上述的三类。在GDB中，如果你<br />
觉得已定义好的停止点没有用了，你可以使用delete、clear、disable、enable这几个命令来<br />
进行维护。&nbsp;<br />
clear&nbsp;<br />
清除所有的已定义的停止点。&nbsp;<br />
clear&nbsp;<br />
clear&nbsp;<br />
清除所有设置在函数上的停止点。&nbsp;<br />
clear&nbsp;<br />
clear&nbsp;<br />
清除所有设置在指定行上的停止点。&nbsp;<br />
delete [breakpoints] [range...]&nbsp;<br />
删除指定的断点，breakpoints为断点号。如果不指定断点号，则表示删除所有的断点。range&nbsp;<br />
表示断点号的范围（如：3-7）。其简写命令为d。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">比删除更好的一种方法是disable停止点，disable了的停止点，GDB不会删除，当你还需要<br />
时，enable即可，就好像回收站一样。&nbsp;<br />
disable [breakpoints] [range...]&nbsp;<br />
disable所指定的停止点，breakpoints为停止点号。如果什么都不指定，表示disable所有的<br />
停止点。简写命令是dis.&nbsp;<br />
enable [breakpoints] [range...]&nbsp;<br />
enable所指定的停止点，breakpoints为停止点号。&nbsp;<br />
enable [breakpoints] once range...&nbsp;<br />
enable所指定的停止点一次，当程序停止后，该停止点马上被GDB自动disable。&nbsp;<br />
enable [breakpoints] delete range...&nbsp;<br />
enable所指定的停止点一次，当程序停止后，该停止点马上被GDB自动删除。&nbsp;<br />
五、停止条件维护&nbsp;<br />
前面在说到设置断点时，我们提到过可以设置一个条件，当条件成立时，程序自动停止，这<br />
是一个非常强大的功能，这里，我想专门说说这个条件的相关维护命令。一般来说，为断点<br />
设置一个条件，我们使用if关键词，后面跟其断点条件。并且，条件设置好后，我们可以<br />
用condition命令来修改断点的条件。（只有break和watch命令支持if，catch目前暂不支持<br />
if）&nbsp;<br />
condition&nbsp;<br />
修改断点号为bnum的停止条件为expression。&nbsp;<br />
condition&nbsp;<br />
清除断点号为bnum的停止条件。&nbsp;<br />
还有一个比较特殊的维护命令ignore，你可以指定程序运行时，忽略停止条件几次。&nbsp;<br />
ignore&nbsp;<br />
表示忽略断点号为bnum的停止条件count次。&nbsp;<br />
六、为停止点设定运行命令&nbsp;<br />
我们可以使用GDB提供的command命令来设置停止点的运行命令。也就是说，当运行的<br />
程序在被停止住时，我们可以让其自动运行一些别的命令，这很有利行自动化调试。对基于<br />
GDB的自动化调试是一个强大的支持。&nbsp;<br />
commands [bnum]</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">... command-list ...&nbsp;<br />
end&nbsp;<br />
为断点号bnum指写一个命令列表。当程序被该断点停住时，gdb会依次运行命令列表中的<br />
命令。&nbsp;<br />
例如：&nbsp;<br />
break foo if x&gt;0&nbsp;<br />
commands&nbsp;<br />
printf "x is %d\n",x&nbsp;<br />
continue&nbsp;<br />
end&nbsp;<br />
断点设置在函数foo中，断点条件是x&gt;0，如果程序被断住后，也就是，一旦x的值在foo<br />
函数中大于0，GDB会自动打印出x的值，并继续运行程序。&nbsp;<br />
如果你要清除断点上的命令序列，那么只要简单的执行一下commands命令，并直接在打个<br />
end就行了。&nbsp;<br />
七、断点菜单&nbsp;<br />
在C++中，可能会重复出现同一个名字的函数若干次（函数重载），在这种情况下，break 不<br />
能告诉GDB要停在哪个函数的入口。当然，你可以使用break 也就是把函数的参数类型告<br />
诉GDB，以指定一个函数。否则的话，GDB会给你列出一个断点菜单供你选择你所需要的<br />
断点。你只要输入你菜单列表中的编号就可以了。如：&nbsp;<br />
(gdb) b String::after&nbsp;<br />
[0] cancel&nbsp;<br />
[1] all&nbsp;<br />
[2] file:String.cc; line number:867&nbsp;<br />
[3] file:String.cc; line number:860&nbsp;<br />
[4] file:String.cc; line number:875&nbsp;<br />
[5] file:String.cc; line number:853&nbsp;<br />
[6] file:String.cc; line number:846&nbsp;<br />
[7] file:String.cc; line number:735&nbsp;<br />
&gt; 2 4 6&nbsp;<br />
Breakpoint 1 at 0xb26c: file String.cc, line 867.&nbsp;<br />
Breakpoint 2 at 0xb344: file String.cc, line 875.&nbsp;<br />
Breakpoint 3 at 0xafcc: file String.cc, line 846.&nbsp;<br />
Multiple breakpoints were set.&nbsp;<br />
Use the "delete" command to delete unwanted&nbsp;<br />
breakpoints.&nbsp;<br />
(gdb)</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">可见，GDB列出了所有after的重载函数，你可以选一下列表编号就行了。0表示放弃设置<br />
断点，1表示所有函数都设置断点。&nbsp;<br />
八、恢复程序运行和单步调试&nbsp;<br />
当程序被停住了，你可以用continue命令恢复程序的运行直到程序结束，或下一个断点到来。<br />
也可以使用step或next命令单步跟踪程序。&nbsp;<br />
continue [ignore-count]&nbsp;<br />
c [ignore-count]&nbsp;<br />
fg [ignore-count]&nbsp;<br />
恢复程序运行，直到程序结束，或是下一个断点到来。ignore-count表示忽略其后的断点次<br />
数。continue，c，fg三个命令都是一样的意思。&nbsp;<br />
step&nbsp;<br />
单步跟踪，如果有函数调用，他会进入该函数。进入函数的前提是，此函数被编译有debug<br />
信息。很像VC等工具中的step in。后面可以加count也可以不加，不加表示一条条地执行，<br />
加表示执行后面的count条指令，然后再停住。&nbsp;<br />
next&nbsp;<br />
同样单步跟踪，如果有函数调用，他不会进入该函数。很像VC等工具中的step over。后面<br />
可以加count也可以不加，不加表示一条条地执行，加表示执行后面的count条指令，然后<br />
再停住。&nbsp;<br />
set step-mode&nbsp;<br />
set step-mode on&nbsp;<br />
打开step-mode模式，于是，在进行单步跟踪时，程序不会因为没有debug信息而不停住。<br />
这个参数有很利于查看机器码。&nbsp;<br />
set step-mod off&nbsp;<br />
关闭step-mode模式。&nbsp;<br />
finish&nbsp;<br />
运行程序，直到当前函数完成返回。并打印函数返回时的堆栈地址和返回值及参数值等信息。&nbsp;<br />
until 或 u&nbsp;<br />
当你厌倦了在一个循环体内单步跟踪时，这个命令可以运行程序直到退出循环体。&nbsp;<br />
stepi 或 si&nbsp;<br />
nexti 或 ni&nbsp;<br />
单步跟踪一条机器指令！一条程序代码有可能由数条机器指令完成，stepi和nexti可以单步<br />
执行机器指令。与之一样有相同功能的命令是&#8220;display/i $pc&#8221; ，当运行完这个命令后，单<br />
步跟踪会在打出程序代码的同时打出机器指令（也就是汇编代码）</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">九、信号（Signals）&nbsp;<br />
信号是一种软中断，是一种处理异步事件的方法。一般来说，操作系统都支持许多信号。尤<br />
其是UNIX，比较重要应用程序一般都会处理信号。UNIX定义了许多信号，比如SIGINT<br />
表示中断字符信号，也就是Ctrl+C的信号，SIGBUS表示硬件故障的信号；SIGCHLD表示<br />
子进程状态改变信号；SIGKILL表示终止程序运行的信号，等等。信号量编程是UNIX下<br />
非常重要的一种技术。&nbsp;<br />
GDB有能力在你调试程序的时候处理任何一种信号，你可以告诉GDB需要处理哪一种信<br />
号。你可以要求GDB收到你所指定的信号时，马上停住正在运行的程序，以供你进行调试。<br />
你可以用GDB的handle命令来完成这一功能。&nbsp;<br />
handle&nbsp;<br />
在GDB中定义一个信号处理。信号可以以SIG开头或不以SIG开头，可以用定义一个要处<br />
理信号的范围（如：SIGIO-SIGKILL，表示处理从SIGIO信号到SIGKILL的信号，其中包<br />
括SIGIO，SIGIOT，SIGKILL三个信号），也可以使用关键字all来标明要处理所有的信号。<br />
一旦被调试的程序接收到信号，运行程序马上会被GDB停住，以供调试。其可以是以下几<br />
种关键字的一个或多个。&nbsp;<br />
nostop&nbsp;<br />
当被调试的程序收到信号时，GDB不会停住程序的运行，但会打出消息告诉你收到这种信<br />
号。&nbsp;<br />
stop&nbsp;<br />
当被调试的程序收到信号时，GDB会停住你的程序。&nbsp;<br />
print&nbsp;<br />
当被调试的程序收到信号时，GDB会显示出一条信息。&nbsp;<br />
noprint&nbsp;<br />
当被调试的程序收到信号时，GDB不会告诉你收到信号的信息。&nbsp;<br />
pass&nbsp;<br />
noignore&nbsp;<br />
当被调试的程序收到信号时，GDB不处理信号。这表示，GDB会把这个信号交给被调试程<br />
序会处理。&nbsp;<br />
nopass&nbsp;<br />
ignore&nbsp;<br />
当被调试的程序收到信号时，GDB不会让被调试程序来处理这个信号。&nbsp;<br />
info signals&nbsp;<br />
info handle&nbsp;<br />
查看有哪些信号在被GDB检测中。&nbsp;<br />
十、线程（Thread Stops）</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">如果你程序是多线程的话，你可以定义你的断点是否在所有的线程上，或是在某个特定的线<br />
程。GDB很容易帮你完成这一工作。&nbsp;<br />
break thread&nbsp;<br />
break thread if ...&nbsp;<br />
linespec指定了断点设置在的源程序的行号。threadno指定了线程的ID，注意，这个ID是<br />
GDB分配的，你可以通过&#8220;info threads&#8221;命令来查看正在运行程序中的线程信息。如果你<br />
不指定thread 则表示你的断点设在所有线程上面。你还可以为某线程指定断点条件。如：&nbsp;<br />
(gdb) break frik.c:13 thread 28 if bartab &gt; lim&nbsp;<br />
当你的程序被GDB停住时，所有的运行线程都会被停住。这方便你你查看运行程序的总体<br />
情况。而在你恢复程序运行时，所有的线程也会被恢复运行。那怕是主进程在被单步调试时。&nbsp;<br />
查看栈信息&nbsp;<br />
—————&nbsp;<br />
当程序被停住了，你需要做的第一件事就是查看程序是在哪里停住的。当你的程序调用了一<br />
个函数，函数的地址，函数参数，函数内的局部变量都会被压入&#8220;栈&#8221;（Stack）中。你可以<br />
用GDB命令来查看当前的栈中的信息。&nbsp;<br />
下面是一些查看函数调用栈信息的GDB命令：&nbsp;<br />
backtrace&nbsp;<br />
bt&nbsp;<br />
打印当前的函数调用栈的所有信息。如：&nbsp;<br />
(gdb) bt&nbsp;<br />
#0 func (n=250) at tst.c:6&nbsp;<br />
#1 0x08048524 in main (argc=1, argv=0xbffff674) at tst.c:30&nbsp;<br />
#2 0x400409ed in __libc_start_main () from /lib/libc.so.6&nbsp;<br />
从上可以看出函数的调用栈信息：__libc_start_main --&gt; main() --&gt; func()&nbsp;<br />
backtrace&nbsp;<br />
bt&nbsp;<br />
n是一个正整数，表示只打印栈顶上n层的栈信息。&nbsp;<br />
backtrace &lt;-n&gt;&nbsp;<br />
bt &lt;-n&gt;&nbsp;<br />
-n表一个负整数，表示只打印栈底下n层的栈信息。&nbsp;<br />
如果你要查看某一层的信息，你需要在切换当前的栈，一般来说，程序停止时，最顶层的栈</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">就是当前栈，如果你要查看栈下面层的详细信息，首先要做的是切换当前栈。&nbsp;<br />
frame&nbsp;<br />
f&nbsp;<br />
n是一个从0开始的整数，是栈中的层编号。比如：frame 0，表示栈顶，frame 1，表示栈的<br />
第二层。&nbsp;<br />
up&nbsp;<br />
表示向栈的上面移动n层，可以不打n，表示向上移动一层。&nbsp;<br />
down&nbsp;<br />
表示向栈的下面移动n层，可以不打n，表示向下移动一层。&nbsp;<br />
上面的命令，都会打印出移动到的栈层的信息。如果你不想让其打出信息。你可以使用这三<br />
个命令：&nbsp;<br />
select-frame 对应于 frame 命令。&nbsp;<br />
up-silently 对应于 up 命令。&nbsp;<br />
down-silently 对应于 down 命令。&nbsp;<br />
查看当前栈层的信息，你可以用以下GDB命令：&nbsp;<br />
frame 或 f&nbsp;<br />
会打印出这些信息：栈的层编号，当前的函数名，函数参数值，函数所在文件及行号，函数<br />
执行到的语句。&nbsp;<br />
info frame&nbsp;<br />
info f&nbsp;<br />
这个命令会打印出更为详细的当前栈层的信息，只不过，大多数都是运行时的内内地址。比<br />
如：函数地址，调用函数的地址，被调用函数的地址，目前的函数是由什么样的程序语言写<br />
成的、函数参数地址及值、局部变量的地址等等。如：&nbsp;<br />
(gdb) info f&nbsp;<br />
Stack level 0, frame at 0xbffff5d4:&nbsp;<br />
eip = 0x804845d in func (tst.c:6); saved eip 0x8048524&nbsp;<br />
called by frame at 0xbffff60c&nbsp;<br />
source language c.&nbsp;<br />
Arglist at 0xbffff5d4, args: n=250&nbsp;<br />
Locals at 0xbffff5d4, Previous frame's sp is 0x0&nbsp;<br />
Saved registers:&nbsp;<br />
ebp at 0xbffff5d4, eip at 0xbffff5d8&nbsp;<br />
info args</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">打印出当前函数的参数名及其值。&nbsp;<br />
info locals&nbsp;<br />
打印出当前函数中所有局部变量及其值。&nbsp;<br />
info catch&nbsp;<br />
打印出当前的函数中的异常处理信息。&nbsp;<br />
查看源程序&nbsp;<br />
—————&nbsp;<br />
一、显示源代码&nbsp;<br />
GDB 可以打印出所调试程序的源代码，当然，在程序编译时一定要加上-g的参数，把源程<br />
序信息编译到执行文件中。不然就看不到源程序了。当程序停下来以后，GDB会报告程序<br />
停在了那个文件的第几行上。你可以用list命令来打印程序的源代码。还是来看一看查看源<br />
代码的GDB命令吧。&nbsp;<br />
list&nbsp;<br />
显示程序第linenum行的周围的源程序。&nbsp;<br />
list&nbsp;<br />
显示函数名为function的函数的源程序。&nbsp;<br />
list&nbsp;<br />
显示当前行后面的源程序。&nbsp;<br />
list -&nbsp;<br />
显示当前行前面的源程序。&nbsp;<br />
一般是打印当前行的上5行和下5行，如果显示函数是是上2行下8行，默认是10行，当<br />
然，你也可以定制显示的范围，使用下面命令可以设置一次显示源程序的行数。&nbsp;<br />
set listsize&nbsp;<br />
设置一次显示源代码的行数。&nbsp;<br />
show listsize&nbsp;<br />
查看当前listsize的设置。&nbsp;<br />
list命令还有下面的用法：&nbsp;<br />
list ,</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">显示从first行到last行之间的源代码。&nbsp;<br />
list ,&nbsp;<br />
显示从当前行到last行之间的源代码。&nbsp;<br />
list +&nbsp;<br />
往后显示源代码。&nbsp;<br />
一般来说在list后面可以跟以下这们的参数：&nbsp;<br />
行号。&nbsp;<br />
&lt;+offset&gt; 当前行号的正偏移量。&nbsp;<br />
&lt;-offset&gt; 当前行号的负偏移量。&nbsp;<br />
哪个文件的哪一行。&nbsp;<br />
函数名。&nbsp;<br />
哪个文件中的哪个函数。&nbsp;<br />
&lt;*address&gt; 程序运行时的语句在内存中的地址。&nbsp;<br />
二、搜索源代码&nbsp;<br />
不仅如此，GDB还提供了源代码搜索的命令：&nbsp;<br />
forward-search&nbsp;<br />
search&nbsp;<br />
向前面搜索。&nbsp;<br />
reverse-search&nbsp;<br />
全部搜索。&nbsp;<br />
其中，就是正则表达式，也主一个字符串的匹配模式，关于正则表达式，我就不在这里讲了，<br />
还请各位查看相关资料。&nbsp;<br />
三、指定源文件的路径&nbsp;<br />
某些时候，用-g编译过后的执行程序中只是包括了源文件的名字，没有路径名。GDB提供<br />
了可以让你指定源文件的路径的命令，以便GDB进行搜索。&nbsp;<br />
directory&nbsp;<br />
dir&nbsp;<br />
加一个源文件路径到当前路径的前面。如果你要指定多个路径，UNIX下你可以使用&#8220;:&#8221;，<br />
Windows下你可以使用&#8220;;&#8221;。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">directory&nbsp;<br />
清除所有的自定义的源文件搜索路径信息。&nbsp;<br />
show directories&nbsp;<br />
显示定义了的源文件搜索路径。&nbsp;<br />
四、源代码的内存&nbsp;<br />
你可以使用info line命令来查看源代码在内存中的地址。info line后面可以跟&#8220;行号&#8221;，&#8220;函<br />
数名&#8221;，&#8220;文件名:行号&#8221;，&#8220;文件名:函数名&#8221;，这个命令会打印出所指定的源码在运行时的内<br />
存地址，如：&nbsp;<br />
(gdb) info line tst.c:func&nbsp;<br />
Line 5 of "tst.c" starts at address 0x8048456 and ends at 0x804845d .&nbsp;<br />
还有一个命令（disassemble）你可以查看源程序的当前执行时的机器码，这个命令会把目前<br />
内存中的指令dump出来。如下面的示例表示查看函数func的汇编代码。&nbsp;<br />
(gdb) disassemble func&nbsp;<br />
Dump of assembler code for function func:&nbsp;<br />
0x8048450 : push %ebp&nbsp;<br />
0x8048451 : mov %esp,%ebp&nbsp;<br />
0x8048453 : sub $0x18,%esp&nbsp;<br />
0x8048456 : movl $0x0,0xfffffffc(%ebp)&nbsp;<br />
0x804845d : movl $0x1,0xfffffff8(%ebp)&nbsp;<br />
0x8048464 : mov 0xfffffff8(%ebp),%eax&nbsp;<br />
0x8048467 : cmp 0x8(%ebp),%eax&nbsp;<br />
0x804846a : jle 0x8048470&nbsp;<br />
0x804846c : jmp 0x8048480&nbsp;<br />
0x804846e : mov %esi,%esi&nbsp;<br />
0x8048470 : mov 0xfffffff8(%ebp),%eax&nbsp;<br />
0x8048473 : add %eax,0xfffffffc(%ebp)&nbsp;<br />
0x8048476 : incl 0xfffffff8(%ebp)&nbsp;<br />
0x8048479 : jmp 0x8048464&nbsp;<br />
0x804847b : nop&nbsp;<br />
0x804847c : lea 0x0(%esi,1),%esi&nbsp;<br />
0x8048480 : mov 0xfffffffc(%ebp),%edx&nbsp;<br />
0x8048483 : mov %edx,%eax&nbsp;<br />
0x8048485 : jmp 0x8048487&nbsp;<br />
0x8048487 : mov %ebp,%esp&nbsp;<br />
0x8048489 : pop %ebp&nbsp;<br />
0x804848a : ret&nbsp;<br />
End of assembler dump.</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">查看运行时数据&nbsp;<br />
———————&nbsp;<br />
在你调试程序时，当程序被停住时，你可以使用print命令（简写命令为p），或是同义命令<br />
inspect来查看当前程序的运行数据。print命令的格式是：&nbsp;<br />
print&nbsp;<br />
print /&nbsp;<br />
是表达式，是你所调试的程序的语言的表达式（GDB可以调试多种编程语言），是输出的格<br />
式，比如，如果要把表达式按16进制的格式输出，那么就是/x。&nbsp;<br />
一、表达式&nbsp;<br />
print和许多GDB的命令一样，可以接受一个表达式，GDB会根据当前的程序运行的数据<br />
来计算这个表达式，既然是表达式，那么就可以是当前程序运行中的const常量、变量、函<br />
数等内容。可惜的是GDB不能使用你在程序中所定义的宏。&nbsp;<br />
表达式的语法应该是当前所调试的语言的语法，由于C/C++是一种大众型的语言，所以，本<br />
文中的例子都是关于C/C++的。（而关于用GDB调试其它语言的章节，我将在后面介绍）&nbsp;<br />
在表达式中，有几种GDB所支持的操作符，它们可以用在任何一种语言中。&nbsp;<br />
@&nbsp;<br />
是一个和数组有关的操作符，在后面会有更详细的说明。&nbsp;<br />
::&nbsp;<br />
指定一个在文件或是一个函数中的变量。&nbsp;<br />
{}&nbsp;<br />
表示一个指向内存地址的类型为type的一个对象。&nbsp;<br />
二、程序变量&nbsp;<br />
在GDB中，你可以随时查看以下三种变量的值：&nbsp;<br />
1、全局变量（所有文件可见的）&nbsp;<br />
2、静态全局变量（当前文件可见的）&nbsp;<br />
3、局部变量（当前Scope可见的）&nbsp;<br />
如果你的局部变量和全局变量发生冲突（也就是重名），一般情况下是局部变量会隐藏全局<br />
变量，也就是说，如果一个全局变量和一个函数中的局部变量同名时，如果当前停止点在函</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">数中，用print显示出的变量的值会是函数中的局部变量的值。如果此时你想查看全局变量<br />
的值时，你可以使用&#8220;::&#8221;操作符：&nbsp;<br />
file::variable&nbsp;<br />
function::variable&nbsp;<br />
可以通过这种形式指定你所想查看的变量，是哪个文件中的或是哪个函数中的。例如，查看<br />
文件f2.c中的全局变量x的值：&nbsp;<br />
gdb) p 'f2.c'::x&nbsp;<br />
当然，&#8220;::&#8221;操作符会和C++中的发生冲突，GDB能自动识别&#8220;::&#8221; 是否C++的操作符，所<br />
以你不必担心在调试C++程序时会出现异常。&nbsp;<br />
另外，需要注意的是，如果你的程序编译时开启了优化选项，那么在用GDB调试被优化过<br />
的程序时，可能会发生某些变量不能访问，或是取值错误码的情况。这个是很正常的，因为<br />
优化程序会删改你的程序，整理你程序的语句顺序，剔除一些无意义的变量等，所以在GDB<br />
调试这种程序时，运行时的指令和你所编写指令就有不一样，也就会出现你所想象不到的结<br />
果。对付这种情况时，需要在编译程序时关闭编译优化。一般来说，几乎所有的编译器都支<br />
持编译优化的开关，例如，GNU的C/C++编译器GCC，你可以使用&#8220;-gstabs&#8221;选项来解决<br />
这个问题。关于编译器的参数，还请查看编译器的使用说明文档。&nbsp;<br />
三、数组&nbsp;<br />
有时候，你需要查看一段连续的内存空间的值。比如数组的一段，或是动态分配的数据的大<br />
小。你可以使用GDB的&#8220;@&#8221;操作符，&#8220;@&#8221;的左边是第一个内存的地址的值，&#8220;@&#8221;的右<br />
边则你你想查看内存的长度。例如，你的程序中有这样的语句：&nbsp;<br />
int *array = (int *) malloc (len * sizeof (int));&nbsp;<br />
于是，在GDB调试过程中，你可以以如下命令显示出这个动态数组的取值：&nbsp;<br />
p&nbsp;<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#42;&#97;&#114;&#114;&#97;&#121;&#64;&#108;&#101;&#110;" style="text-decoration: none; color: #336699; "><font color="#336699">*array@len</font></a>&nbsp;<br />
@的左边是数组的首地址的值，也就是变量array所指向的内容，右边则是数据的长度，其<br />
保存在变量len中，其输出结果，大约是下面这个样子的：&nbsp;<br />
(gdb) p&nbsp;<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#42;&#97;&#114;&#114;&#97;&#121;&#64;&#108;&#101;&#110;" style="text-decoration: none; color: #336699; "><font color="#336699">*array@len</font></a>&nbsp;<br />
$1 = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40}&nbsp;<br />
如果是静态数组的话，可以直接用print数组名，就可以显示数组中所有数据的内容了。&nbsp;<br />
四、输出格式</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">一般来说，GDB会根据变量的类型输出变量的值。但你也可以自定义GDB的输出的格式。<br />
例如，你想输出一个整数的十六进制，或是二进制来查看这个整型变量的中的位的情况。要<br />
做到这样，你可以使用GDB的数据显示格式：&nbsp;<br />
x 按十六进制格式显示变量。&nbsp;<br />
d 按十进制格式显示变量。&nbsp;<br />
u 按十六进制格式显示无符号整型。&nbsp;<br />
o 按八进制格式显示变量。&nbsp;<br />
t 按二进制格式显示变量。&nbsp;<br />
a 按十六进制格式显示变量。&nbsp;<br />
c 按字符格式显示变量。&nbsp;<br />
f 按浮点数格式显示变量。&nbsp;<br />
(gdb) p i&nbsp;<br />
$21 = 101&nbsp;<br />
(gdb) p/a i&nbsp;<br />
$22 = 0x65&nbsp;<br />
(gdb) p/c i&nbsp;<br />
$23 = 101 'e'&nbsp;<br />
(gdb) p/f i&nbsp;<br />
$24 = 1.41531145e-43&nbsp;<br />
(gdb) p/x i&nbsp;<br />
$25 = 0x65&nbsp;<br />
(gdb) p/t i&nbsp;<br />
$26 = 1100101&nbsp;<br />
五、查看内存&nbsp;<br />
你可以使用examine命令（简写是x）来查看内存地址中的值。x命令的语法如下所示：&nbsp;<br />
x/&nbsp;<br />
n、f、u是可选的参数。&nbsp;<br />
n 是一个正整数，表示显示内存的长度，也就是说从当前地址向后显示几个地址的内容。&nbsp;<br />
f 表示显示的格式，参见上面。如果地址所指的是字符串，那么格式可以是s，如果地十是<br />
指令地址，那么格式可以是i。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">u 表示从当前地址往后请求的字节数，如果不指定的话，GDB默认是4个bytes。u参数可<br />
以用下面的字符来代替，b表示单字节，h表示双字节，w表示四字节，g表示八字节。当<br />
我们指定了字节长度后，GDB会从指内存定的内存地址开始，读写指定字节，并把其当作<br />
一个值取出来。&nbsp;<br />
表示一个内存地址。&nbsp;<br />
n/f/u三个参数可以一起使用。例如：&nbsp;<br />
命令：x/3uh 0x54320 表示，从内存地址0x54320读取内容，h表示以双字节为一个单位，3<br />
表示三个单位，u表示按十六进制显示。&nbsp;<br />
六、自动显示&nbsp;<br />
你可以设置一些自动显示的变量，当程序停住时，或是在你单步跟踪时，这些变量会自动显<br />
示。相关的GDB命令是display。&nbsp;<br />
display&nbsp;<br />
display/&nbsp;<br />
display/&nbsp;<br />
expr是一个表达式，fmt表示显示的格式，addr表示内存地址，当你用display设定好了一<br />
个或多个表达式后，只要你的程序被停下来，GDB会自动显示你所设置的这些表达式的值。&nbsp;<br />
格式i和s同样被display支持，一个非常有用的命令是：&nbsp;<br />
display/i $pc&nbsp;<br />
$pc是GDB的环境变量，表示着指令的地址，/i则表示输出格式为机器指令码，也就是汇<br />
编。于是当程序停下后，就会出现源代码和机器指令码相对应的情形，这是一个很有意思的<br />
功能。&nbsp;<br />
下面是一些和display相关的GDB命令：&nbsp;<br />
undisplay&nbsp;<br />
delete display&nbsp;<br />
删除自动显示，dnums意为所设置好了的自动显式的编号。如果要同时删除几个，编号可以<br />
用空格分隔，如果要删除一个范围内的编号，可以用减号表示（如：2-5）&nbsp;<br />
disable display&nbsp;<br />
enable display&nbsp;<br />
disable和enalbe不删除自动显示的设置，而只是让其失效和恢复。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">info display&nbsp;<br />
查看display设置的自动显示的信息。GDB会打出一张表格，向你报告当然调试中设置了多<br />
少个自动显示设置，其中包括，设置的编号，表达式，是否enable。&nbsp;<br />
七、设置显示选项&nbsp;<br />
GDB中关于显示的选项比较多，这里我只例举大多数常用的选项。&nbsp;<br />
set print address&nbsp;<br />
set print address on&nbsp;<br />
打开地址输出，当程序显示函数信息时，GDB会显出函数的参数地址。系统默认为打开的，<br />
如：&nbsp;<br />
(gdb) f&nbsp;<br />
#0 set_quotes (lq=0x34c78 "&lt;&lt;", rq=0x34c88 "&gt;&gt;")&nbsp;<br />
at input.c:530&nbsp;<br />
530 if (lquote != def_lquote)&nbsp;<br />
set print address off&nbsp;<br />
关闭函数的参数地址显示，如：&nbsp;<br />
(gdb) set print addr off&nbsp;<br />
(gdb) f&nbsp;<br />
#0 set_quotes (lq="&lt;&lt;", rq="&gt;&gt;") at input.c:530&nbsp;<br />
530 if (lquote != def_lquote)&nbsp;<br />
show print address&nbsp;<br />
查看当前地址显示选项是否打开。&nbsp;<br />
set print array&nbsp;<br />
set print array on&nbsp;<br />
打开数组显示，打开后当数组显示时，每个元素占一行，如果不打开的话，每个元素则以逗<br />
号分隔。这个选项默认是关闭的。与之相关的两个命令如下，我就不再多说了。&nbsp;<br />
set print array off&nbsp;<br />
show print array&nbsp;<br />
set print elements&nbsp;<br />
这个选项主要是设置数组的，如果你的数组太大了，那么就可以指定一个来指定数据显示的<br />
最大长度，当到达这个长度时，GDB就不再往下显示了。如果设置为0，则表示不限制。&nbsp;<br />
show print elements</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">查看print elements的选项信息。&nbsp;<br />
set print null-stop&nbsp;<br />
如果打开了这个选项，那么当显示字符串时，遇到结束符则停止显示。这个选项默认为off。&nbsp;<br />
set print pretty on&nbsp;<br />
如果打开printf pretty这个选项，那么当GDB显示结构体时会比较漂亮。如：&nbsp;<br />
$1 = {&nbsp;<br />
next = 0x0,&nbsp;<br />
flags = {&nbsp;<br />
sweet = 1,&nbsp;<br />
sour = 1&nbsp;<br />
},&nbsp;<br />
meat = 0x54 "Pork"&nbsp;<br />
}&nbsp;<br />
set print pretty off&nbsp;<br />
关闭printf pretty这个选项，GDB显示结构体时会如下显示：&nbsp;<br />
$1 = {next = 0x0, flags = {sweet = 1, sour = 1}, meat = 0x54 "Pork"}&nbsp;<br />
show print pretty&nbsp;<br />
查看GDB是如何显示结构体的。&nbsp;<br />
set print sevenbit-strings&nbsp;<br />
设置字符显示，是否按&#8220;\nnn&#8221;的格式显示，如果打开，则字符串或字符数据按\nnn显示，<br />
如&#8220;\065&#8221;。&nbsp;<br />
show print sevenbit-strings&nbsp;<br />
查看字符显示开关是否打开。&nbsp;<br />
set print union&nbsp;<br />
设置显示结构体时，是否显式其内的联合体数据。例如有以下数据结构：&nbsp;<br />
typedef enum {Tree, Bug} Species;&nbsp;<br />
typedef enum {Big_tree, Acorn, Seedling} Tree_forms;&nbsp;<br />
typedef enum {Caterpillar, Cocoon, Butterfly}&nbsp;<br />
Bug_forms;&nbsp;<br />
struct thing {&nbsp;<br />
Species it;&nbsp;<br />
union {</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Tree_forms tree;&nbsp;<br />
Bug_forms bug;&nbsp;<br />
} form;&nbsp;<br />
};&nbsp;<br />
struct thing foo = {Tree, {Acorn}};&nbsp;<br />
当打开这个开关时，执行 p foo 命令后，会如下显示：&nbsp;<br />
$1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}}&nbsp;<br />
当关闭这个开关时，执行 p foo 命令后，会如下显示：&nbsp;<br />
$1 = {it = Tree, form = {...}}&nbsp;<br />
show print union&nbsp;<br />
查看联合体数据的显示方式&nbsp;<br />
set print object&nbsp;<br />
在C++中，如果一个对象指针指向其派生类，如果打开这个选项，GDB会自动按照虚方法<br />
调用的规则显示输出，如果关闭这个选项的话，GDB就不管虚函数表了。这个选项默认是<br />
off。&nbsp;<br />
show print object&nbsp;<br />
查看对象选项的设置。&nbsp;<br />
set print static-members&nbsp;<br />
这个选项表示，当显示一个C++对象中的内容是，是否显示其中的静态数据成员。默认是<br />
on。&nbsp;<br />
show print static-members&nbsp;<br />
查看静态数据成员选项设置。&nbsp;<br />
set print vtbl&nbsp;<br />
当此选项打开时，GDB将用比较规整的格式来显示虚函数表时。其默认是关闭的。&nbsp;<br />
show print vtbl&nbsp;<br />
查看虚函数显示格式的选项。&nbsp;<br />
八、历史记录&nbsp;<br />
当你用GDB的print查看程序运行时的数据时，你每一个print都会被GDB记录下来。GDB<br />
会以$1, $2, $3 .....这样的方式为你每一个print命令编上号。于是，你可以使用这个编号访问<br />
以前的表达式，如$1。这个功能所带来的好处是，如果你先前输入了一个比较长的表达式，<br />
如果你还想查看这个表达式的值，你可以使用历史记录来访问，省去了重复输入。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">九、GDB环境变量&nbsp;<br />
你可以在GDB的调试环境中定义自己的变量，用来保存一些调试程序中的运行数据。要定<br />
义一个GDB的变量很简单只需。使用GDB的set命令。GDB的环境变量和UNIX一样，<br />
也是以$起头。如：&nbsp;<br />
set $foo = *object_ptr&nbsp;<br />
使用环境变量时，GDB会在你第一次使用时创建这个变量，而在以后的使用中，则直接对<br />
其賦值。环境变量没有类型，你可以给环境变量定义任一的类型。包括结构体和数组。&nbsp;<br />
show convenience&nbsp;<br />
该命令查看当前所设置的所有的环境变量。&nbsp;<br />
这是一个比较强大的功能，环境变量和程序变量的交互使用，将使得程序调试更为灵活便捷。<br />
例如：&nbsp;<br />
set $i = 0&nbsp;<br />
print bar[$i++]-&gt;contents&nbsp;<br />
于是，当你就不必，print bar[0]-&gt;contents, print bar[1]-&gt;contents地输入命令了。输入这样的<br />
命令后，只用敲回车，重复执行上一条语句，环境变量会自动累加，从而完成逐个输出的功<br />
能。&nbsp;<br />
十、查看寄存器&nbsp;<br />
要查看寄存器的值，很简单，可以使用如下命令：&nbsp;<br />
info registers&nbsp;<br />
查看寄存器的情况。（除了浮点寄存器）&nbsp;<br />
info all-registers&nbsp;<br />
查看所有寄存器的情况。（包括浮点寄存器）&nbsp;<br />
info registers&nbsp;<br />
查看所指定的寄存器的情况。&nbsp;<br />
寄存器中放置了程序运行时的数据，比如程序当前运行的指令地址（ip），程序的当前堆栈<br />
地址（sp）等等。你同样可以使用print命令来访问寄存器的情况，只需要在寄存器名字前<br />
加一个$符号就可以了。如：p $eip。</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">改变程序的执行&nbsp;<br />
———————&nbsp;<br />
一旦使用GDB挂上被调试程序，当程序运行起来后，你可以根据自己的调试思路来动态地<br />
在GDB中更改当前被调试程序的运行线路或是其变量的值，这个强大的功能能够让你更好<br />
的调试你的程序，比如，你可以在程序的一次运行中走遍程序的所有分支。&nbsp;<br />
一、修改变量值&nbsp;<br />
修改被调试程序运行时的变量值，在GDB中很容易实现，使用GDB的print命令即可完成。<br />
如：&nbsp;<br />
(gdb) print x=4&nbsp;<br />
x=4这个表达式是C/C++的语法，意为把变量x的值修改为4，如果你当前调试的语言是<br />
Pascal，那么你可以使用Pascal的语法：x:=4。&nbsp;<br />
在某些时候，很有可能你的变量和GDB中的参数冲突，如：&nbsp;<br />
(gdb) whatis width&nbsp;<br />
type = double&nbsp;<br />
(gdb) p width&nbsp;<br />
$4 = 13&nbsp;<br />
(gdb) set width=47&nbsp;<br />
Invalid syntax in expression.&nbsp;<br />
因为，set width是GDB的命令，所以，出现了&#8220;Invalid syntax in expression&#8221;的设置错误，<br />
此时，你可以使用set var命令来告诉GDB，width不是你GDB的参数，而是程序的变量名，<br />
如：&nbsp;<br />
(gdb) set var width=47&nbsp;<br />
另外，还可能有些情况，GDB并不报告这种错误，所以保险起见，在你改变程序变量取值<br />
时，最好都使用set var格式的GDB命令。&nbsp;<br />
二、跳转执行&nbsp;<br />
一般来说，被调试程序会按照程序代码的运行顺序依次执行。GDB提供了乱序执行的功能，<br />
也就是说，GDB可以修改程序的执行顺序，可以让程序执行随意跳跃。这个功能可以由GDB<br />
的jump命令来完：&nbsp;<br />
jump</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">指定下一条语句的运行点。可以是文件的行号，可以是file:line格式，可以是+num这种偏<br />
移量格式。表式着下一条运行语句从哪里开始。&nbsp;<br />
jump&nbsp;<br />
这里的&nbsp;<br />
是代码行的内存地址。&nbsp;<br />
注意，jump命令不会改变当前的程序栈中的内容，所以，当你从一个函数跳到另一个函数<br />
时，当函数运行完返回时进行弹栈操作时必然会发生错误，可能结果还是非常奇怪的，甚至<br />
于产生程序Core Dump。所以最好是同一个函数中进行跳转。&nbsp;<br />
熟悉汇编的人都知道，程序运行时，有一个寄存器用于保存当前代码所在的内存地址。所以，<br />
jump命令也就是改变了这个寄存器中的值。于是，你可以使用&#8220;set $pc&#8221;来更改跳转执行<br />
的地址。如：&nbsp;<br />
set $pc = 0x485&nbsp;<br />
三、产生信号量&nbsp;<br />
使用singal命令，可以产生一个信号量给被调试的程序。如：中断信号Ctrl+C。这非常方便<br />
于程序的调试，可以在程序运行的任意位置设置断点，并在该断点用GDB产生一个信号量，<br />
这种精确地在某处产生信号非常有利程序的调试。&nbsp;<br />
语法是：signal ，UNIX的系统信号量通常从1到15。所以取值也在这个范围。&nbsp;<br />
single命令和shell的kill命令不同，系统的kill命令发信号给被调试程序时，是由GDB截<br />
获的，而single命令所发出一信号则是直接发给被调试程序的。&nbsp;<br />
四、强制函数返回&nbsp;<br />
如果你的调试断点在某个函数中，并还有语句没有执行完。你可以使用return命令强制函数<br />
忽略还没有执行的语句并返回。&nbsp;<br />
return&nbsp;<br />
return&nbsp;<br />
使用return命令取消当前函数的执行，并立即返回，如果指定了，那么该表达式的值会被认<br />
作函数的返回值。&nbsp;<br />
五、强制调用函数</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">call&nbsp;<br />
表达式中可以一是函数，以此达到强制调用函数的目的。并显示函数的返回值，如果函数返<br />
回值是void，那么就不显示。&nbsp;<br />
另一个相似的命令也可以完成这一功能——print，print后面可以跟表达式，所以也可以用他<br />
来调用函数，print和call的不同是，如果函数返回void，call则不显示，print则显示函数返<br />
回值，并把该值存入历史数据中。&nbsp;<br />
在不同语言中使用GDB&nbsp;<br />
——————————&nbsp;<br />
GDB支持下列语言：C, C++, Fortran, PASCAL, Java, Chill, assembly, 和 Modula-2。一般说<br />
来，GDB会根据你所调试的程序来确定当然的调试语言，比如：发现文件名后缀为&#8220;.c&#8221;<br />
的，GDB会认为是C程序。文件名后缀为&#8220;.C, .cc, .cp, .cpp, .cxx, .c++&#8221;的，GDB会认为是<br />
C++程序。而后缀是&#8220;.f, .F&#8221;的，GDB会认为是Fortran程序，还有，后缀为如果是&#8220;.s, .S&#8221;<br />
的会认为是汇编语言。&nbsp;<br />
也就是说，GDB会根据你所调试的程序的语言，来设置自己的语言环境，并让GDB的命令<br />
跟着语言环境的改变而改变。比如一些GDB命令需要用到表达式或变量时，这些表达式或<br />
变量的语法，完全是根据当前的语言环境而改变的。例如C/C++中对指针的语法是*p，而在<br />
Modula-2中则是p^。并且，如果你当前的程序是由几种不同语言一同编译成的，那到在调<br />
试过程中，GDB也能根据不同的语言自动地切换语言环境。这种跟着语言环境而改变的功<br />
能，真是体贴开发人员的一种设计。&nbsp;<br />
下面是几个相关于GDB语言环境的命令：&nbsp;<br />
show language&nbsp;<br />
查看当前的语言环境。如果GDB不能识为你所调试的编程语言，那么，C语言被认为是默<br />
认的环境。&nbsp;<br />
info frame&nbsp;<br />
查看当前函数的程序语言。&nbsp;<br />
info source&nbsp;<br />
查看当前文件的程序语言。&nbsp;<br />
如果GDB没有检测出当前的程序语言，那么你也可以手动设置当前的程序语言。使用set&nbsp;<br />
language命令即可做到。&nbsp;<br />
当set language命令后什么也不跟的话，你可以查看GDB所支持的语言种类：</p>
<p style="padding-top: 0.9em; padding-right: 0px; padding-bottom: 0.9em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">(gdb) set language&nbsp;<br />
The currently understood settings are:&nbsp;<br />
local or auto Automatic setting based on source file&nbsp;<br />
c Use the C language&nbsp;<br />
c++ Use the C++ language&nbsp;<br />
asm Use the Asm language&nbsp;<br />
chill Use the Chill language&nbsp;<br />
fortran Use the Fortran language&nbsp;<br />
java Use the Java language&nbsp;<br />
modula-2 Use the Modula-2 language&nbsp;<br />
pascal Use the Pascal language&nbsp;<br />
scheme Use the Scheme language&nbsp;<br />
于是你可以在set language后跟上被列出来的程序语言名，来设置当前的语言环境。&nbsp;<br />
后记&nbsp;<br />
——&nbsp;<br />
GDB是一个强大的命令行调试工具。大家知道命令行的强大就是在于，其可以形成执行序<br />
列，形成脚本。UNIX下的软件全是命令行的，这给程序开发提代供了极大的便利，命令行<br />
软件的优势在于，它们可以非常容易的集成在一起，使用几个简单的已有工具的命令，就可<br />
以做出一个非常强大的功能。&nbsp;<br />
于是UNIX下的软件比Windows下的软件更能有机地结合，各自发挥各自的长处，组合成<br />
更为强劲的功能。而Windows下的图形软件基本上是各自为营，互相不能调用，很不利于<br />
各种软件的相互集成。在这里并不是要和Windows做个什么比较，所谓&#8220;寸有所长，尺有<br />
所短&#8221;，图形化工具还是有不如命令行的地方。（看到这句话时，希望各位千万再也不要认为<br />
我就是&#8220;鄙视图形界面&#8221;，和我抬杠了 ）&nbsp;<br />
我是根据版本为5.1.1的GDB所写的这篇文章，所以可能有些功能已被修改，或是又有更<br />
为强劲的功能。而且，我写得非常仓促，写得比较简略，并且，其中我已经看到有许多错别<br />
字了（我用五笔，所以错字让你看不懂），所以，我在这里对我文中的差错表示万分的歉意。&nbsp;<br />
文中所罗列的GDB的功能时，我只是罗列了一些带用的GDB的命令和使用方法，其实，<br />
我这里只讲述的功能大约只占GDB所有功能的60%吧，详细的文档，还是请查看GDB的<br />
帮助和使用手册吧，或许，过段时间，如果我有空，我再写一篇GDB的高级使用。&nbsp;<br />
我个人非常喜欢GDB的自动调试的功能，这个功能真的很强大，试想，我在UNIX下写个<br />
脚本，让脚本自动编译我的程序，被自动调试，并把结果报告出来，调试成功，自动checkin<br />
源码库。一个命令，编译带着调试带着checkin，多爽啊。只是GDB对自动化调试目前支持<br />
还不是很成熟，只能实现半自动化，真心期望着GDB的自动化调试功能的成熟。</p>
</span></div>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/326300.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-07-16 13:39 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/07/16/326300.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>TIFF图像文件分析</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325861.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 12 Jul 2010 05:29:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325861.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/325861.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325861.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/325861.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/325861.html</trackback:ping><description><![CDATA[转载于：http://blog.csdn.net/windcsn/archive/2005/11/16/530915.aspx<br />
<br />
<h1 style="margin: 17pt 0cm 16.5pt 21pt;"><span lang="EN-US"><span><font face="Times New Roman"><font size="3">一、</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><span style="font-family: 宋体;"><font size="3">介绍</font></span></h1>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt 27pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">全名</span><font face="Times New Roman"> <span lang="EN-US">tag image file format,</span></font><span style="font-family: 宋体;">是一种基于标志域的图形。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt 8.9pt; text-indent: 17.95pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">图像是靠指针连接来组织数据的，文件头和数据可以任意数据的存储。</span><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">由四种类型：</span><span lang="EN-US"><font face="Times New Roman">TIFF-B</font></span><span style="font-family: 宋体;">，二色；</span><span lang="EN-US"><font face="Times New Roman">TIFF-G</font></span><span style="font-family: 宋体;">，黑白灰度；</span><span lang="EN-US"><font face="Times New Roman">TIFF-P</font></span><span style="font-family: 宋体;">，带调色板的彩色图形；</span><span lang="EN-US"><font face="Times New Roman">TIFF-R</font></span><span style="font-family: 宋体;">，适合</span><span lang="EN-US"><font face="Times New Roman">RGB</font></span><span style="font-family: 宋体;">色彩的图形。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt 8.9pt; text-indent: 17.95pt;"><span lang="EN-US">
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
</span></p>
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
<h1 style="margin: 17pt 0cm 16.5pt 21pt;"><span lang="EN-US"><span><font face="Times New Roman"><font size="3">二、</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><span style="font-family: 宋体;"><font size="3">组成</font></span></h1>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 27pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">一般来说由四部分组成：文件头、文件目录、目录内容、图像数据；如下图，下面具体说明。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 27pt;"><font size="3"><span style="font-family: 宋体;"><img alt="" src="http://blog.csdn.net/images/blog_csdn_net/windcsn/tiffstruct.jpg" /></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"><span lang="EN-US"><font size="3"><shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"></shapetype><stroke joinstyle="miter"></stroke>
<formulas>
</formulas>
<f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f>
<path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path>
<lock v:ext="edit" aspectratio="t"></lock><shape id="_x0000_i1025" style="width: 338.25pt; height: 382.5pt;" type="#_x0000_t75"></shape><imagedata src="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.png" o:title=""></imagedata></font></span></p>
<h1 style="margin: 17pt 0cm 16.5pt 21pt;"><span lang="EN-US"><span><font face="Times New Roman"><font size="3">三、</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><span style="font-family: 宋体;"><font size="3">具体格式</font></span></h1>
<h2 style="margin: 13pt 0cm 13pt 21pt;"><span lang="EN-US"><span><font size="3">1.</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 黑体;"><font size="3">文件头部分</font></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 17.95pt;"><font size="3"><span style="font-family: 宋体;">文件头部分有</span><span lang="EN-US"><font face="Times New Roman">8</font></span><span style="font-family: 宋体;">个字节，格式为：</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><font size="3" face="Times New Roman">0<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>2<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>4</font></span></p>
<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" cellpadding="0" cellspacing="0" border="1">
    <tbody>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 213pt; background-color: transparent;" valign="top" width="284">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">II/MM</font></span><span style="font-family: 宋体;">（表示字节序）</span></font></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 213.1pt; background-color: transparent;" valign="top" width="284">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">42</font></span><span style="font-family: 宋体;">（版本号）</span></font></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 426.1pt; background-color: transparent;" colspan="2" valign="top" width="568">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">文件目录在整个文件的偏移量，是一个指针，指向</span><span lang="EN-US"><font face="Times New Roman">IFD</font></span><span style="font-family: 宋体;">的开始部分</span></font></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt 410.25pt; text-indent: -410.25pt;"><font face="Times New Roman"><span lang="EN-US"><span><font size="3">5</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><span lang="EN-US"><font size="3">8</font></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 17.95pt;"><font size="3"><span style="color: red; font-family: 宋体;">注意这里的值不一定就是紧接头后的</span><chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="a" w:st="on"></chmetcnv><span style="color: red;" lang="EN-US"><font face="Times New Roman">0A</font></span><span style="color: red; font-family: 宋体;">地址，可以是任意的。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 17.95pt;"><span style="color: red;" lang="EN-US">
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
</span></p>
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
<h2 style="margin: 13pt 0cm 13pt 21pt;"><span lang="EN-US"><span><font size="3">2.</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 黑体;"><font size="3">文件目录部分</font></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><font size="3" face="Times New Roman">0<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>2<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>14</font></span></p>
<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" cellpadding="0" cellspacing="0" border="1">
    <tbody>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 213pt; background-color: transparent;" valign="top" width="284">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">IFD</font></span><span style="font-family: 宋体;">的总项数</span></font></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 213.1pt; background-color: transparent;" valign="top" width="284">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">项</span><span lang="EN-US"><font face="Times New Roman">1(12</font></span><span style="font-family: 宋体;">个字节</span><span lang="EN-US"><font face="Times New Roman">)</font></span></font></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 426.1pt; background-color: transparent;" colspan="2" valign="top" width="568">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">项</span><span lang="EN-US"><font face="Times New Roman">2</font></span><span style="font-family: 宋体;">。。。。</span><span lang="EN-US"><font face="Times New Roman">(12</font></span><span style="font-family: 宋体;">个字节</span><span lang="EN-US"><font face="Times New Roman">)</font></span></font></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 426.1pt; background-color: transparent;" colspan="2" valign="top" width="568">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">下一个</span><span lang="EN-US"><font face="Times New Roman">IFD</font></span><span style="font-family: 宋体;">的开始地址（用于保存多个文件）</span></font></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">每个项的</span><span lang="EN-US"><font face="Times New Roman">12</font></span><span style="font-family: 宋体;">个字节，其是连续的，有前两个字节说明其项的总数。对于不同的</span><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">格式文件，这里的不同。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US">
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
</span></p>
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
<h2 style="margin: 13pt 0cm 13pt 21pt;"><span lang="EN-US"><span><font size="3">3.</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 黑体;"><font size="3">目录项</font></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">每个目录项由</span><span lang="EN-US"><font face="Times New Roman">12</font></span><span style="font-family: 宋体;">个字节组成，格式如下：</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US">
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
</span></p>
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" cellpadding="0" cellspacing="0" border="1">
    <tbody>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 213pt; background-color: transparent;" valign="top" width="284">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">TAG(2</font></span><span style="font-family: 宋体;">个字节</span><span lang="EN-US"><font face="Times New Roman">)</font></span></font></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 213.1pt; background-color: transparent;" valign="top" width="284">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">TAG</font></span><span style="font-family: 宋体;">的数据类型</span></font></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 426.1pt; background-color: transparent;" colspan="2" valign="top" width="568">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: 宋体;"><font size="3">数据长度</font></span></p>
            </td>
        </tr>
        <tr>
            <td style="padding: 0cm 5.4pt; width: 426.1pt; background-color: transparent;" colspan="2" valign="top" width="568">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: 宋体;"><font size="3">数据值或值的偏移（文件范围）</font></span></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">TAG</font></span><span style="font-family: 宋体;">的值由</span><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">标准定义；不同的</span><span lang="EN-US"><font face="Times New Roman">TAG</font></span><span style="font-family: 宋体;">表示不同的意思，例如</span><span lang="EN-US"><font face="Times New Roman">0X0100</font></span><span style="font-family: 宋体;">表示图像的宽度。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span lang="EN-US"><font face="Times New Roman">TAG</font></span><span style="font-family: 宋体;">的数据类型表示数据值的类型；例如使用</span><span lang="EN-US"><font face="Times New Roman">long</font></span><span style="font-family: 宋体;">类型来表示宽度。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">数据长度是以数据类型为单位的，真正的数据长度是：数据长度</span><span lang="EN-US"><font face="Times New Roman">*sizeof(</font></span><span style="font-family: 宋体;">数据类型</span><span lang="EN-US"><font face="Times New Roman">)</font></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">数据值或值的偏移：如果数据长度小于</span><span lang="EN-US"><font face="Times New Roman">4</font></span><span style="font-family: 宋体;">个字节，一般直接以该字段来表示其值，如果其值大于</span><span lang="EN-US"><font face="Times New Roman">4</font></span><span style="font-family: 宋体;">个字节，就指定一个文件范围的偏移地址，从那里开始的&#8220;数据长度</span><span lang="EN-US"><font face="Times New Roman">*sizeof(</font></span><span style="font-family: 宋体;">数据类型</span><span lang="EN-US"><font face="Times New Roman">)</font></span><span style="font-family: 宋体;">&#8221;个字节表示该标志的值。</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US">
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
</span></p>
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
<h2 style="margin: 13pt 0cm 13pt 21pt;"><span lang="EN-US"><span><font size="3">4.</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 黑体;"><font size="3">图像数据：</font></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: 宋体;"><font size="3">紧接上面数据之后就是图像数据了；图像数据的存储形式有不同的形式，有以像素位来存储的，也有以颜色面来存储的；具体的存储方式在目录项中定义。</font></span></p>
<h1 style="margin: 17pt 0cm 16.5pt 21pt;"><span lang="EN-US"><span><font face="Times New Roman"><font size="3">四、</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><font size="3"><span style="font-family: 宋体;">一些</span><span lang="EN-US"><font face="Times New Roman">TAG</font></span><span style="font-family: 宋体;">值</span></font></h1>
<table class="MsoNormalTable" style="border: medium none ; margin: auto auto auto 4.65pt; width: 414.75pt; border-collapse: collapse;" cellpadding="0" cellspacing="0" width="553" border="0">
    <tbody>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; background: #ffcc99 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 106pt; height: 12pt;" colspan="2" nowrap="65535" width="141">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">TAG</span><span style="font-size: 10pt; font-family: 宋体;">值</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; background: #ffcc99 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 308.75pt; height: 12pt;" rowspan="2" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">说明</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; background: #ffcc99 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 59pt; height: 12pt;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">十进制</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; background: #ffcc99 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 47pt; height: 12pt;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">16</span><span style="font-size: 10pt; font-family: 宋体;">进制</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">256</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">100</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">图像宽度</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">257</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">101</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">图像高度</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">258</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">102</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">BitsPerSample,</span><span style="font-size: 10pt; font-family: 宋体;">对于<span lang="EN-US">RGB</span>是<span lang="EN-US">8</span>，<span lang="EN-US">8</span>，<span lang="EN-US">8</span>，通过偏移来表示</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">259</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">103</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">压缩方式<span lang="EN-US">(1/2/32773),1</span>为不压缩</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">262</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">106</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">光度滴定<span lang="EN-US">,</span>对于<span lang="EN-US">RGB</span>图，该值是<span lang="EN-US">2</span></span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">273</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">111</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">带的偏移，每个带是不同的</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">277</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">115</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">每像素的颜色成分，对于<span lang="EN-US">RGB</span>这个值一般是<span lang="EN-US">3</span>，如果需要其他有<span lang="EN-US">ExtraSamples</span>标志</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">278</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">116</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">每带的行数</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">279</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">117</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">每带中压缩之后的数据字节常长度</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">284</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="11" unitname="C" w:st="on"></chmetcnv><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">11C</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;">每个分量（<span lang="EN-US">R</span>，<span lang="EN-US">G</span>，<span lang="EN-US">B</span>）是怎么存储的<span lang="EN-US">,1</span>表示按照<span lang="EN-US">RGBRGB</span>的顺序来存储</span></p>
            </td>
        </tr>
        <tr style="height: 12pt;">
            <td style="padding: 0cm 5.4pt; width: 59pt; height: 12pt; background-color: transparent;" nowrap="65535" width="79">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">296</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 47pt; height: 12pt; background-color: transparent;" nowrap="65535" width="63">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">128</span></p>
            </td>
            <td style="padding: 0cm 5.4pt; width: 308.75pt; height: 12pt; background-color: transparent;" nowrap="65535" width="412">
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: right;" align="right"><span style="font-size: 10pt; font-family: 宋体;" lang="EN-US">Xresolution</span><span style="font-size: 10pt; font-family: 宋体;">和<span lang="EN-US">Yresolution</span>的单位</span></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font size="3"><span style="font-family: 宋体;">更多的参考</span><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">标准</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US">
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
</span></p>
<p><font size="3" face="Times New Roman">&nbsp;</font></p>
<h1 style="margin: 17pt 0cm 16.5pt 21pt;"><span lang="EN-US"><span><font face="Times New Roman"><font size="3">五、</font><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></span></span><font size="3"><span style="font-family: 宋体;">一个</span><span lang="EN-US"><font face="Times New Roman">TIFF</font></span><span style="font-family: 宋体;">文件格式分析</span></font></h1>
<h1 style="margin: 17pt 0cm 16.5pt 21pt;"><font size="3"><span style="font-family: 宋体;"><img alt="" src="http://blog.csdn.net/images/blog_csdn_net/windcsn/tiffile.jpg" /></span></font></h1>
<br />
<br />
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/325861.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-07-12 13:29 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325861.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>编译基于Qt的webkit</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325857.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 12 Jul 2010 05:11:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325857.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/325857.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325857.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/325857.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/325857.html</trackback:ping><description><![CDATA[http://www.linuxeden.com/html/softuse/20100120/70195.html<br />
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/325857.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-07-12 13:11 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325857.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Webkit内核的浏览器默认CSS属性</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325855.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 12 Jul 2010 05:06:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325855.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/325855.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325855.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/325855.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/325855.html</trackback:ping><description><![CDATA[<pre>/*<br />
* The default style sheet used to render HTML.<br />
*<br />
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)<br />
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.<br />
*<br />
* This library is free software; you can redistribute it and/or<br />
* modify it under the terms of the GNU Library General Public<br />
* License as published by the Free Software Foundation; either<br />
* version 2 of the License, or (at your option) any later version.<br />
*<br />
* This library is distributed in the hope that it will be useful,<br />
* but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br />
* Library General Public License for more details.<br />
*<br />
* You should have received a copy of the GNU Library General Public License<br />
* along with this library; see the file COPYING.LIB.  If not, write to<br />
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,<br />
* Boston, MA 02110-1301, USA.<br />
*<br />
*/<br />
<br />
@namespace "http://www.w3.org/1999/xhtml";<br />
<br />
html {<br />
display: block<br />
}<br />
<br />
/* children of the &lt;head&gt; element all have display:none */<br />
head {<br />
display: none<br />
}<br />
<br />
meta {<br />
display: none<br />
}<br />
<br />
title {<br />
display: none<br />
}<br />
<br />
link {<br />
display: none<br />
}<br />
<br />
style {<br />
display: none<br />
}<br />
<br />
script {<br />
display: none<br />
}<br />
<br />
/* generic block-level elements */<br />
<br />
body {<br />
display: block;<br />
margin: 8px<br />
}<br />
<br />
p {<br />
display: block;<br />
margin: 1.0__qem 0px<br />
}<br />
<br />
div {<br />
display: block<br />
}<br />
<br />
layer {<br />
display: block<br />
}<br />
<br />
article, aside, footer, header, nav, section {<br />
display: block<br />
}<br />
<br />
marquee {<br />
display: inline-block;<br />
overflow: -webkit-marquee<br />
}<br />
<br />
address {<br />
display: block<br />
}<br />
<br />
blockquote {<br />
display: block;<br />
margin: 1__qem 40px 1em 40px<br />
}<br />
<br />
q {<br />
display: inline<br />
}<br />
<br />
q:before {<br />
content: '"'<br />
/* FIXME: content: open-quote; */<br />
}<br />
<br />
q:after {<br />
content: '"'<br />
/* FIXME: content: close-quote; */<br />
}<br />
<br />
center {<br />
display: block;<br />
/* special centering to be able to emulate the html4/netscape behaviour */<br />
text-align: -webkit-center<br />
}<br />
<br />
hr {<br />
display: block;<br />
margin: 0.5em auto;<br />
border-style: inset;<br />
border-width: 1px<br />
}<br />
<br />
map {<br />
display: inline<br />
}<br />
<br />
/* heading elements */<br />
<br />
h1 {<br />
display: block;<br />
font-size: 2em;<br />
margin: .67__qem 0 .67em 0;<br />
font-weight: bold<br />
}<br />
<br />
h2 {<br />
display: block;<br />
font-size: 1.5em;<br />
margin: .83__qem 0 .83em 0;<br />
font-weight: bold<br />
}<br />
<br />
h3 {<br />
display: block;<br />
font-size: 1.17em;<br />
margin: 1__qem 0 1em 0;<br />
font-weight: bold<br />
}<br />
<br />
h4 {<br />
display: block;<br />
margin: 1.33__qem 0 1.33em 0;<br />
font-weight: bold<br />
}<br />
<br />
h5 {<br />
display: block;<br />
font-size: .83em;<br />
margin: 1.67__qem 0 1.67em 0;<br />
font-weight: bold<br />
}<br />
<br />
h6 {<br />
display: block;<br />
font-size: .67em;<br />
margin: 2.33__qem 0 2.33em 0;<br />
font-weight: bold<br />
}<br />
<br />
/* tables */<br />
<br />
table {<br />
display: table;<br />
border-collapse: separate;<br />
border-spacing: 2px;<br />
border-color: gray<br />
}<br />
<br />
thead {<br />
display: table-header-group;<br />
vertical-align: middle;<br />
border-color: inherit<br />
}<br />
<br />
tbody {<br />
display: table-row-group;<br />
vertical-align: middle;<br />
border-color: inherit<br />
}<br />
<br />
tfoot {<br />
display: table-footer-group;<br />
vertical-align: middle;<br />
border-color: inherit<br />
}<br />
<br />
/* for tables without table section elements (can happen with XHTML or dynamically created tables) */<br />
table &gt; tr {<br />
vertical-align: middle;<br />
}<br />
<br />
col {<br />
display: table-column<br />
}<br />
<br />
colgroup {<br />
display: table-column-group<br />
}<br />
<br />
tr {<br />
display: table-row;<br />
vertical-align: inherit;<br />
border-color: inherit<br />
}<br />
<br />
td, th {<br />
display: table-cell;<br />
vertical-align: inherit<br />
}<br />
<br />
th {<br />
font-weight: bold<br />
}<br />
<br />
caption {<br />
display: table-caption;<br />
text-align: -webkit-center<br />
}<br />
<br />
/* lists */<br />
<br />
ul, menu, dir {<br />
display: block;<br />
list-style-type: disc;<br />
margin: 1__qem 0 1em 0;<br />
-webkit-padding-start: 40px<br />
}<br />
<br />
ol {<br />
display: block;<br />
list-style-type: decimal;<br />
margin: 1__qem 0 1em 0;<br />
-webkit-padding-start: 40px<br />
}<br />
<br />
li {<br />
display: list-item<br />
}<br />
<br />
ul ul, ol ul {<br />
list-style-type: circle<br />
}<br />
<br />
ol ol ul, ol ul ul, ul ol ul, ul ul ul {<br />
list-style-type: square<br />
}<br />
<br />
dd {<br />
display: block;<br />
-webkit-margin-start: 40px<br />
}<br />
<br />
dl {<br />
display: block;<br />
margin: 1__qem 0 1em 0<br />
}<br />
<br />
dt {<br />
display: block<br />
}<br />
<br />
ol ul, ul ol, ul ul, ol ol {<br />
margin-top: 0;<br />
margin-bottom: 0<br />
}<br />
<br />
/* form elements */<br />
<br />
form {<br />
display: block;<br />
margin-top: 0__qem<br />
}<br />
<br />
label {<br />
cursor: default;<br />
}<br />
<br />
legend {<br />
display: block;<br />
padding-left: 2px;<br />
padding-right: 2px;<br />
border: none<br />
}<br />
<br />
fieldset {<br />
display: block;<br />
margin-left: 2px;<br />
margin-right: 2px;<br />
padding: 0.35em 0.75em 0.625em;<br />
border: 2px groove ThreeDFace<br />
}<br />
<br />
button {<br />
-webkit-appearance: button;<br />
}<br />
<br />
input, textarea, keygen, select, button, isindex, datagrid {<br />
margin: 0__qem;<br />
font: -webkit-small-control;<br />
color: initial;<br />
letter-spacing: normal;<br />
word-spacing: normal;<br />
line-height: normal;<br />
text-transform: none;<br />
text-indent: 0;<br />
text-shadow: none;<br />
display: inline-block;<br />
text-align: -webkit-auto;<br />
}<br />
<br />
input[type="hidden"] {<br />
display: none<br />
}<br />
<br />
input, input[type="password"], input[type="search"], isindex {<br />
-webkit-appearance: textfield;<br />
padding: 1px;<br />
background-color: white;<br />
border: 2px inset;<br />
-webkit-rtl-ordering: logical;<br />
-webkit-user-select: text;<br />
cursor: auto;<br />
}<br />
<br />
input[type="search"] {<br />
-webkit-appearance: searchfield;<br />
-webkit-box-sizing: border-box;<br />
}<br />
<br />
input[type="search"]::-webkit-search-cancel-button {<br />
-webkit-appearance: searchfield-cancel-button;<br />
display: inline-block;<br />
}<br />
<br />
input[type="search"]::-webkit-search-decoration {<br />
-webkit-appearance: searchfield-decoration;<br />
display: inline-block;<br />
}<br />
<br />
input[type="search"]::-webkit-search-results-decoration {<br />
-webkit-appearance: searchfield-results-decoration;<br />
display: inline-block;<br />
}<br />
<br />
input[type="search"]::-webkit-search-results-button {<br />
-webkit-appearance: searchfield-results-button;<br />
display: inline-block;<br />
}<br />
<br />
input::-webkit-input-list-button {<br />
-webkit-appearance: list-button;<br />
display: inline-block;<br />
}<br />
<br />
input::-webkit-inner-spin-button {<br />
-webkit-appearance: inner-spin-button;<br />
display: inline-block;<br />
}<br />
<br />
input::-webkit-outer-spin-button {<br />
-webkit-appearance: outer-spin-button;<br />
display: inline-block;<br />
margin-left: 2px;<br />
}<br />
<br />
textarea {<br />
-webkit-appearance: textarea;<br />
background-color: white;<br />
border: 1px solid;<br />
-webkit-rtl-ordering: logical;<br />
-webkit-user-select: text;<br />
-webkit-box-orient: vertical;<br />
resize: auto;<br />
cursor: auto;<br />
padding: 2px;<br />
white-space: pre-wrap;<br />
word-wrap: break-word;<br />
}<br />
<br />
input::-webkit-input-placeholder, isindex::-webkit-input-placeholder, textarea::-webkit-input-placeholder {<br />
color: darkGray;<br />
}<br />
<br />
input[type="password"] {<br />
-webkit-text-security: disc !important;<br />
}<br />
<br />
input[type="hidden"], input[type="image"], input[type="file"] {<br />
-webkit-appearance: initial;<br />
padding: initial;<br />
background-color: initial;<br />
border: initial;<br />
}<br />
<br />
input[type="file"] {<br />
-webkit-box-align: baseline;<br />
text-align: start !important;<br />
}<br />
<br />
input:-webkit-autofill {<br />
background-color: #FAFFBD !important;<br />
background-image:none !important;<br />
}<br />
<br />
input[type="radio"], input[type="checkbox"] {<br />
margin: 3px 0.5ex;<br />
padding: initial;<br />
background-color: initial;<br />
border: initial;<br />
}<br />
<br />
input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button {<br />
-webkit-appearance: push-button;<br />
white-space: pre<br />
}<br />
<br />
input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button, button {<br />
-webkit-box-align: center;<br />
text-align: center;<br />
cursor: default;<br />
color: ButtonText;<br />
padding: 2px 6px 3px 6px;<br />
border: 2px outset ButtonFace;<br />
background-color: ButtonFace;<br />
-webkit-box-sizing: border-box<br />
}<br />
<br />
input[type="range"] {<br />
-webkit-appearance: slider-horizontal;<br />
padding: initial;<br />
border: initial;<br />
margin: 2px;<br />
}<br />
<br />
input[type="range"]::-webkit-slider-thumb {<br />
-webkit-appearance: sliderthumb-horizontal;<br />
}<br />
<br />
input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled,<br />
input[type="file"]:disabled::-webkit-file-upload-button, button:disabled,<br />
select:disabled, keygen:disabled, optgroup:disabled, option:disabled, datagrid:disabled {<br />
color: GrayText<br />
}<br />
<br />
input[type="button"]:active, input[type="submit"]:active, input[type="reset"]:active, input[type="file"]:active::-webkit-file-upload-button, button:active {<br />
border-style: inset<br />
}<br />
<br />
input[type="button"]:active:disabled, input[type="submit"]:active:disabled, input[type="reset"]:active:disabled, input[type="file"]:active:disabled::-webkit-file-upload-button, button:active:disabled {<br />
border-style: outset<br />
}<br />
<br />
area, param {<br />
display: none<br />
}<br />
<br />
input[type="checkbox"] {<br />
-webkit-appearance: checkbox;<br />
-webkit-box-sizing: border-box;<br />
}<br />
<br />
input[type="radio"] {<br />
-webkit-appearance: radio;<br />
-webkit-box-sizing: border-box;<br />
}<br />
<br />
keygen, select {<br />
-webkit-appearance: menulist;<br />
-webkit-box-sizing: border-box;<br />
-webkit-box-align: center;<br />
border: 1px solid;<br />
-webkit-border-radius: 5px;<br />
white-space: pre;<br />
-webkit-rtl-ordering: logical;<br />
color: black;<br />
background-color: white;<br />
cursor: default;<br />
}<br />
<br />
select[size],<br />
select[multiple],<br />
select[size][multiple] {<br />
-webkit-appearance: listbox;<br />
-webkit-box-align: start;<br />
border: 1px inset gray;<br />
-webkit-border-radius: initial;<br />
white-space: initial;<br />
}<br />
<br />
select[size="0"],<br />
select[size="1"] {<br />
-webkit-appearance: menulist;<br />
-webkit-box-align: center;<br />
border: 1px solid;<br />
-webkit-border-radius: 5px;<br />
white-space: pre;<br />
}<br />
<br />
datalist {<br />
display: none;<br />
}<br />
<br />
optgroup {<br />
font-weight: bolder;<br />
}<br />
<br />
option {<br />
font-weight: normal;<br />
}<br />
<br />
/* datagrid */<br />
<br />
datagrid {<br />
height: 150px; /* We don't use width:300px in CSS, since we want width:intrinsic and width:min-intrinsic to reset to 300 properly. */<br />
-webkit-appearance: datagrid;<br />
-webkit-box-sizing: border-box;<br />
-webkit-rtl-ordering: logical;<br />
color: black;<br />
background-color: white;<br />
cursor: default;<br />
border: 1px inset gray;<br />
white-space: initial;<br />
}<br />
<br />
/* inline elements */<br />
<br />
u, ins {<br />
text-decoration: underline<br />
}<br />
<br />
strong, b {<br />
font-weight: bolder<br />
}<br />
<br />
i, cite, em, var, address {<br />
font-style: italic<br />
}<br />
<br />
tt, code, kbd, samp {<br />
font-family: monospace<br />
}<br />
<br />
pre, xmp, plaintext, listing {<br />
display: block;<br />
font-family: monospace;<br />
white-space: pre;<br />
margin: 1__qem 0<br />
}<br />
<br />
big {<br />
font-size: larger<br />
}<br />
<br />
small {<br />
font-size: smaller<br />
}<br />
<br />
s, strike, del {<br />
text-decoration: line-through<br />
}<br />
<br />
sub {<br />
vertical-align: sub;<br />
font-size: smaller<br />
}<br />
<br />
sup {<br />
vertical-align: super;<br />
font-size: smaller<br />
}<br />
<br />
nobr {<br />
white-space: nowrap<br />
}<br />
<br />
/* states */<br />
<br />
:focus { <br />
outline: auto 5px -webkit-focus-ring-color<br />
}<br />
<br />
/* Read-only text fields do not show a focus ring but do still receive focus */<br />
html:focus, body:focus, input[readonly]:focus { <br />
outline: none<br />
}<br />
<br />
input:focus, textarea:focus, isindex:focus, keygen:focus, select:focus {<br />
outline-offset: -2px<br />
}<br />
<br />
input[type="button"]:focus,<br />
input[type="checkbox"]:focus,<br />
input[type="file"]:focus,<br />
input[type="hidden"]:focus,<br />
input[type="image"]:focus,<br />
input[type="radio"]:focus,<br />
input[type="reset"]:focus,<br />
input[type="search"]:focus,<br />
input[type="submit"]:focus,<br />
input[type="file"]:focus::-webkit-file-upload-button {<br />
outline-offset: 0<br />
}<br />
<br />
a:-webkit-any-link {<br />
color: -webkit-link;<br />
text-decoration: underline;<br />
cursor: auto;<br />
}<br />
<br />
a:-webkit-any-link:active {<br />
color: -webkit-activelink<br />
}<br />
<br />
/* HTML5 ruby elements */<br />
<br />
ruby, rt {<br />
text-indent: 0; /* blocks used for ruby rendering should not trigger this */<br />
line-height: normal;<br />
}<br />
<br />
ruby &gt; rt {<br />
display: block;<br />
font-size: 60%; /* make slightly larger than 50% for better readability */<br />
text-align: center;<br />
}<br />
<br />
ruby &gt; rp {<br />
display: none;<br />
}<br />
<br />
/* other elements */<br />
<br />
noframes {<br />
display: none<br />
}<br />
<br />
frameset, frame {<br />
display: block<br />
}<br />
<br />
frameset {<br />
border-color: inherit<br />
}<br />
<br />
iframe {<br />
border: 2px inset<br />
}<br />
<br />
/* noscript is handled internally, as it depends on settings */<br />
</pre>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/325855.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-07-12 13:06 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/07/12/325855.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>dlopen加载一个动态库=&gt;file not found的错的查错过程</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325487.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Wed, 07 Jul 2010 10:47:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325487.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/325487.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325487.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/325487.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/325487.html</trackback:ping><description><![CDATA[<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">转载于：http://hi.baidu.com/li_dayao/blog/item/ad6cddcb9d25641bbf09e66b.html　</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">　在</font><font face="Times New Roman, serif">arm-linux</font><font face="Times New Roman, serif">环境下运行可执行程序</font><font face="Times New Roman, serif">mocp</font><font face="Times New Roman, serif">，在加载动态库</font><font face="Times New Roman, serif">libdecoder.so</font><font face="Times New Roman, serif">时，却总是报错：</font><font face="Times New Roman, serif">File not found</font><font face="Times New Roman, serif">。在代码中添加很多</font><font face="Times New Roman, serif">printf</font><font face="Times New Roman, serif">，找到是在</font><font face="Times New Roman, serif">dlopen</font><font face="Times New Roman, serif">时报错。最初以为，是函数</font><font face="Times New Roman, serif">dlopen</font><font face="Times New Roman, serif">找不到</font><font face="Times New Roman, serif">lib_decoder.so</font><font face="Times New Roman, serif">文件。那么就认为有以下几种可能：</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">１，动态库给的搜索路径不对；</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">２，编译生成动态库的编译工具和程序的运行环境不同；</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">３，交叉编译环境不能识别</font><font face="Times New Roman, serif">dlopen</font><font face="Times New Roman, serif">（当然这个可能性是瞎猜的）。</font></p>
<p style="margin-bottom: 0cm;"> </p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">　　于是写了个测试程序并交叉编译，自己创建一个动态库</font><font face="Times New Roman, serif">libabc.so</font><font face="Times New Roman, serif">，并用</font><font face="Times New Roman, serif">dlopen</font><font face="Times New Roman, serif">加载它。</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">１，更改动态库的存放路径，结果是在任何路径下都可以找到；</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">２，用这个正确的测试程序加载</font><font face="Times New Roman, serif">libdecoder.so</font><font face="Times New Roman, serif">，结果是不管什么路径，就是找不到；</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">３，在</font><font face="Times New Roman, serif">mocp</font><font face="Times New Roman, serif">运行时加载</font><font face="Times New Roman, serif">libabd.so</font><font face="Times New Roman, serif">，能找到；</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">结论：只要给了</font><font face="Times New Roman, serif">dlopen</font><font face="Times New Roman, serif">函数一个路径，它就能到这个路径下去寻找指定的库；都是用</font><font face="Times New Roman, serif">arm-linux-uclibc-</font><font face="Times New Roman, serif">编译的，编译环境相同。那么就是</font><font face="Times New Roman, serif">libdecoder.so</font><font face="Times New Roman, serif">这个库本身的问题。</font></p>
<p style="margin-bottom: 0cm;"> </p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">　　于是将命令从</font><font face="Times New Roman, serif">Makefile</font><font face="Times New Roman, serif">中抽出来，在</font><font face="Times New Roman, serif">shell</font><font face="Times New Roman, serif">中单独运行命令生成这个库，结果还是找不到。然后把命令简化，去掉各种选项，比如链接选项，仅仅用</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">  arm-linux-uclibc-gcc -fpic -shared snow.c rain.c -o libdecoder.so</font></p>
<p style="margin-bottom: 0cm;"><font face="Times New Roman, serif">生成库后，测试发现能找到了。添加一个链接选项</font><font face="Times New Roman, serif">-ldl</font><font face="Times New Roman, serif">，又找不到了。</font></p>
<p style="margin-bottom: 0cm;"> </p>
<p style="margin-bottom: 0cm;" align="left"><font face="Times New Roman, serif">　　这才想到，</font><font face="Times New Roman, serif">libdecoder.so</font><font face="Times New Roman, serif">还要加载一个动态库</font><font face="Times New Roman, serif">libdl.so</font><font face="Times New Roman, serif">，</font><font face="Times New Roman, serif">file not found</font><font face="Times New Roman, serif">是不是指的是这个库找不到啊？查找运行环境下的</font><font face="Times New Roman, serif">/lib</font><font face="Times New Roman, serif">发现，果然没有</font><font face="Times New Roman, serif">libdl.so</font><font face="Times New Roman, serif">文件。把这个库拷进来，</font><font face="Times New Roman, serif">mocp</font><font face="Times New Roman, serif">在</font><font face="Times New Roman, serif">dlopen</font><font face="Times New Roman, serif">的时候就通过了。</font><font face="Times New Roman, serif">Done</font><font face="Times New Roman, serif">！</font></p>
<p style="margin-bottom: 0cm;" align="left"> </p>
<p style="margin-bottom: 0cm;" align="left"><font face="Times New Roman, serif">　　其实，如果我在运行程序之前就检查好这个程序究竟需要那些动态库，也就不至于花了这么大力气查找这个问题。</font></p>
<p style="margin-bottom: 0cm;" align="left"> </p>
<p style="margin-bottom: 0cm;" align="left"><font face="Times New Roman, serif">　　用</font><font face="Times New Roman, serif">objdump</font><font face="Times New Roman, serif">命令就可以查看目标文件包含的信息，其中就有程序需要链接的动态库。</font></p>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/325487.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-07-07 18:47 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325487.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>dlopen</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325446.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Wed, 07 Jul 2010 06:39:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325446.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/325446.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325446.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/325446.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/325446.html</trackback:ping><description><![CDATA[<div id="art" style="margin: 15px;">
<div>
<h4>NAME</h4>
<blockquote><strong style="color: black; background-color: #ffff66;">dlopen</strong> - gain access to an executable object file </blockquote>
<h4><a name="tag_000_003_143">&nbsp;</a>SYNOPSIS</h4>
<blockquote>
<pre><code><br />
<br />
#include &lt;<a href="http://opengroup.org/onlinepubs/007908775/xsh/dlfcn.h.html"><font color="#0000ff">dlfcn.h</font></a>&gt;<br />
<br />
void *<strong style="color: black; background-color: #ffff66;">dlopen</strong>(const char *<em>file</em>, int <em>mode</em>);<br />
</code><br />
</pre>
</blockquote>
<h4><a name="tag_000_003_144">&nbsp;</a>DESCRIPTION</h4>
<blockquote><em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> makes an executable object file specified by <em>file</em>
available to the calling program. The class of files eligible for this
operation and the manner of their construction are specified by the
implementation, though typically such files are executable objects such
as shared libraries, relocatable files or programs. Note that some
implementations permit the construction of dependencies between such
objects that are embedded within files. In such cases, a <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> operation will load such dependencies in addition to the object referenced by <em>file</em>. Implementations may also impose specific constraints on the construction of programs that can employ <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> and its related services.
<p>A successful <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> returns a <em>handle</em> which the caller may use on subsequent calls to <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlsym.html"><font color="#0000ff">dlsym()</font></a></em> and <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlclose.html"><font color="#0000ff">dlclose()</font></a></em>. The value of this <em>handle</em> should not be interpreted in any way by the caller. </p>
<p><em>file</em> is used to construct a pathname to the object file. If <em>file</em> contains a slash character, the <em>file</em> argument is used as the pathname for the file. Otherwise, <em>file</em> is used in an implementation-dependent manner to yield a pathname. </p>
<p>If the value of <em>file</em> is 0, <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> provides a <em>handle</em>
on a global symbol object. This object provides access to the symbols
from an ordered set of objects consisting of the original program image
file, together with any objects loaded at program startup as specified
by that process image file (for example, shared libraries), and the set
of objects loaded using a <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> operation together with the RTLD_GLOBAL flag. As the latter set of objects can change during execution, the set identified by <em>handle</em> can also change dynamically. </p>
<p>Only a single copy of an object file is brought into the address space, even if <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> is invoked multiple times in reference to the file, and even if different pathnames are used to reference the file. </p>
<p>The <em>mode</em> parameter describes how <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> will operate upon <em>file</em> with respect to the processing of relocations and the scope of visibility of the symbols provided within <em>file</em>.
When an object is brought into the address space of a process, it may
contain references to symbols whose addresses are not known until the
object is loaded. These references must be relocated before the symbols
can be accessed. The <em>mode</em> parameter governs when these relocations take place and may have the following values: </p>
<dl compact="compact"><dt>RTLD_LAZY</dt><dd>Relocations are performed at an implementation-dependent time, ranging from the time of the <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em>
call until the first reference to a given symbol occurs. Specifying
RTLD_LAZY should improve performance on implementations supporting
dynamic symbol binding as a process may not reference all of the
functions in any given object. And, for systems supporting dynamic
symbol resolution for normal process execution, this behaviour mimics
the normal handling of process execution. </dd><dt>RTLD_NOW</dt><dd>All necessary relocations are performed when the object is first
loaded. This may waste some processing if relocations are performed for
functions that are never referenced. This behaviour may be useful for
applications that need to know as soon as an object is loaded that all
symbols referenced during execution will be available. </dd></dl>
<p>Any object loaded by <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em>
that requires relocations against global symbols can reference the
symbols in the original process image file, any objects loaded at
program startup, from the object itself as well as any other object
included in the same <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> invocation, and any objects that were loaded in any <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> invocation and which specified the RTLD_GLOBAL flag. To determine the scope of visibility for the symbols loaded with a <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> invocation, the <em>mode</em> parameter should be bitwise or'ed with one of the following values: </p>
<dl compact="compact"><dt>RTLD_GLOBAL</dt><dd>The object's symbols are made available for the relocation processing of any other object. In addition, symbol lookup using <em><strong style="color: black; background-color: #ffff66;">dlopen</strong></em>(<em>0, mode</em>) and an associated <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlsym.html"><font color="#0000ff">dlsym()</font></a></em> allows objects loaded with this <em>mode</em> to be searched. </dd><dt>RTLD_LOCAL</dt><dd>The object's symbols are not made available for the relocation processing of any other object. </dd></dl>
<p>If neither RTLD_GLOBAL nor RTLD_LOCAL are specified, then an implementation-specified default behaviour will be applied. </p>
<p>If a <em>file</em> is specified in multiple <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> invocations, <em>mode</em>
is interpreted at each invocation. Note, however, that once RTLD_NOW
has been specified all relocations will have been completed rendering
further RTLD_NOW operations redundant and any further RTLD_LAZY
operations irrelevant. Similarly note that once RTLD_GLOBAL has been
specified the object will maintain the RTLD_GLOBAL status regardless of
any previous or future specification of RTLD_LOCAL, so long as the
object remains in the address space (see <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlclose.html"><font color="#0000ff">dlclose()</font></a></em>). </p>
<p>Symbols introduced into a program through calls to <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> may be used in relocation activities. Symbols so introduced may duplicate symbols already defined by the program or previous <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em>
operations. To resolve the ambiguities such a situation might present,
the resolution of a symbol reference to symbol definition is based on a
symbol resolution order. Two such resolution orders are defined: <em>load</em> or <em>dependency</em> ordering. <em>Load</em>
order establishes an ordering among symbol definitions, such that the
definition first loaded (including definitions from the image file and
any dependent objects loaded with it) has priority over objects added
later (via <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em>). <em>Load</em> ordering is used in relocation processing. <em>Dependency</em>
ordering uses a breadth-first order starting with a given object, then
all of its dependencies, then any dependents of those, iterating until
all dependencies are satisfied. With the exception of the global symbol
object obtained via a <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> operation on a <em>file</em> of 0, <em>dependency</em> ordering is used by the <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlsym.html"><font color="#0000ff">dlsym()</font></a></em> function. <em>Load</em> ordering is used in <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlsym.html"><font color="#0000ff">dlsym()</font></a></em> operations upon the global symbol object. </p>
<p>When an object is first made accessible via <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> it and its dependent objects are added in <em>dependency</em> order. Once all the objects are added, relocations are performed using <em>load</em> order. Note that if an object or its dependencies had been previously loaded, the <em>load</em> and <em>dependency</em> orders may yield different resolutions. </p>
<p>The symbols introduced by <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> operations, and available through <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlsym.html"><font color="#0000ff">dlsym()</font></a></em>
are at a minimum those which are exported as symbols of global scope by
the object. Typically such symbols will be those that were specified in
(for example) C source code as having <em>extern</em> linkage. The precise manner in which an implementation constructs the set of exported symbols for a <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> object is specified by that implementation. </p>
</blockquote>
<h4><a name="tag_000_003_145">&nbsp;</a>RETURN VALUE</h4>
<blockquote>If <em>file</em> cannot be found, cannot be opened for reading, is not of an appropriate object format for processing by <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em>, or if an error occurs during the process of loading <em>file</em> or relocating its symbolic references, <em><strong style="color: black; background-color: #ffff66;">dlopen</strong>()</em> will return NULL. More detailed diagnostic information will be available through <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlerror.html"><font color="#0000ff">dlerror()</font></a></em>. </blockquote>
<h4><a name="tag_000_003_146">&nbsp;</a>ERRORS</h4>
<blockquote>No errors are defined. </blockquote>
<h4><a name="tag_000_003_147">&nbsp;</a>EXAMPLES</h4>
<blockquote>None. </blockquote>
<h4><a name="tag_000_003_148">&nbsp;</a>APPLICATION USAGE</h4>
<blockquote>None. </blockquote>
<h4><a name="tag_000_003_149">&nbsp;</a>FUTURE DIRECTIONS</h4>
<blockquote>None. </blockquote>
<h4><a name="tag_000_003_150">&nbsp;</a>SEE ALSO</h4>
<blockquote><em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlclose.html"><font color="#0000ff">dlclose()</font></a></em>, <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlerror.html"><font color="#0000ff">dlerror()</font></a></em>, <em><a href="http://opengroup.org/onlinepubs/007908775/xsh/dlsym.html"><font color="#0000ff">dlsym()</font></a></em>. </blockquote></div>
</div>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/325446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-07-07 14:39 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/07/07/325446.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android开机过程</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/06/25/324442.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Fri, 25 Jun 2010 07:03:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/06/25/324442.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/324442.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/06/25/324442.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/324442.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/324442.html</trackback:ping><description><![CDATA[<span id="ctl00_MainContentPlaceholder_ctl01_ctl00_lblEntry">
<p>Android 开机会出现3个画面：<br />
a. Linux 系统启动，出现Linux小企鹅画面(reboot)；<br />
b. Android平台启动初始化，出现"A N D R I O D"文字字样画面；<br />
c. Android平台图形系统启动，出现含闪动的ANDROID字样的动画图片(start)。  </p>
<p>1/ 开机图片(Linux小企鹅)  </p>
<p>Linux Kernel引导启动后，加载该图片。<br />
/kernel/trunk/drivers/video/fbmem.c<br />
/kernel/trunk/drivers/video/fbmem.h<br />
/kernel/trunk/drivers/video/logo/logo.c<br />
/kernel/trunk/drivers/video/logo/logo.h<br />
/kernel/trunk/drivers/video/logo/Kconfig<br />
/kernel/trunk/include/linux/linux_logo.h  </p>
<p>2/ 开机文字("A N D R I O D")  </p>
<p>Android
系统启动后，读取 /initlogo.rle（一张565
rle压缩的位图），如果读取成功，测在/dev/graphics/fb0显示Logo图片；如果读取失败，则将/dev/tty0设为TEXT模式，
并打开/dev/tty0，输出文本&#8220;A N D R I O D&#8221;字样。 </p>
<p>相关代码：  </p>
<p>/system/core/init/init.c<br />
/system/core/init/init.h<br />
/system/core/init/init.rc<br />
/system/core/init/logo.c  </p>
<p>*.rle文件的制作步骤:<br />
a. 使用GIMP或者Advanced Batch Converter软件，将图象转换为RAW格式；<br />
b. 使用android自带的rgb2565工具，将RAW格式文件转换为RLE格式(如：rgb2565 -rle &lt; initlogo.raw &gt; initlogo.rle)。  </p>
<p>3/ 开机动画(闪动的ANDROID字样的动画图片)  </p>
<p>Android
的系统登录动画类似于Windows系统的滚动条，是由前景和背景两张PNG图片组成，这两张图片存在于/system/framework
/framework-res.apk文件当中。前景图片（android-logo-mask.png）上的Android文字部分镂空，背景图片
（android-logo-shine.png）则是简单的纹理。系统登录时，前景图片在最上层显示，程序代码控制背景图片连续滚动，透过前景图片文字
镂空部分滚动显示背景纹理，从而实现动画效果。 </p>
<p>相关代码：<br />
/frameworks/base/libs/surfaceflinger/BootAnimation.h<br />
/frameworks/base/libs/surfaceflinger/BootAnimation.cpp  </p>
<p>/frameworks/base/core/res/assets/images/android-logo-mask.png<br />
Android默认的前景图片，文字部分镂空，大小256&#215;64<br />
/frameworks/base/core/res/assets/images/android-logo-shine.png<br />
Android默认的背景图片，有动感效果，大小512&#215;64  </p>
<p>参考文档：  </p>
<p>图说Android开机画面和开机动画<br />
<a href="http://www.shudoo.com/09/1030/15/13418431.html">http://www.shudoo.com/09/1030/15/13418431.html</a> </p>
<p>initlogo.rle: display an image on boot<br />
<a href="http://forum.xda-developers.com/showthread.php?t=443431">http://forum.xda-developers.com/showthread.php?t=443431</a> </p>
<p>分析Android 根文件系统启动过程（init守护进程分析）<br />
http://crazier9527.javaeye.com/blog/454635</p>
</span>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/324442.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-06-25 15:03 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/06/25/324442.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Lock Screen Orientation in Android</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324101.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 21 Jun 2010 15:46:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324101.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/324101.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324101.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/324101.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/324101.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="font-family: 'Trebuchet MS'; font-size: 11px; line-height: 16px; ">
<table class="Panel" cellspacing="2" cellpadding="2" border="0" style="text-align: left; vertical-align: top; width: 518px; ">
    <tbody>
        <tr>
            <td align="left">Martin Belcher</td>
            <td align="right">26th May 2010</td>
        </tr>
        <tr>
            <td colspan="2" style="width: 510px; ">
            <p style="text-align: left; vertical-align: top; color: #000000; font-family: 'Trebuchet MS'; font-size: 11px; text-decoration: none; "></p>
            <h2 style="font-size: 12px; ">Intro<img src="http://www.eigo.co.uk/images/Article/Android_ScreenRotation.JPG" alt="Android screen rotation image" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; float: right; " /></h2>
            <p style="text-align: left; vertical-align: top; color: #000000; font-family: 'Trebuchet MS'; font-size: 11px; text-decoration: none; ">This article describes how to force the orientation of an Android view not to change ie screen not to rotate.</p>
            <br />
            <h2 style="font-size: 12px; ">How to lock the orientation</h2>
            <p style="text-align: left; vertical-align: top; color: #000000; font-family: 'Trebuchet MS'; font-size: 11px; text-decoration: none; ">In the&nbsp;<a target="_new" href="http://developer.android.com/reference/android/app/Activity.html#onCreateDialog(int)" title="Android documentation on onCreateDialog event" style="font-weight: bold; color: #0385fc; font-family: 'Trebuchet MS'; text-decoration: none; ">onCreateDialog(int) event</a>&nbsp;of the activity use the&nbsp;<a target="_new" href="http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation(int)" title="Android documentation on setRequestedOrientation method" style="font-weight: bold; color: #0385fc; font-family: 'Trebuchet MS'; text-decoration: none; ">setRequestedOrientation(int) method</a>&nbsp;to set the screen orientation to your chosen setting. The activity will stay in this orientation regardless of if the device is tilted or not.</p>
            <div align="left">
            <table border="0" cellpadding="3" cellspacing="0" bgcolor="#E0E0E0">
                <tbody>
                    <tr>
                        <td style="background-color: #aaaaaa; font-weight: bold; color: #ffffff; ">[Code sample &#8211; How to lock the orientation]</td>
                    </tr>
                    <tr>
                        <td nowrap="nowrap" valign="top" align="left"><code><font color="#3f5fbf">/**&nbsp;Called&nbsp;when&nbsp;the&nbsp;activity&nbsp;is&nbsp;first&nbsp;created.&nbsp;*/</font><br />
                        <font color="#646464">@Override</font><br />
                        <font color="#7f0055"><strong>public&nbsp;</strong></font><font color="#7f0055"><strong>void&nbsp;</strong></font><font color="#000000">onCreate</font><font color="#000000">(</font><font color="#000000">Bundle&nbsp;savedInstanceState</font><font color="#000000">)&nbsp;</font><br />
                        <font color="#000000">{</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><strong>super</strong></font><font color="#000000">.onCreate</font><font color="#000000">(</font><font color="#000000">savedInstanceState</font><font color="#000000">)</font><font color="#000000">;</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">.setRequestedOrientation</font><font color="#000000">(</font><br />
                        <font color="#000000">ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE</font><font color="#000000">)</font><font color="#000000">;</font><br />
                        <font color="#000000">}</font></code></td>
                    </tr>
                </tbody>
            </table>
            </div>
            <br />
            <h2 style="font-size: 12px; ">How to detect the current orientation</h2>
            <p style="text-align: left; vertical-align: top; color: #000000; font-family: 'Trebuchet MS'; font-size: 11px; text-decoration: none; ">To programmatically detect the current orientation of the activity use the following code snippet. The<a target="_new" href="http://developer.android.com/reference/android/content/res/Configuration.html#orientation" title="Android documentation on orientation property" style="font-weight: bold; color: #0385fc; font-family: 'Trebuchet MS'; text-decoration: none; ">orientation property</a>&nbsp;of the&nbsp;<a target="_new" href="http://developer.android.com/reference/android/content/res/Configuration.html" title="Android documentation on Configuration class" style="font-weight: bold; color: #0385fc; font-family: 'Trebuchet MS'; text-decoration: none; ">Configuration class</a>&nbsp;returns three possible values corresponding to Landscape, Portrait and Square.</p>
            <div align="left">
            <table border="0" cellpadding="3" cellspacing="0" bgcolor="#E0E0E0">
                <tbody>
                    <tr>
                        <td style="background-color: #aaaaaa; font-weight: bold; color: #ffffff; ">[Code sample &#8211; How to detect the current orientation]</td>
                    </tr>
                    <tr>
                        <td nowrap="nowrap" valign="top" align="left"><code><font color="#7f0055"><strong>switch&nbsp;</strong></font><font color="#000000">(</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">.getResources</font><font color="#000000">()</font><font color="#000000">.getConfiguration</font><font color="#000000">()</font><font color="#000000">.orientation</font><font color="#000000">)</font><br />
                        <font color="#000000">{</font><br />
                        <font color="#7f0055"><strong>case&nbsp;</strong></font><font color="#000000">Configuration.ORIENTATION_PORTRAIT:</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;Do&nbsp;something&nbsp;here</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><strong>break</strong></font><font color="#000000">;</font><br />
                        <font color="#7f0055"><strong>case&nbsp;</strong></font><font color="#000000">Configuration.ORIENTATION_LANDSCAPE:</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;Do&nbsp;something&nbsp;here</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><strong>break</strong></font><font color="#000000">;</font><br />
                        <font color="#7f0055"><strong>case&nbsp;</strong></font><font color="#000000">Configuration.ORIENTATION_SQUARE:</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;Do&nbsp;something&nbsp;here</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><strong>break</strong></font><font color="#000000">;</font><br />
                        <font color="#7f0055"><strong>default</strong></font><font color="#000000">:</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><strong>throw&nbsp;new&nbsp;</strong></font><font color="#000000">Exception</font><font color="#000000">(</font><font color="#2a00ff">"Unexpected&nbsp;orientation&nbsp;enumeration&nbsp;returned"</font><font color="#000000">)</font><font color="#000000">;</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><strong>break</strong></font><font color="#000000">;</font><br />
                        <font color="#000000">}</font></code></td>
                    </tr>
                </tbody>
            </table>
            </div>
            <br />
            <h2 style="font-size: 12px; ">Example : Locking rotation while performing an action.</h2>
            <p style="text-align: left; vertical-align: top; color: #000000; font-family: 'Trebuchet MS'; font-size: 11px; text-decoration: none; ">You might wish to disable the screen rotation whilst performing an action or by user command, to do this you need to combine the above samples to detect the current orientation and lock the display to that orientation.</p>
            <div align="left">
            <table border="0" cellpadding="3" cellspacing="0" bgcolor="#E0E0E0">
                <tbody>
                    <tr>
                        <td style="background-color: #aaaaaa; font-weight: bold; color: #ffffff; ">[Code sample &#8211; Locking rotation while performing an action]</td>
                    </tr>
                    <tr>
                        <td nowrap="nowrap" valign="top" align="left"><code><font color="#3f7f5f">//&nbsp;Sets&nbsp;screen&nbsp;rotation&nbsp;as&nbsp;fixed&nbsp;to&nbsp;current&nbsp;rotation&nbsp;setting</font><br />
                        <font color="#7f0055"><strong>private&nbsp;</strong></font><font color="#7f0055"><strong>void&nbsp;</strong></font><font color="#000000">mLockScreenRotation</font><font color="#000000">()</font><br />
                        <font color="#000000">{</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;Stop&nbsp;the&nbsp;screen&nbsp;orientation&nbsp;changing&nbsp;during&nbsp;an&nbsp;event</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><strong>switch&nbsp;</strong></font><font color="#000000">(</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">.getResources</font><font color="#000000">()</font><font color="#000000">.getConfiguration</font><font color="#000000">()</font><font color="#000000">.orientation</font><font color="#000000">)</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">{</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><strong>case&nbsp;</strong></font><font color="#000000">Configuration.ORIENTATION_PORTRAIT:</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">.setRequestedOrientation</font><font color="#000000">(</font><br />
                        <font color="#000000">ActivityInfo.SCREEN_ORIENTATION_PORTRAIT</font><font color="#000000">)</font><font color="#000000">;</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><strong>break</strong></font><font color="#000000">;</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><strong>case&nbsp;</strong></font><font color="#000000">Configuration.ORIENTATION_LANDSCAPE:</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><strong>this</strong></font><font color="#000000">.setRequestedOrientation</font><font color="#000000">(</font><br />
                        <font color="#000000">ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE</font><font color="#000000">)</font><font color="#000000">;</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><strong>break</strong></font><font color="#000000">;</font><br />
                        <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
                        <font color="#000000">}</font></code></td>
                    </tr>
                </tbody>
            </table>
            </div>
            <p style="text-align: left; vertical-align: top; color: #000000; font-family: 'Trebuchet MS'; font-size: 11px; text-decoration: none; ">Once your action has completed you may wish to enable screen rotation again, see the next section for an example on how to do this.</p>
            <br />
            <h2 style="font-size: 12px; ">How to re-enable screen rotation</h2>
            <p style="text-align: left; vertical-align: top; color: #000000; font-family: 'Trebuchet MS'; font-size: 11px; text-decoration: none; ">To enable the orientation to be automatically changed on device tilt simply pass the<a target="_new" href="http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation(int)" title="Android documentation on setRequestedOrientation method" style="font-weight: bold; color: #0385fc; font-family: 'Trebuchet MS'; text-decoration: none; ">setRequestedOrientation(int) method</a>&nbsp;the enumeration value for an unspecified orientation.</p>
            <div align="left">
            <table border="0" cellpadding="3" cellspacing="0" bgcolor="#E0E0E0">
                <tbody>
                    <tr>
                        <td style="background-color: #aaaaaa; font-weight: bold; color: #ffffff; ">[Code sample &#8211; How to re-enable screen rotation]</td>
                    </tr>
                    <tr>
                        <td nowrap="nowrap" valign="top" align="left"><code><font color="#3f7f5f">//&nbsp;allow&nbsp;screen&nbsp;rotations&nbsp;again</font><br />
                        <font color="#7f0055"><strong>this</strong></font><font color="#000000">.setRequestedOrientation</font><font color="#000000">(</font><br />
                        <font color="#000000">ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED</font><font color="#000000">)</font><font color="#000000">;</font></code></td>
                    </tr>
                </tbody>
            </table>
            </div>
            </td>
        </tr>
    </tbody>
</table>
</span>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/324101.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-06-21 23:46 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324101.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android屏幕超时设置</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324092.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 21 Jun 2010 13:33:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324092.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/324092.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324092.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/324092.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/324092.html</trackback:ping><description><![CDATA[<div>int t = Settings.System.getInt(this.getContentResolver(),Settings.System.SCREEN_OFF_TIMEOUT);</div>
<div>Settings.System.putInt(this.getContentResolver(),Settings.System.SCREEN_OFF_TIMEOUT, &lt;span style="color: #ff0000;"&gt;60000&lt;/span&gt;);</div>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/324092.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-06-21 21:33 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324092.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android手机的充电情况监视</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324090.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 21 Jun 2010 13:28:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324090.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/324090.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324090.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/324090.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/324090.html</trackback:ping><description><![CDATA[<div>当手机电量有变化，或者有充电情况的时候，android会自动的发送一个广播，要监视充电情况，只需截获这个广播就ok啦！</div>
<div>/**</div>
<div>&nbsp;&nbsp; * 先声明一个 IntentFilter 对象</div>
<div>&nbsp;&nbsp; */</div>
<div>&nbsp;&nbsp; private IntentFilter &nbsp; mIntentFilter;</div>
<div>&nbsp;&nbsp;public void onCreate(Bundle savedInstanceState)</div>
<div>&nbsp;&nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp;super.onCreate(savedInstanceState); &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp;setContentView(R.layout.main);</div>
<div>&nbsp;&nbsp; &nbsp;mIntentFilter = new IntentFilter();</div>
<div>&nbsp;&nbsp; mIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);</div>
<div>&nbsp;&nbsp;}</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;protected void onResume()</div>
<div>&nbsp;&nbsp;{</div>
<div>&nbsp;&nbsp; &nbsp;super.onResume(); &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp;// 注册消息处理器</div>
<div>&nbsp;&nbsp; &nbsp;registerReceiver(mIntentReceiver, mIntentFilter);</div>
<div>&nbsp;&nbsp;}</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;//声明消息处理过程</div>
<div>&nbsp;&nbsp; private BroadcastReceiver mIntentReceiver = newBroadcastReceiver() {</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; @Override</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; public void onReceive(Context context, Intentintent) {</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String action = intent.getAction();</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //要看看是不是我们要处理的消息</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (action.equals(Intent.ACTION_BATTERY_CHANGED)){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //电池电量，数字</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.d("Battery", "" + intent.getIntExtra("level",0)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //电池最大容量</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.d("Battery", "" + intent.getIntExtra("scale",0)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //电池伏数</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.d("Battery", "" +intent.getIntExtra("voltage", 0)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //电池温度</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.d("Battery", "" +intent.getIntExtra("temperature", 0));</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //电池状态，返回是一个数字</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // BatteryManager.BATTERY_STATUS_CHARGING 表示是充电状态</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // BatteryManager.BATTERY_STATUS_DISCHARGING 放电中</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // BatteryManager.BATTERY_STATUS_NOT_CHARGING 未充电</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // BatteryManager.BATTERY_STATUS_FULL 电池满</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.d("Battery", "" + intent.getIntExtra("status",BatteryManager.BATTERY_STATUS_UNKNOWN));</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //充电类型 BatteryManager.BATTERY_PLUGGED_AC 表示是充电器，不是这个值，表示是 USB</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.d("Battery", "" +intent.getIntExtra("plugged", 0));</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //电池健康情况，返回也是一个数字</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //BatteryManager.BATTERY_HEALTH_GOOD 良好</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //BatteryManager.BATTERY_HEALTH_OVERHEAT 过热</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //BatteryManager.BATTERY_HEALTH_DEAD 没电</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE 过电压</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE 未知错误</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.d("Battery", "" + intent.getIntExtra("health",BatteryManager.BATTERY_HEALTH_UNKNOWN));</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp;&nbsp; };</div>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/324090.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-06-21 21:28 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324090.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android滑动键盘事件捕获</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324089.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 21 Jun 2010 13:18:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324089.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/324089.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324089.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/324089.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/324089.html</trackback:ping><description><![CDATA[<span style="font-family: 宋体; color: #333333; font-size: 14px; line-height: 22px; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">G1带有实体键盘，可以侧推。虽然如今的G2 G3去掉了实体键盘，但同志们开发的应用还是得兼容一下G1吧。先从几个问题入手：<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
1、不管键盘是否滑出，都要设置屏幕为竖屏或者横屏。这个该怎么处理？<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
2、当用户在竖屏状态下编辑了一个文本框，又突然想推出实体键盘进行编辑，而此时Activity重绘，文本框内未保存的信息又该怎么办？<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
3、监听键盘滑动事件。让纵横屏状态下载入不同的layout。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">当然你也许可以再java代码中去设置很多事件捕获，但有一个更好的方法，那就是修改Androidmanifest.xml.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">默认的情况下推出或缩进键盘会重新启动<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial; ">activity<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
</span>要不关闭<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial; ">activity 则可以在</span>manifest.xml中增加 android:configChanges=&#8221;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial; ">keyboardHidden|orientation</span>&#8221;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
然后重载<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial; ">public void onConfigurationChanged(Configuration newConfig) 函数<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
</span>键盘被抽出后会首先调用onConfigurationChanged</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">如果你希望滑动键盘不改变屏幕分辨率 则可以增加属性：<strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; ">android:screenOrientation=&#8221;<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; color: #ff0000; "><span style="color: #0c0000; ">portrait</span></span>&#8220;</strong>&gt;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
<span style="color: #0c0000; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; color: #0000ff; "><span style="color: #0c0000; ">portrait :竖&nbsp; &nbsp;</span></span><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; "></span><span style="color: #0c0000; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; color: #0000ff; "><span style="color: #0c0000; ">landscape: 横</span></span></span><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; color: #0000ff; "><span style="color: #0c0000; ">sensor:根</span></span></span></span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; color: #0000ff; "><span style="color: #0c0000; "><span style="color: #0c0000; ">据手机的角度自动调整</span></span></span></span></span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Courier New'; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; color: #0000ff; "><span style="color: #0c0000; "></span></span></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">详细说明：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">&lt;activity &#8230;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; android:configChanges=[one or more of: "mcc" "mnc" "locale"<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;"touchscreen" "keyboard" "keyboardHidden"<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;"navigation" "orientation" "fontScale"]<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&#8230;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&lt;/activity&gt;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
android:configChanges<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; Lists configuration changes that the activity will handle itself. When changes that are not listed occur, the activity is shut down and restarted. When a listed change occurs, the activity remains running and its onConfigurationChanged() method is called.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">&nbsp; &nbsp; Any or all of the following strings can be used to set this attribute. Values are separated by &#8216;|&#8217; — for example, &#8220;locale|navigation|orientation&#8221;.<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; Value &nbsp; &nbsp; &nbsp; &nbsp; Description<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;mcc&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The IMSI mobile country code (MCC) has changed — that is, a SIM has been detected and updated the MCC.<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;mnc&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The IMSI mobile network code (MNC) has changed — that is, a SIM has been detected and updated the MNC.<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;locale&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The locale has changed — for example, the user has selected a new language that text should be displayed in.<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;touchscreen&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The touchscreen has changed. (This should never normally happen.)<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;keyboard&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The keyboard type has changed — for example, the user has plugged in an external keyboard.<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;keyboardHidden&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The keyboard accessibility has changed — for example, the user has slid the keyboard out to expose it.<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;navigation&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The navigation type has changed. (This should never normally happen.)<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;orientation&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The screen orientation has changed — that is, the user has rotated the device.<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; " />
&nbsp; &nbsp; &#8220;fontScale&#8221; &nbsp; &nbsp; &nbsp; &nbsp; The font scaling factor has changed — that is, the user has selected a new global font size.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; text-indent: 28px; text-align: justify; ">&nbsp; &nbsp; All of these configuration changes can impact the resource values seen by the application. Therefore, when onConfigurationChanged() is called, it will generally be necessary to again retrieve all resources (including view layouts, drawables, and so on) to correctly handle the change.</p>
</span>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/324089.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-06-21 21:18 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/06/21/324089.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>c++ dlopen</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/05/05/320139.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Wed, 05 May 2010 10:34:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/05/05/320139.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/320139.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/05/05/320139.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/320139.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/320139.html</trackback:ping><description><![CDATA[转载于：http://hi.baidu.com/xcroger/blog/item/142db1ea5b937bdbd539c99a.html<br />
<br />
<div style="text-align: center;"><span style="font-size: medium;"><strong>C++ dlopen mini HOWTO 中译版 </strong></span></div>
<div align="center"><font color="#ff0000">C++ dlopen mini HOWTO<br />
作者：Aaron Isotton &lt;aaron@isotton.com&gt; 2006-03-16<br />
译者：Lolita@linuxsir.org 2006-08-05</font></div>
----------------------------------------------------------------------<br />
<font color="#ff0000">摘要<br />
如何使用dlopen API动态地加载C++函数和类</font><br />
----------------------------------------------------------------------<br />
<br />
<br />
<font color="#0000ff">介绍</font><br />
如何使用dlopen API动态地加载C++函数和类，是Unix C++程序员经常碰到的问题。事实上，情况偶尔有些复杂，需要一些解释。这正是写这篇mini HOWTO的缘由。<br />
理解这篇文档的前提是对C/C++语言中dlopen API有基本的了解。<br />
<font color="#0000ff"><br />
术语</font><br />
dlopen API<br />
关于dlclose、dlerror、dlopen和dlsym函数的描述可以在 dlopen(3) man手册页查到。<br />
请注意，我们使用&#8220;dlopen&#8221;时，指的是dlopen函数，而使用&#8220;dlopen API&#8221;则是指整个API集合。<br />
<font color="#0000ff"><br />
问题所在</font><br />
有时你想在运行时加载一个库（并使用其中的函数），这在你为你的程序写一些插件或模块架构的时候经常发生。<br />
在C语言中，加载一个库轻而易举（调用dlopen、dlsym和dlclose就够了），但对C++来说，情况稍微复杂。动态加载一个C++库的困难一
部分是因为C++的name mangling（译者注：也有人把它翻译为&#8220;名字毁坏&#8221;，我觉得还是不翻译好），另一部分是因为dlopen
API是用C语言实现的，因而没有提供一个合适的方式来装载类。<br />
在解释如何装载C++库之前，最好再详细了解一下name mangling。我推荐您了解一下它，即使您对它不感兴趣。因为这有助于您理解问题是如何产生的，如何才能解决它们。<br />
<br />
<font color="#0000ff">　　Name Mangling</font><br />
在每个C++程序（或库、目标文件）中，所有非静态（non-static）函数在二进制文件中都是以&#8220;符号（symbol）&#8221;形式出现的。这些符号都是唯一的字符串，从而把各个函数在程序、库、目标文件中区分开来。<br />
在C中，符号名正是函数名：strcpy函数的符号名就是&#8220;strcpy&#8221;，等等。这可能是因为两个非静态函数的名字一定各不相同的缘故。<br />
而C++允许重载（不同的函数有相同的名字但不同的参数），并且有很多C所没有的特性──比如类、成员函数、异常说明──几乎不可能直接用函数名作符号
名。为了解决这个问题，C++采用了所谓的name
mangling。它把函数名和一些信息（如参数数量和大小）杂糅在一起，改造成奇形怪状，只有编译器才懂的符号名。例如，被mangle后的foo可能
看起来像foo@4%6^，或者，符号名里头甚至不包括&#8220;foo&#8221;。<br />
其中一个问题是，C++标准（目前是[ISO14882]）并没有定义名字必须如何被mangle，所以每个编译器都按自己的方式来进行name
mangling。有些编译器甚至在不同版本间更换mangling算法（尤其是g++
2.x和3.x）。即使您搞清楚了您的编译器到底怎么进行mangling的，从而可以用dlsym调用函数了，但可能仅仅限于您手头的这个编译器而已，
而无法在下一版编译器下工作。<br />
<br />
<font color="#0000ff">　　类</font><br />
使用dlopen API的另一个问题是，它只支持加载函数。但在C++中，您可能要用到库中的一个类，而这需要创建该类的一个实例，这不容易做到。<br />
<br />
<font color="#0000ff">解决方案</font><br />
<br />
<font color="#0000ff">extern "C"</font><br />
C++有个特定的关键字用来声明采用C binding的函数：extern "C" 。 用 extern
"C"声明的函数将使用函数名作符号名，就像C函数一样。因此，只有非成员函数才能被声明为extern
"C"，并且不能被重载。尽管限制多多，extern "C"函数还是非常有用，因为它们可以象C函数一样被dlopen动态加载。冠以extern
"C"限定符后，并不意味着函数中无法使用C++代码了，相反，它仍然是一个完全的C++函数，可以使用任何C++特性和各种类型的参数。<br />
<br />
<font style="background-color: #ff99cc;" size="4" color="#0000ff"><strong>加载函数</strong></font><br />
在C++中，函数用dlsym加载，就像C中一样。不过，该函数要用extern "C"限定符声明以防止其符号名被mangle。<br />
<br />
<font style="background-color: #99ccff;">示例1.加载函数<br />
</font>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<hr />
<code dir="ltr" style="margin: 0px; text-align: left;"><font face="NSimsun"><br />
<font color="#339966">//----------<br />
//main.cpp:<br />
//----------</font><br />
<font color="#0000ff">#include &lt;iostream&gt;<br />
#include &lt;dlfcn.h&gt;<br />
<br />
int main() <br />
{<br />
using std::cout;<br />
using std::cerr;<br />
<br />
cout &lt;&lt; "C++ dlopen demo\n\n";<br />
<br />
<font color="#339966">// open the library<br />
</font>cout &lt;&lt; "Opening hello.so...\n";<br />
void* handle = dlopen("./hello.so", RTLD_LAZY);<br />
<br />
if (!handle) {<br />
cerr &lt;&lt; "Cannot open library: " &lt;&lt; dlerror() &lt;&lt; '\n';<br />
return 1;<br />
}<br />
<br />
<font color="#339966">// load the symbol<br />
</font>cout &lt;&lt; "Loading symbol hello...\n";<br />
typedef void (*hello_t)();<br />
<br />
<font color="#339966">// reset errors<br />
</font>dlerror();<br />
hello_t hello = (hello_t) dlsym(handle, "hello");<br />
const char *dlsym_error = dlerror();<br />
if (dlsym_error) {<br />
cerr &lt;&lt; "Cannot load symbol 'hello': " &lt;&lt; dlsym_error &lt;&lt;'\n';<br />
dlclose(handle);<br />
return 1;<br />
}<br />
<br />
<font color="#339966">// use it to do the calculation</font><br />
cout &lt;&lt; "Calling hello...\n";<br />
hello();<br />
<br />
<font color="#339966">// close the library<br />
</font>cout &lt;&lt; "Closing library...\n";<br />
dlclose(handle);<br />
}<br />
<br />
<font color="#339966">//----------<br />
// hello.cpp:<br />
//----------</font><br />
#include &lt;iostream&gt;<br />
<br />
extern "C" void hello() <br />
{<br />
std::cout &lt;&lt; "hello" &lt;&lt; '\n';<br />
}</font></font></code> <hr />
</div>
在hello.cpp中函数hello被定义为extern "C"。它在main.cpp中被dlsym调用。函数必须以extern "C"限定，否则我们无从知晓其符号名。<br />
<br />
警告：<br />
extern "C"的声明形式有两种：上面示例中使用的那种内联（inline）形式extern "C" ， 还有才用花括号的extern
"C" { ... }这种。 第一种内联形式声明包含两层意义：外部链接(extern linkage)和C语言链接(language
linkage)，而第二种仅影响语言链接。<br />
<br />
下面两种声明形式等价：<br />
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<hr />
<code dir="ltr" style="margin: 0px; text-align: left;"><font face="NSimsun" color="#0000ff">extern "C" int foo;<br />
extern "C" void bar();</font></code> <hr />
</div>
和<br />
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<hr />
<code dir="ltr" style="margin: 0px; text-align: left;"><font face="NSimsun" color="#0000ff">extern "C" <br />
{<br />
extern int foo;<br />
extern void bar();<br />
}</font></code> <hr />
</div>
对于函数来说，extern和non-extern的函数声明没有区别，但对于变量就有不同了。如果您声明变量，请牢记：<br />
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<hr />
<code dir="ltr" style="margin: 0px; text-align: left;"><font face="NSimsun" color="#0000ff">extern "C" int foo;</font></code> <hr />
</div>
和<br />
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<hr />
<code dir="ltr" style="margin: 0px; text-align: left;"><font face="NSimsun" color="#0000ff">extern "C" <br />
{<br />
int foo;<br />
}</font></code> <hr />
</div>
是不同的事物(译者注：简言之，前者是个声明; 而后者不仅是声明，也可以是定义)。<br />
<br />
<font color="#0000ff">　　<font style="background-color: #ff99cc;" size="4"><strong>加载类</strong></font></font><br />
加载类有点困难，因为我们需要类的一个实例，而不仅仅是一个函数指针。我们无法通过new来创建类的实例，因为类不是在可执行文件中定义的，况且（有时候）我们连它的名字都不知道。<br />
解决方案是：利用多态性！ 我们在可执行文件中定义一个带虚成员函数的接口基类，而在模块中定义派生实现类。通常来说，接口类是抽象的（如果一个类含有虚函数，那它就是抽象的）。<br />
因为动态加载类往往用于实现插件，这意味着必须提供一个清晰定义的接口──我们将定义一个接口类和派生实现类。<br />
接下来，在模块中，我们会定义两个附加的helper函数，就是众所周知的&#8220;类工厂函数（class factory
functions）（译者注：或称对象工厂函数）&#8221;。其中一个函数创建一个类实例，并返回其指针;
另一个函数则用以销毁该指针。这两个函数都以extern "C"来限定修饰。<br />
为了使用模块中的类，我们用dlsym像示例1中加载hello函数那样加载这两个函数，然后我们就可以随心所欲地创建和销毁实例了。<br />
<br />
<font style="background-color: #99ccff;">示例2.加载类</font><br />
我们用一个一般性的多边形类作为接口，而继承它的三角形类（译者注：正三角形类）作为实现。<br />
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">代码:</div>
<hr />
<code dir="ltr" style="margin: 0px; text-align: left;"><font face="NSimsun" color="#0000ff"><font color="#339966">//----------<br />
//main.cpp:<br />
//----------</font><br />
#include "polygon.hpp"<br />
#include &lt;iostream&gt;<br />
#include &lt;dlfcn.h&gt;<br />
<br />
int main()<br />
{<br />
using std::cout;<br />
using std::cerr;<br />
<br />
<font color="#339966">// load the triangle library<br />
</font>void* triangle = dlopen("./triangle.so", RTLD_LAZY);<br />
if (!triangle) <br />
{<br />
cerr &lt;&lt; "Cannot load library: " &lt;&lt; dlerror() &lt;&lt; '\n';<br />
return 1;<br />
}<br />
<br />
<font color="#339966">// reset errors<br />
</font>dlerror();<br />
<br />
<font color="#339966">// load the symbols<br />
</font>create_t* create_triangle = (create_t*) dlsym(triangle, "create");<br />
const char* dlsym_error = dlerror();<br />
if (dlsym_error) <br />
{<br />
cerr &lt;&lt; "Cannot load symbol create: " &lt;&lt; dlsym_error &lt;&lt; '\n';<br />
return 1;<br />
}<br />
<br />
destroy_t* destroy_triangle = (destroy_t*) dlsym(triangle, "destroy");<br />
dlsym_error = dlerror();<br />
if (dlsym_error) <br />
{<br />
cerr &lt;&lt; "Cannot load symbol destroy: " &lt;&lt; dlsym_error &lt;&lt; '\n';<br />
return 1;<br />
}<br />
<br />
<font color="#339966">// create an instance of the class<br />
</font>polygon* poly = create_triangle();<br />
<br />
<font color="#339966">// use the class<br />
</font>poly-&gt;set_side_length(7);<br />
cout &lt;&lt; "The area is: " &lt;&lt; poly-&gt;area() &lt;&lt; '\n';<br />
<br />
<font color="#339966">// destroy the class<br />
</font>destroy_triangle(poly);<br />
<br />
<font color="#339966">// unload the triangle library</font><br />
dlclose(triangle);<br />
}<br />
<br />
<br />
<font color="#339966">//----------<br />
//polygon.hpp:<br />
//----------<br />
</font>#ifndef POLYGON_HPP<br />
#define POLYGON_HPP<br />
<br />
class polygon <br />
{<br />
protected:<br />
double side_length_;<br />
<br />
public:<br />
polygon()<br />
:side_length_(0) {}<br />
<br />
virtual ~polygon() {}<br />
<br />
void set_side_length(double side_length) <br />
{<br />
side_length_ = side_length;<br />
}<br />
<br />
virtual double area() const = 0;<br />
};<br />
<br />
<font color="#339966">// the types of the class factories<br />
</font>typedef polygon* create_t();<br />
typedef void destroy_t(polygon*);<br />
<br />
#endif<br />
<br />
<font color="#339966">//----------<br />
//triangle.cpp:<br />
//----------<br />
</font>#include "polygon.hpp"<br />
#include &lt;cmath&gt;<br />
<br />
class triangle : public polygon<br />
{<br />
public:<br />
virtual double area() const <br />
{<br />
return side_length_ * side_length_ * sqrt(3) / 2;<br />
}<br />
};<br />
<br />
<br />
<font color="#339966">// the class factories<br />
</font>extern "C" polygon* create() <br />
{<br />
return new triangle;<br />
}<br />
<br />
extern "C" void destroy(polygon* p) <br />
{<br />
delete p;<br />
}</font></code> <hr />
</div>
加载类时有一些值得注意的地方：<br />
◆
你必须（译者注：在模块或者说共享库中）同时提供一个创造函数和一个销毁函数，且不能在执行文件内部使用delete来销毁实例，只能把实例指针传递给模
块的销毁函数处理。这是因为C++里头，new操作符可以被重载;这容易导致new-delete的不匹配调用，造成莫名其妙的内存泄漏和段错误。这在用
不同的标准库链接模块和可执行文件时也一样。<br />
◆ 接口类的析构函数在任何情况下都必须是虚函数（virtual）。因为即使出错的可能极小，近乎杞人忧天了，但仍旧不值得去冒险，反正额外的开销微不足道。如果基类不需要析构函数，定义一个空的（但必须虚的）析构函数吧，否则你迟早要遇到问题，我向您保证。<br />
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/320139.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-05-05 18:34 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/05/05/320139.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android build system</title><link>http://www.blogjava.net/ThinkingTalking/archive/2010/04/21/319023.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Wed, 21 Apr 2010 13:00:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2010/04/21/319023.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/319023.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2010/04/21/319023.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/319023.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/319023.html</trackback:ping><description><![CDATA[<h1><a name="My_Project_">Android Build System</a></h1>
<!-- Status is one of: Draft, Current, Needs Update, Obsolete -->
<p style="text-align: center;">
<a name="My_Project_">  <strong>Status:</strong> <em>Draft </em> &nbsp;
<small>(as of May 18, 2006)</small>
</a></p>
<p><a name="My_Project_"><strong>Contents</strong></a></p>
<!-- this div expands out to a list of contents based on the H2 and H3 headings.
Believe it! -->
<a name="My_Project_"> </a>
<h2><a name="My_Project_">Objective</a></h2>
<p><a name="My_Project_">The primary goals of reworking the build system are (1) to make dependencies
work more reliably, so that when files need to rebuilt, they are, and (2) to
improve performance of the build system so that unnecessary modules are not
rebuilt, and so doing a top-level build when little or nothing needs to be done
for a build takes as little time as possible.</a></p>
<h2><a name="My_Project_">Principles and Use Cases and Policy</a></h2>
<p><a name="My_Project_">Given the above objective, these are the overall principles and use cases
that we will support.  This is not an exhaustive list.</a></p>
<h3><a name="My_Project_">Multiple Targets</a></h3>
<p><a name="My_Project_">It needs to be possible to build the Android platform for multiple targets.
This means:</a></p>
<ul><a name="My_Project_">    </a>
    <li><a name="My_Project_">The build system will support building tools for the host platform,
    both ones that are used in the build process itself, and developer tools
    like the simulator.</a></li>
    <a name="My_Project_">    </a>
    <li><a name="My_Project_">The build system will need to be able to build tools on Linux
    (definitely Goobuntu and maybe Grhat), MacOS, and to some degree on
    Windows.</a></li>
    <a name="My_Project_">    </a>
    <li><a name="My_Project_">The build system will need to be able to build the OS on Linux, and in
    the short-term, MacOS.  Note that this is a conscious decision to stop
    building the OS on Windows.  We are going to rely on the emulator there
    and not attempt to use the simulator.  This is a requirement change now
    that the emulator story is looking brighter.</a></li>
</ul>
<h3><a name="My_Project_">Non-Recursive Make</a></h3>
<p><a name="My_Project_">To achieve the objectives, the build system will be rewritten to use make
non-recursively.  For more background on this, read </a><a href="http://aegis.sourceforge.net/auug97.pdf">Recursive Make Considered Harmful</a>.  For those that don't
want PDF, here is the
<a href="http://72.14.203.104/search?q=cache:HwuX7YF2uBIJ:aegis.sourceforge.net/auug97.pdf&amp;hl=en&amp;gl=us&amp;ct=clnk&amp;cd=2&amp;client=firefox">Google translated version</a>.
</p>
<h3>Rapid Compile-Test Cycles</h3>
<p>When developing a component, for example a C++ shared library, it must be
possible to easily rebuild just that component, and not have to wait more than a
couple seconds for dependency checks, and not have to wait for unneeded
components to be built.</p>
<h3>Both Environment and Config File Based Settings</h3>
<p>To set the target, and other options, some people on the team like to have a
configuration file in a directory so they do not have an environment setup
script to run, and others want an environment setup script to run so they can
run builds in different terminals on the same tree, or switch back and forth
in one terminal.  We will support both.</p>
<h3>Object File Directory / make clean</h3>
<p>Object files and other intermediate files will be generated into a directory
that is separate from the source tree.  The goal is to have make clean be
"rm -rf <obj>" in the tree root directory.  The primary goals of
this are to simplify searching the source tree, and to make "make clean" more
reliable.</obj></p>
<h3>SDK</h3>
<p>The SDK will be a tarball that will allow non-OS-developers to write apps.
The apps will actually be built by first building the SDK, and then building
the apps against that SDK.  This will hopefully (1) make writing apps easier
for us, because we won't have to rebuild the OS as much, and we can use the
standard java-app development tools, and (2) allow us to dog-food the SDK, to
help ensure its quality.  Cedric has suggested (and I agree) that apps built
from the SDK should be built with ant.  Stay tuned for more details as we
figure out exactly how this will work.</p>
<h3>Dependecies</h3>
<p>Dependencies should all be automatic.  Unless there is a custom tool involved
(e.g. the webkit has several), the dependencies for shared and static libraries,
.c, .cpp, .h, .java, java libraries, etc., should all work without intervention
in the Android.mk file.</p>
<h3>Hiding command lines</h3>
<p>The default of the build system will be to hide the command lines being
executed for make steps.  It will be possible to override this by specifying
the showcommands pseudo-target, and possibly by setting an environment
variable.</p>
<h3>Wildcard source files</h3>
<p>Wildcarding source file will be discouraged.  It may be useful in some
scenarios.  The default <code>$(wildcard *)</code> will not work due to the
current directory being set to the root of the build tree.</p>
<p>
</p>
<h3>Multiple targets in one directory</h3>
<p>It will be possible to generate more than one target from a given
subdirectory.  For example, libutils generates a shared library for the target
and a static library for the host.</p>
<h3>Makefile fragments for modules</h3>
<p><strong>Android.mk</strong> is the standard name for the makefile fragments that
control the building of a given module.  Only the top directory should
have a file named "Makefile".</p>
<h3>Use shared libraries</h3>
<p>Currently, the simulator is not built to use shared libraries.  This should
be fixed, and now is a good time to do it.  This implies getting shared
libraries to work on Mac OS.</p>
<h2>Nice to Have</h2>
<p>These things would be nice to have, and this is a good place to record them,
however these are not promises.</p>
<h3>Simultaneous Builds</h3>
<p>The hope is to be able to do two builds for different combos in the same
tree at the same time, but this is a stretch goal, not a requirement.
Doing two builds in the same tree, not at the same time must work.  (update:
it's looking like we'll get the two builds at the same time working)</p>
<h3>Deleting headers (or other dependecies)</h3>
<p>Problems can arise if you delete a header file that is referenced in
".d" files.  The easy way to deal with this is "make clean".  There
should be a better way to handle it. (from fadden)</p>
<p>One way of solving this is introducing a dependency on the directory.  The
problem is that this can create extra dependecies and slow down the build.
It's a tradeoff.</p>
<h3>Multiple builds</h3>
<p>General way to perform builds across the set of known platforms.  This
would make it easy to perform multiple platform builds when testing a
change, and allow a wide-scale "make clean".  Right now the buildspec.mk
or environment variables need to be updated before each build. (from fadden)</p>
<h3>Aftermarket Locales and Carrier</h3>
<p>We will eventually need to add support for creating locales and carrier
customizations to the SDK, but that will not be addressed right now.</p>
<h2><a id="usage">Usage</a></h2>
<p><a id="usage">You've read (or scrolled past) all of the motivations for this build system,
and you want to know how to use it.  This is the place.</a></p>
<h3><a id="usage">Your first build</a></h3>
<p><a id="usage">The </a><a href="http://android.git.kernel.org/building.html">Building</a> document describes how do do
builds.</p>
<h3>build/envsetup.sh functions</h3>
If you source the file build/envsetup.sh into your bash environment,
<code>. build/envsetup.sh</code>you'll get a few helpful shell functions:
<ul>
    <li><strong>printconfig</strong> - Prints the current configuration as set by the
    lunch and choosecombo commands.</li>
    <li><strong>m</strong> - Runs <code>make</code> from the top of the tree.  This is
    useful because you can run make from within subdirectories.  If you have the
    <code>TOP</code> environment variable set, it uses that.  If you don't, it looks
    up the tree from the current directory, trying to find the top of the tree.</li>
    <li><strong>croot</strong> - <code>cd</code> to the top of the tree.</li>
    <li><strong>sgrep</strong> - grep for the regex you provide in all .c, .cpp, .h, .java,
    and .xml files below the current directory.</li>
</ul>
<h3>Build flavors/types</h3>
<p>
When building for a particular product, it's often useful to have minor
variations on what is ultimately the final release build.  These are the
currently-defined "flavors" or "types" (we need to settle on a real name
for these).
</p>
<table border="1">
    <tbody>
        <tr>
            <td>
            <code>eng<code>
            </code></code></td>
            <td>
            This is the default flavor. A plain "<code>make</code>" is the
            same as "<code>make eng</code>".  <code>droid</code> is an alias
            for <code>eng</code>.
            <ul>
                <li>Installs modules tagged with: <code>eng</code>, <code>debug</code>,
                <code>user</code>, and/or <code>development</code>.
                </li>
                <li>Installs non-APK modules that have no tags specified.
                </li>
                <li>Installs APKs according to the product definition files, in
                addition to tagged APKs.
                </li>
                <li><code>ro.secure=0</code>
                </li>
                <li><code>ro.debuggable=1</code>
                </li>
                <li><code>ro.kernel.android.checkjni=1</code>
                </li>
                <li><code>adb</code> is enabled by default.
                </li>
            </ul>
            </td>
        </tr>
        <tr>
            <td>
            <code>user<code>
            </code></code></td>
            <td>
            "<code>make user</code>"
            <p>
            This is the flavor intended to be the final release bits.
            </p>
            <ul>
                <li>Installs modules tagged with <code>user</code>.
                </li>
                <li>Installs non-APK modules that have no tags specified.
                </li>
                <li>Installs APKs according to the product definition files; tags
                are ignored for APK modules.
                </li>
                <li><code>ro.secure=1</code>
                </li>
                <li><code>ro.debuggable=0</code>
                </li>
                <li><code>adb</code> is disabled by default.
                </li>
            </ul>
            </td>
        </tr>
        <tr>
            <td>
            <code>userdebug<code>
            </code></code></td>
            <td>
            "<code>make userdebug</code>"
            <p>
            The same as <code>user</code>, except:
            </p>
            <ul>
                <li>Also installs modules tagged with <code>debug</code>.
                </li>
                <li><code>ro.debuggable=1</code>
                </li>
                <li><code>adb</code> is enabled by default.
                </li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p>
If you build one flavor and then want to build another, you should run
"<code>make installclean</code>" between the two makes to guarantee that
you don't pick up files installed by the previous flavor.  "<code>make
clean</code>" will also suffice, but it takes a lot longer.
</p>
<h3>More pseudotargets</h3>
<p>Sometimes you want to just build one thing.  The following pseudotargets are
there for your convenience:</p>
<ul>
    <li><strong>droid</strong> - <code>make droid</code> is the normal build.  This target
    is here because the default target has to have a name.</li>
    <li><strong>all</strong> - <code>make all</code> builds everything <code>make
    droid</code> does, plus everything whose <code>LOCAL_MODULE_TAGS</code> do not
    include the "droid" tag.  The build server runs this to make sure
    that everything that is in the tree and has an Android.mk builds.</li>
    <li><strong>clean-$(LOCAL_MODULE)</strong> and <strong>clean-$(LOCAL_PACKAGE_NAME)</strong> -
    Let you selectively clean one target.  For example, you can type
    <code>make clean-libutils</code> and it will delete libutils.so and all of the
    intermediate files, or you can type <code>make clean-Home</code> and it will
    clean just the Home app.</li>
    <li><strong>clean</strong> - <code>make clean</code> deletes all of the output and
    intermediate files for this configuration.  This is the same as <code>rm -rf
    out/&lt;configuration&gt;/</code></li>
    <li><strong>clobber</strong> - <code>make clobber</code> deletes all of the output
    and intermediate files for all configurations.  This is the same as
    <code>rm -rf out/</code>.</li>
    <li><strong>dataclean</strong> - <code>make dataclean</code> deletes contents of the data
    directory inside the current combo directory.  This is especially useful on the
    simulator and emulator, where the persistent data remains present between
    builds.</li>
    <li><strong>showcommands</strong> - <code>showcommands</code> is a modifier target
    which causes the build system to show the actual command lines for the build
    steps, instead of the brief descriptions.  Most people don't like seeing the
    actual commands, because they're quite long and hard to read, but if you need
    to for debugging purposes, you can add <code>showcommands</code> to the list
    of targets you build.  For example <code>make showcommands</code> will build
    the default android configuration, and <code>make runtime showcommands</code>
    will build just the runtime, and targets that it depends on, while displaying
    the full command lines.  Please note that there are a couple places where the
    commands aren't shown here.  These are considered bugs, and should be fixed,
    but they're often hard to track down.  Please let
    <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#97;&#110;&#100;&#114;&#111;&#105;&#100;&#45;&#98;&#117;&#105;&#108;&#100;&#45;&#116;&#101;&#97;&#109;">android-build-team</a> know if you find
    any.</li>
    <li><strong>LOCAL_MODULE</strong> - Anything you specify as a <code>LOCAL_MODULE</code>
    in an Android.mk is made into a pseudotarget.  For example, <code>make
    runtime</code> might be shorthand for <code>make
    out/linux-x86-debug/system/bin/runtime</code> (which would work), and
    <code>make libkjs</code> might be shorthand for <code>make
    out/linux-x86-debug/system/lib/libkjs.so</code> (which would also work).</li>
    <li><strong>targets</strong> - <code>make targets</code> will print a list of all of
    the LOCAL_MODULE names you can make.</li>
</ul>
<h3><a name="templates">How to add another component to the build - Android.mk templates</a></h3>
<p><a name="templates">You have a new library, a new app, or a new executable.  For each of the
common types of modules, there is a corresponding file in the templates
directory.  It will usually be enough to copy one of these, and fill in your
own values.  Some of the more esoteric values are not included in the
templates, but are instead just documented here, as is the documentation
on using custom tools to generate files.</a></p>
<p><a name="templates">Mostly, you can just look for the TODO comments in the templates and do
what it says.  Please remember to delete the TODO comments when you're done
to keep the files clean.  The templates have minimal documentation in them,
because they're going to be copied, and when that gets stale, the copies just
won't get updated.  So read on...</a></p>
<h4><a name="templates">Apps</a></h4>
<p><a name="templates">Use the <code>templates/apps</code> file.</a></p>
<p><a name="templates">This template is pretty self-explanitory.  See the variables below for more
details.</a></p>
<h4><a name="templates">Java Libraries</a></h4>
<p><a name="templates">Use the <code>templates/java_library</code> file.</a></p>
<p><a name="templates">The interesting thing here is the value of LOCAL_MODULE, which becomes
the name of the jar file.  (Actually right now, we're not making jar files yet,
just directories of .class files,  but the directory is named according to
what you put in LOCAL_MODULE).  This name will be what goes in the
LOCAL_JAVA_LIBRARIES variable in modules that depend on your java library.</a></p>
<h4><a name="templates">C/C++ Executables</a></h4>
<p><a name="templates">Use the <code>templates/executable</code> file, or the
<code>templates/executable_host</code> file.</a></p>
<p><a name="templates">This template has a couple extra options that you usually don't need.
Please delete the ones you don't need, and remove the TODO comments.  It makes
the rest of them easier to read, and you can always refer back to the templates
if you need them again later.</a></p>
<p><a name="templates">By default, on the target these are built into /system/bin, and on the
host, they're built into <combo>/host/bin.  These can be overridden by setting
<code>LOCAL_MODULE_PATH</code>.  See
</combo></a><a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#moving-targets">Putting targets elsewhere</a>
for more.</p>
<h4>Shared Libraries</h4>
<p>Use the <code>templates/shared_library</code> file, or the
<code>templates/shared_library_host</code> file.</p>
<p>Remember that on the target, we use shared libraries, and on the host,
we use static libraries, since executable size isn't as big an issue, and it
simplifies distribution in the SDK.</p>
<h4>Static Libraries</h4>
<p>Use the <code>templates/static_library</code> file, or the
<code>templates/static_library_host</code> file.</p>
<p>Remember that on the target, we use shared libraries, and on the host,
we use static libraries, since executable size isn't as big an issue, and it
simplifies distribution in the SDK.</p>
<h4><a name="custom-tools">Using Custom Tools</a></h4>
<p><a name="custom-tools">If you have a tool that generates source files for you, it's possible
to have the build system get the dependencies correct for it.  Here are
a couple of examples.  <code>$@</code> is the make built-in variable for
"the current target." The <font color="red">red</font> parts are the parts you'll
need to change.</a></p>
<p><a name="custom-tools">You need to put this after you have declared <code>LOCAL_PATH</code> and
<code>LOCAL_MODULE</code>, because the <code>$(local-intermediates-dir)</code>
and <code>$(local-host-intermediates-dir)</code> macros use these variables
to determine where to put the files.
</a></p>
<h5><a name="custom-tools">Example 1</a></h5>
<p><a name="custom-tools">Here, there is one generated file, called
chartables.c, which doesn't depend on anything.  And is built by the tool
built to $(HOST_OUT_EXECUTABLES)/dftables.  Note on the second to last line
that a dependency is created on the tool.</a></p>
<pre><a name="custom-tools">intermediates:= $(local-intermediates-dir)<br />
GEN := $(intermediates)/<font color="red">chartables.c</font><br />
$(GEN): PRIVATE_CUSTOM_TOOL = <font color="red">$(HOST_OUT_EXECUTABLES)/dftables $@</font><br />
$(GEN): <font color="red">$(HOST_OUT_EXECUTABLES)/dftables</font><br />
$(transform-generated-source)<br />
LOCAL_GENERATED_SOURCES += $(GEN)<br />
</a></pre>
<h5><a name="custom-tools">Example 2</a></h5>
<p><a name="custom-tools">Here as a hypothetical example, we use use cat as if it were to transform
a file.  Pretend that it does something useful.  Note how we use a
target-specific variable called PRIVATE_INPUT_FILE to store the name of the
input file.</a></p>
<pre><a name="custom-tools">intermediates:= $(local-intermediates-dir)<br />
GEN := $(intermediates)/<font color="red">file.c</font><br />
$(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/<font color="red">input.file</font><br />
$(GEN): PRIVATE_CUSTOM_TOOL = <font color="red">cat $(PRIVATE_INPUT_FILE) &gt; $@</font><br />
$(GEN): <font color="red">$(LOCAL_PATH)/file.c</font><br />
$(transform-generated-source)<br />
LOCAL_GENERATED_SOURCES += $(GEN)<br />
</a></pre>
<h5><a name="custom-tools">Example 3</a></h5>
<p><a name="custom-tools">If you have several files that are all similar in
name, and use the same tool, you can combine them.  (here the *.lut.h files are
the generated ones, and the *.cpp files are the input files)</a></p>
<pre><a name="custom-tools">intermediates:= $(local-intermediates-dir)<br />
GEN := $(addprefix $(intermediates)<font color="red">/kjs/, \<br />
array_object.lut.h \<br />
bool_object.lut.h \</font><br />
)<br />
$(GEN): PRIVATE_CUSTOM_TOOL = <font color="red">perl libs/WebKitLib/WebKit/JavaScriptCore/kjs/create_hash_table $&lt; -i &gt; $@</font><br />
$(GEN): $(intermediates)/<font color="red">%.lut.h</font> : $(LOCAL_PATH)/<font color="red">%.cpp</font><br />
$(transform-generated-source)<br />
LOCAL_GENERATED_SOURCES += $(GEN)<br />
</a></pre>
<h3><a name="platform-specific">Platform specific conditionals</a></h3>
<p><a name="platform-specific">Sometimes you need to set flags specifically for different platforms.  Here
is a list of which values the different build-system defined variables will be
set to and some examples.</a></p>
<p><a name="platform-specific">For a device build, <code>TARGET_OS</code> is <code>linux</code> (we're using
linux!), and <code>TARGET_ARCH</code> is <code>arm</code>.</a></p>
<p><a name="platform-specific">For a simulator build, <code>TARGET_OS</code> and <code>TARGET_ARCH</code>
are set to the same as <code>HOST_OS</code> and <code>HOST_ARCH</code> are
on your platform.  <code>TARGET_PRODUCT</code> is the name of the target
hardware/product you are building for.  The value <code>sim</code> is used
for the simulator.  We haven't thought through the full extent of customization
that will happen here, but likely there will be additional UI configurations
specified here as well.</a></p>
<table cellspacing="25">
    <tbody>
        <tr>
            <td valign="top" align="center">
            <strong>HOST_OS</strong><br />
            linux<br />
            darwin<br />
            (cygwin)
            </td>
            <td valign="top" align="center">
            <strong>HOST_ARCH</strong><br />
            x86
            </td>
            <td valign="top" align="center">
            <strong>HOST_BUILD_TYPE</strong><br />
            release<br />
            debug
            </td>
        </tr>
        <tr>
            <td valign="top" align="center">
            <strong>TARGET_OS</strong><br />
            linux<br />
            darwin<br />
            (cygwin)
            </td>
            <td valign="top" align="center">
            <strong>TARGET_ARCH</strong><br />
            arm<br />
            x86
            </td>
            <td valign="top" align="center">
            <strong>TARGET_BUILD_TYPE</strong><br />
            release<br />
            debug
            </td>
            <td valign="top" align="center">
            <strong>TARGET_PRODUCT</strong><br />
            sim<br />
            dream<br />
            sooner
            </td>
        </tr>
    </tbody>
</table>
<h4><a name="platform-specific">TARGET_SIMULATOR</a></h4>
<p><a name="platform-specific">If we're building the simulator, as opposed to the arm or emulator builds,
<code>TARGET_SIMULATOR</code> will be set to <code>true</code>.
</a></p>
<h4><a name="platform-specific">Some Examples</a></h4>
<pre><a name="platform-specific">ifeq ($(TARGET_SIMULATOR),true)<br />
LOCAL_CFLAGS += -DSIMULATOR<br />
endif<br />
<br />
ifeq ($(TARGET_BUILD_TYPE),release)<br />
LOCAL_CFLAGS += -DNDEBUG=1<br />
endif<br />
<br />
# from libutils<br />
ifeq ($(TARGET_OS),linux)<br />
# Use the futex based mutex and condition variable<br />
# implementation from android-arm because it's shared mem safe<br />
LOCAL_SRC_FILES += futex_synchro.c<br />
LOCAL_LDLIBS += -lrt -ldl<br />
endif<br />
<br />
</a></pre>
<h3><a name="moving-modules">Putting modules elsewhere</a></h3>
<p><a name="moving-modules">If you have modules that normally go somewhere, and you need to have them
build somewhere else, read this.  One use of this is putting files on
the root filesystem instead of where they normally go in /system. Add these
lines to your Android.mk:</a></p>
<pre><a name="moving-modules">LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)<br />
<br />
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)<br />
</a></pre>
<p><a name="moving-modules">For executables and libraries, you need to also specify a
<code>LOCAL_UNSTRIPPED_PATH</code> location, because on target builds, we keep
the unstripped executables so GDB can find the symbols.
</a></p>
<p><a name="moving-modules">Look in <code>config/envsetup.make</code> for all of the variables defining
places to build things.</a></p>
<p><a name="moving-modules">FYI: If you're installing an executable to /sbin, you probably also want to
set <code>LOCAL_FORCE_STATIC_EXCUTABLE := true</code> in your Android.mk, which
will force the linker to only accept static libraries.</a></p>
<h3><a name="moving-modules">Android.mk variables</a></h3>
<p><a name="moving-modules">These are the variables that you'll commonly see in Android.mk files, listed
alphabetically.</a></p>
<p><a name="moving-modules">But first, a note on variable naming:
</a></p>
<ul><a name="moving-modules">    </a>
    <li><a name="moving-modules"><strong>LOCAL_</strong> - These variables are set per-module.  They are cleared
    by the <code>include $(CLEAR_VARS)</code> line, so you can rely on them
    being empty after including that file.  Most of the variables you'll use
    in most modules are LOCAL_ variables.</a></li>
    <a name="moving-modules">    </a>
    <li><a name="moving-modules"><strong>PRIVATE_</strong> - These variables are make-target-specific variables.  That
    means they're only usable within the commands for that module.  It also
    means that they're unlikely to change behind your back from modules that
    are included after yours.  This
    </a><a href="http://www.gnu.org/software/make/manual/make.html#Target_002dspecific">link to the make documentation</a>
    describes more about target-specific variables.  Please note that there
    are a couple of these laying around the tree that aren't prefixed with
    PRIVATE_.  It is safe, and they will be fixed as they are discovered.
    Sorry for the confusion.</li>
    <li><strong>INTERNAL_</strong> - These variables are critical to functioning of
    the build system, so you shouldn't create variables named like this, and
    you probably shouldn't be messing with these variables in your makefiles.
    </li>
    <li><strong>HOST_</strong> and <strong>TARGET_</strong> - These contain the directories
    and definitions that are specific to either the host or the target builds.
    Do not set variables that start with HOST_ or TARGET_ in your makefiles.
    </li>
    <li><strong>BUILD_</strong> and <strong>CLEAR_VARS</strong> - These contain the names of
    well-defined template makefiles to include.  Some examples are CLEAR_VARS
    and BUILD_HOST_PACKAGE.</li>
    <li>Any other name is fair-game for you to use in your Android.mk.  However,
    remember that this is a non-recursive build system, so it is possible that
    your variable will be changed by another Android.mk included later, and be
    different when the commands for your rule / module are executed.</li>
</ul>
<h4>LOCAL_ASSET_FILES</h4>
<p>In Android.mk files that <code>include $(BUILD_PACKAGE)</code> set this
to the set of files you want built into your app.  Usually:</p>
<p><code>LOCAL_ASSET_FILES += $(call find-subdir-assets)</code></p>
<p>This will probably change when we switch to ant for the apps' build
system.</p>
<h4>LOCAL_CC</h4>
<p>If you want to use a different C compiler for this module, set LOCAL_CC
to the path to the compiler.  If LOCAL_CC is blank, the appropriate default
compiler is used.</p>
<h4>LOCAL_CXX</h4>
<p>If you want to use a different C++ compiler for this module, set LOCAL_CXX
to the path to the compiler.  If LOCAL_CXX is blank, the appropriate default
compiler is used.</p>
<h4>LOCAL_CFLAGS</h4>
<p>If you have additional flags to pass into the C or C++ compiler, add
them here.  For example:</p>
<p><code>LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1</code></p>
<h4>LOCAL_CPPFLAGS</h4>
<p>If you have additional flags to pass into <em>only</em> the C++ compiler, add
them here.  For example:</p>
<p><code>LOCAL_CPPFLAGS += -ffriend-injection</code></p>
<code>LOCAL_CPPFLAGS</code> is guaranteed to be after <code>LOCAL_CFLAGS</code>
on the compile line, so you can use it to override flags listed in
<code>LOCAL_CFLAGS</code>.
<h4>LOCAL_CPP_EXTENSION</h4>
<p>If your C++ files end in something other than "<code>.cpp</code>",
you can specify the custom extension here.  For example:</p>
<p><code>LOCAL_CPP_EXTENSION := .cc</code></p>
Note that all C++ files for a given module must have the same
extension; it is not currently possible to mix different extensions.
<h4>LOCAL_NO_DEFAULT_COMPILER_FLAGS</h4>
<p>Normally, the compile line for C and C++ files includes global include
paths and global cflags.  If <code>LOCAL_NO_DEFAULT_COMPILER_FLAGS</code>
is non-empty, none of the default includes or flags will be used when compiling
C and C++ files in this module.
<code>LOCAL_C_INCLUDES</code>, <code>LOCAL_CFLAGS</code>, and
<code>LOCAL_CPPFLAGS</code> will still be used in this case, as will
any <code>DEBUG_CFLAGS</code> that are defined for the module.
</p>
<h4>LOCAL_COPY_HEADERS</h4>
<p class="warning">This will be going away.</p>
<p>The set of files to copy to the install include tree.  You must also
supply <code>LOCAL_COPY_HEADERS_TO</code>.</p>
<p>This is going away because copying headers messes up the error messages, and
may lead to people editing those headers instead of the correct ones.  It also
makes it easier to do bad layering in the system, which we want to avoid.  We
also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any
headers.</p>
<h4>LOCAL_COPY_HEADERS_TO</h4>
<p class="warning">This will be going away.</p>
<p>The directory within "include" to copy the headers listed in
<code>LOCAL_COPY_HEADERS</code> to.</p>
<p>This is going away because copying headers messes up the error messages, and
may lead to people editing those headers instead of the correct ones.  It also
makes it easier to do bad layering in the system, which we want to avoid.  We
also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any
headers.</p>
<h4>LOCAL_C_INCLUDES</h4>
<p>Additional directories to instruct the C/C++ compilers to look for header
files in.  These paths are rooted at the top of the tree.  Use
<code>LOCAL_PATH</code> if you have subdirectories of your own that you
want in the include paths.  For example:</p>
<p><code>
LOCAL_C_INCLUDES += extlibs/zlib-1.2.3<br />
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src
</code></p>
<p>You should not add subdirectories of include to
<code>LOCAL_C_INCLUDES</code>, instead you should reference those files
in the <code>#include</code> statement with their subdirectories.  For
example:</p>
<p><code>#include &lt;utils/KeyedVector.h&gt;</code><br />
not <code><s>#include &lt;KeyedVector.h&gt;</s></code></p>
<p>There are some components that are doing this wrong, and should be cleaned
up.</p>
<h4>LOCAL_MODULE_TAGS</h4>
<p>Set <code>LOCAL_MODULE_TAGS</code> to any number of whitespace-separated
tags.  If the tag list is empty or contains <code>droid</code>, the module
will get installed as part of a <code>make droid</code>.  Otherwise, it will
only get installed by running <code>make &lt;your-module&gt;</code>
or with the <code>make all</code> pseudotarget.</p>
<h4>LOCAL_REQUIRED_MODULES</h4>
<p>Set <code>LOCAL_REQUIRED_MODULES</code> to any number of whitespace-separated
module names, like "libblah" or "Email".  If this module is installed, all
of the modules that it requires will be installed as well.  This can be
used to, e.g., ensure that necessary shared libraries or providers are
installed when a given app is installed.
</p>
<h4>LOCAL_FORCE_STATIC_EXECUTABLE</h4>
<p>If your executable should be linked statically, set
<code>LOCAL_FORCE_STATIC_EXECUTABLE:=true</code>.  There is a very short
list of libraries that we have in static form (currently only libc).  This is
really only used for executables in /sbin on the root filesystem.</p>
<h4>LOCAL_GENERATED_SOURCES</h4>
<p>Files that you add to <code>LOCAL_GENERATED_SOURCES</code> will be
automatically generated and then linked in when your module is built.
See the <a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#custom-tools">Custom Tools</a> template makefile for an
example.</p>
<h4>LOCAL_JAVA_LIBRARIES</h4>
<p>When linking Java apps and libraries, <code>LOCAL_JAVA_LIBRARIES</code>
specifies which sets of java classes to include.  Currently there are
two of these: <code>core</code> and <code>framework</code>.
In most cases, it will look like this:</p>
<p><code>LOCAL_JAVA_LIBRARIES := core framework</code></p>
<p>Note that setting <code>LOCAL_JAVA_LIBRARIES</code> is not necessary
(and is not allowed) when building an APK with
"<code>include $(BUILD_PACKAGE)</code>".  The appropriate libraries
will be included automatically.</p>
<h4>LOCAL_LDFLAGS</h4>
<p>You can pass additional flags to the linker by setting
<code>LOCAL_LDFLAGS</code>.  Keep in mind that the order of parameters is
very important to ld, so test whatever you do on all platforms.</p>
<h4>LOCAL_LDLIBS</h4>
<p><code>LOCAL_LDLIBS</code> allows you to specify additional libraries
that are not part of the build for your executable or library.  Specify
the libraries you want in -lxxx format; they're passed directly to the
link line.  However, keep in mind that there will be no dependency generated
for these libraries.  It's most useful in simulator builds where you want
to use a library preinstalled on the host.  The linker (ld) is a particularly
fussy beast, so it's sometimes necessary to pass other flags here if you're
doing something sneaky. Some examples:</p>
<p><code>LOCAL_LDLIBS += -lcurses -lpthread<br />
LOCAL_LDLIBS += -Wl,-z,origin
</code></p>
<h4>LOCAL_NO_MANIFEST</h4>
<p>If your package doesn't have a manifest (AndroidManifest.xml), then
set <code>LOCAL_NO_MANIFEST:=true</code>.  The common resources package
does this.</p>
<h4>LOCAL_PACKAGE_NAME</h4>
<p><code>LOCAL_PACKAGE_NAME</code> is the name of an app.  For example,
Dialer, Contacts, etc.  This will probably change or go away when we switch
to an ant-based build system for the apps.</p>
<h4>LOCAL_PATH</h4>
<p>The directory your Android.mk file is in. You can set it by putting the
following as the first line in your Android.mk:</p>
<p><code>LOCAL_PATH := $(my-dir)</code></p>
<p>The <code>my-dir</code> macro uses the
<code><a href="http://www.gnu.org/software/make/manual/make.html#MAKEFILE_005fLIST-Variable">MAKEFILE_LIST</a></code>
variable, so you must call it before you include any other makefiles.  Also,
consider that any subdirectories you inlcude might reset LOCAL_PATH, so do your
own stuff before you include them.  This also means that if you try to write
several <code>include</code> lines that reference <code>LOCAL_PATH</code>,
it won't work, because those included makefiles might reset LOCAL_PATH.
</p>
<h4>LOCAL_POST_PROCESS_COMMAND</h4>
<p>For host executables, you can specify a command to run on the module
after it's been linked.  You might have to go through some contortions
to get variables right because of early or late variable evaluation:</p>
<p><code>module := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)<br />
LOCAL_POST_PROCESS_COMMAND := /Developer/Tools/Rez -d __DARWIN__ -t APPL\<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-d __WXMAC__ -o $(module) Carbon.r
</code></p>
<h4>LOCAL_PREBUILT_EXECUTABLES</h4>
<p>When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to
executables that you want copied.  They're located automatically into the
right bin directory.</p>
<h4>LOCAL_PREBUILT_LIBS</h4>
<p>When including $(BUILD_PREBUILT) or $(BUILD_HOST_PREBUILT), set these to
libraries that you want copied.  They're located automatically into the
right lib directory.</p>
<h4>LOCAL_SHARED_LIBRARIES</h4>
<p>These are the libraries you directly link against.  You don't need to
pass transitively included libraries.  Specify the name without the suffix:</p>
<p><code>LOCAL_SHARED_LIBRARIES := \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libutils \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libui \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libaudio \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libexpat \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libsgl
</code></p>
<h4>LOCAL_SRC_FILES</h4>
<p>The build system looks at <code>LOCAL_SRC_FILES</code> to know what source
files to compile -- .cpp .c .y .l .java.  For lex and yacc files, it knows
how to correctly do the intermediate .h and .c/.cpp files automatically.  If
the files are in a subdirectory of the one containing the Android.mk, prefix
them with the directory name:</p>
<p><code>LOCAL_SRC_FILES := \<br />
&nbsp;&nbsp;&nbsp;&nbsp;file1.cpp \<br />
&nbsp;&nbsp;&nbsp;&nbsp;dir/file2.cpp
</code></p>
<h4>LOCAL_STATIC_LIBRARIES</h4>
<p>These are the static libraries that you want to include in your module.
Mostly, we use shared libraries, but there are a couple of places, like
executables in sbin and host executables where we use static libraries instead.
</p>
<p><code>LOCAL_STATIC_LIBRARIES := \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libutils \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libtinyxml
</code></p>
<h4>LOCAL_MODULE</h4>
<p><code>LOCAL_MODULE</code> is the name of what's supposed to be generated
from your Android.mk.  For exmample, for libkjs, the <code>LOCAL_MODULE</code>
is "libkjs" (the build system adds the appropriate suffix -- .so .dylib .dll).
For app modules, use <code>LOCAL_PACKAGE_NAME</code> instead of
<code>LOCAL_MODULE</code>.  We're planning on switching to ant for the apps,
so this might become moot.</p>
<h4>LOCAL_MODULE_PATH</h4>
<p>Instructs the build system to put the module somewhere other than what's
normal for its type.  If you override this, make sure you also set
<code>LOCAL_UNSTRIPPED_PATH</code> if it's an executable or a shared library
so the unstripped binary has somewhere to go.  An error will occur if you forget
to.</p>
<p>See <a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#moving-modules">Putting modules elsewhere</a> for more.</p>
<h4>LOCAL_UNSTRIPPED_PATH</h4>
<p>Instructs the build system to put the unstripped version of the module
somewhere other than what's normal for its type.  Usually, you override this
because you overrode <code>LOCAL_MODULE_PATH</code> for an executable or a
shared library.  If you overrode <code>LOCAL_MODULE_PATH</code>, but not
<code>LOCAL_UNSTRIPPED_PATH</code>, an error will occur.</p>
<p>See <a href="http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html#moving-modules">Putting modules elsewhere</a> for more.</p>
<h4>LOCAL_WHOLE_STATIC_LIBRARIES</h4>
<p>These are the static libraries that you want to include in your module without allowing
the linker to remove dead code from them. This is mostly useful if you want to add a static library
to a shared library and have the static library's content exposed from the shared library.
</p>
<p><code>LOCAL_WHOLE_STATIC_LIBRARIES := \<br />
&nbsp;&nbsp;&nbsp;&nbsp;libsqlite3_android<br />
</code></p>
<h4>LOCAL_YACCFLAGS</h4>
<p>Any flags to pass to invocations of yacc for your module.  A known limitation
here is that the flags will be the same for all invocations of YACC for your
module.  This can be fixed.  If you ever need it to be, just ask.</p>
<p><code>LOCAL_YACCFLAGS := -p kjsyy</code></p>
<h2>Implementation Details</h2>
<p>You should never have to touch anything in the config directory unless
you're adding a new platform, new tools, or adding new features to the
build system.  In general, please consult with the build system owner(s)
(<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#97;&#110;&#100;&#114;&#111;&#105;&#100;&#45;&#98;&#117;&#105;&#108;&#100;&#45;&#116;&#101;&#97;&#109;">android-build-team</a>) before you go
mucking around in here.  That said, here are some notes on what's going on
under the hood.</p>
<h3>Environment Setup / buildspec.mk Versioning</h3>
<p>In order to make easier for people when the build system changes, when
it is necessary to make changes to buildspec.mk or to rerun the environment
setup scripts, they contain a version number in the variable
BUILD_ENV_SEQUENCE_NUMBER.  If this variable does not match what the build
system expects, it fails printing an error message explaining what happened.
If you make a change that requires an update, you need to update two places
so this message will be printed.
</p>
<ul>
    <li>In config/envsetup.make, increment the
    CORRECT_BUILD_ENV_SEQUENCE_NUMBER definition.</li>
    <li>In buildspec.mk.default, update the BUILD_ENV_SEQUENCE_DUMBER
    definition to match the one in config/envsetup.make</li>
</ul>
The scripts automatically get the value from the build system, so they will
trigger the warning as well.
<h3>Additional makefile variables</h3>
<p>You probably shouldn't use these variables.  Please consult
<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#97;&#110;&#100;&#114;&#111;&#105;&#100;&#45;&#98;&#117;&#105;&#108;&#100;&#45;&#116;&#101;&#97;&#109;">android-build-team</a> before using them.
These are mostly there for workarounds for other issues, or things that aren't
completely done right.</p>
<h4>LOCAL_ADDITIONAL_DEPENDENCIES</h4>
<p>If your module needs to depend on anything else that
isn't actually built in to it, you can add those make targets to
<code>LOCAL_ADDITIONAL_DEPENDENCIES</code>.  Usually this is a workaround
for some other dependency that isn't created automatically.</p>
<h4>LOCAL_BUILT_MODULE</h4>
<p>When a module is built, the module is created in an intermediate
directory then copied to its final location.  LOCAL_BUILT_MODULE is
the full path to the intermediate file.  See LOCAL_INSTALLED_MODULE
for the path to the final installed location of the module.</p>
<h4>LOCAL_HOST</h4>
<p>Set by the host_xxx.make includes to tell base_rules.make and the other
includes that we're building for the host.  Kenneth did this as part of
openbinder, and I would like to clean it up so the rules, includes and
definitions aren't duplicated for host and target.</p>
<h4>LOCAL_INSTALLED_MODULE</h4>
<p>The fully qualified path name of the final location of the module.
See LOCAL_BUILT_MODULE for the location of the intermediate file that
the make rules should actually be constructing.</p>
<h4>LOCAL_REPLACE_VARS</h4>
<p>Used in some stuff remaining from the openbinder for building scripts
with particular values set,</p>
<h4>LOCAL_SCRIPTS</h4>
<p>Used in some stuff remaining from the openbinder build system that we
might find handy some day.</p>
<h4>LOCAL_MODULE_CLASS</h4>
<p>Which kind of module this is.  This variable is used to construct other
variable names used to locate the modules.  See base_rules.make and
envsetup.make.</p>
<h4>LOCAL_MODULE_NAME</h4>
<p>Set to the leaf name of the LOCAL_BUILT_MODULE.  I'm not sure,
but it looks like it's just used in the WHO_AM_I variable to identify
in the pretty printing what's being built.</p>
<h4>LOCAL_MODULE_SUFFIX</h4>
<p>The suffix that will be appended to <code>LOCAL_MODULE</code> to form
<code>LOCAL_MODULE_NAME</code>.  For example, .so, .a, .dylib.</p>
<h4>LOCAL_STRIP_MODULE</h4>
<p>Calculated in base_rules.make to determine if this module should actually
be stripped or not, based on whether <code>LOCAL_STRIPPABLE_MODULE</code>
is set, and whether the combo is configured to ever strip modules.  With
Iliyan's stripping tool, this might change.</p>
<h4>LOCAL_STRIPPABLE_MODULE</h4>
<p>Set by the include makefiles if that type of module is strippable.
Executables and shared libraries are.</p>
<h4>LOCAL_SYSTEM_SHARED_LIBRARIES</h4>
<p>Used while building the base libraries: libc, libm, libdl.  Usually
it should be set to "none," as it is in $(CLEAR_VARS).  When building
these libraries, it's set to the ones they link against.  For example,
libc, libstdc++ and libdl don't link against anything, and libm links against
libc.  Normally, when the value is none, these libraries are automatically
linked in to executables and libraries, so you don't need to specify them
manually.</p>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/319023.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2010-04-21 21:00 <a href="http://www.blogjava.net/ThinkingTalking/archive/2010/04/21/319023.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]android 铃声和音量的获取程序</title><link>http://www.blogjava.net/ThinkingTalking/archive/2009/11/23/303328.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 23 Nov 2009 05:44:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2009/11/23/303328.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/303328.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2009/11/23/303328.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/303328.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/303328.html</trackback:ping><description><![CDATA[转载自：http://www.hlovey.cn/2009/09/24/android-ringtone-ringvolumn.html
<div><span  style="font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; color: #333333; font-size: 14px; line-height: 22px; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; text-indent: 28px; text-align: justify; ">通过程序获取android系统手机的铃声和音量。同样，设置铃声和音量的方法也很简单！</p>
<div class="hl-surround" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; background-color: #f9fbfc; border-left-color: #c3ced9; width: auto; height: auto; overflow-x: auto; overflow-y: auto; text-align: left; ">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 12px; padding-bottom: 0px; padding-left: 56px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-image: url(http://www.hlovey.cn/wp-content/plugins/coolcode/images/hide.gif); list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; background-color: transparent; background-position: 5px 5px; background-repeat: no-repeat no-repeat; ">
    <li class="hl-firstline" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; background-color: #f9fbfc !important; ">AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);</li>
</ol>
</div>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; text-indent: 28px; text-align: justify; ">//通话音量</p>
<div class="hl-surround" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; background-color: #f9fbfc; border-left-color: #c3ced9; width: auto; height: auto; overflow-x: auto; overflow-y: auto; text-align: left; ">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 12px; padding-bottom: 0px; padding-left: 56px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-image: url(http://www.hlovey.cn/wp-content/plugins/coolcode/images/hide.gif); list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; background-color: transparent; background-position: 5px 5px; background-repeat: no-repeat no-repeat; ">
    <li class="hl-firstline" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; background-color: #f9fbfc !important; ">int max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;int current = mAudioManager.getStreamVolume( AudioManager.STREAM_VOICE_CALL );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;Log.d("VIOCE_CALL", "max : " + max + " current : " + current);</li>
</ol>
</div>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; text-indent: 28px; text-align: justify; ">//系统音量</p>
<div class="hl-surround" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; background-color: #f9fbfc; border-left-color: #c3ced9; width: auto; height: auto; overflow-x: auto; overflow-y: auto; text-align: left; ">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 12px; padding-bottom: 0px; padding-left: 56px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-image: url(http://www.hlovey.cn/wp-content/plugins/coolcode/images/hide.gif); list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; background-color: transparent; background-position: 5px 5px; background-repeat: no-repeat no-repeat; ">
    <li class="hl-firstline" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; background-color: #f9fbfc !important; ">max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_SYSTEM );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;current = mAudioManager.getStreamVolume( AudioManager.STREAM_SYSTEM );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;Log.d("SYSTEM", "max : " + max + " current : " + current);</li>
</ol>
</div>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; text-indent: 28px; text-align: justify; ">//铃声音量</p>
<div class="hl-surround" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; background-color: #f9fbfc; border-left-color: #c3ced9; width: auto; height: auto; overflow-x: auto; overflow-y: auto; text-align: left; ">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 12px; padding-bottom: 0px; padding-left: 56px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-image: url(http://www.hlovey.cn/wp-content/plugins/coolcode/images/hide.gif); list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; background-color: transparent; background-position: 5px 5px; background-repeat: no-repeat no-repeat; ">
    <li class="hl-firstline" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; background-color: #f9fbfc !important; ">max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_RING );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;current = mAudioManager.getStreamVolume( AudioManager.STREAM_RING );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;Log.d("RING", "max : " + max + " current : " + current);</li>
</ol>
</div>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; text-indent: 28px; text-align: justify; ">//音乐音量</p>
<div class="hl-surround" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; background-color: #f9fbfc; border-left-color: #c3ced9; width: auto; height: auto; overflow-x: auto; overflow-y: auto; text-align: left; ">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 12px; padding-bottom: 0px; padding-left: 56px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-image: url(http://www.hlovey.cn/wp-content/plugins/coolcode/images/hide.gif); list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; background-color: transparent; background-position: 5px 5px; background-repeat: no-repeat no-repeat; ">
    <li class="hl-firstline" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; background-color: #f9fbfc !important; ">max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_MUSIC );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;current = mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;Log.d("MUSIC", "max : " + max + " current : " + current);</li>
</ol>
</div>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; text-indent: 28px; text-align: justify; ">//提示声音音量</p>
<div class="hl-surround" style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; background-color: #f9fbfc; border-left-color: #c3ced9; width: auto; height: auto; overflow-x: auto; overflow-y: auto; text-align: left; ">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick="linenumber(this)" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 12px; padding-bottom: 0px; padding-left: 56px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-image: url(http://www.hlovey.cn/wp-content/plugins/coolcode/images/hide.gif); list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; background-color: transparent; background-position: 5px 5px; background-repeat: no-repeat no-repeat; ">
    <li class="hl-firstline" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; background-color: #f9fbfc !important; ">max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_ALARM );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;current = mAudioManager.getStreamVolume( AudioManager.STREAM_ALARM );</li>
    <li style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 12px !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; list-style-type: decimal !important; list-style-position: outside !important; list-style-image: initial !important; display: list-item !important; font-size: 12px !important; line-height: 20px !important; border-left-width: 1px; border-left-style: solid; border-left-color: #c3ced9; border-top-width: 1px; border-top-style: solid; border-top-color: #e3eef9 !important; background-color: #f9fbfc !important; ">&nbsp;&nbsp; &nbsp;Log.d("ALARM", "max : " + max + " current : " + current);</li>
</ol>
</div>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; text-indent: 28px; text-align: justify; ">设置音量的方法也很简单，AudioManager提供了方法：<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; " />
public void setStreamVolume(int streamType, int index, int flags)<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; " />
其中 streamType 有内置的常量，去文档里面就可以看到</p>
</span></div>
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/303328.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2009-11-23 13:44 <a href="http://www.blogjava.net/ThinkingTalking/archive/2009/11/23/303328.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用基本的Widget</title><link>http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300054.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Wed, 28 Oct 2009 06:29:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300054.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/300054.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300054.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/300054.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/300054.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 转载自：http://blog.csdn.net/xieyali/archive/2009/09/15/4555579.aspx第六章使用基本的Widget&nbsp;&nbsp;&nbsp;每一个GUI工具包都有一些基本的widget: fields, labels, buttons等等。Android的工具包也不例外，想要了解widget如何...&nbsp;&nbsp;<a href='http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300054.html'>阅读全文</a><img src ="http://www.blogjava.net/ThinkingTalking/aggbug/300054.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2009-10-28 14:29 <a href="http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300054.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】Manifest 概述</title><link>http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300046.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Wed, 28 Oct 2009 05:47:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300046.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/300046.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300046.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/300046.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/300046.html</trackback:ping><description><![CDATA[转载自：http://blog.csdn.net/xieyali/archive/2009/07/05/4323575.aspx
<p><span style="font-family: 宋体;">任何</span>
Android<span style="font-family: 宋体;">应用程序的基础都是</span>
Manifest<span style="font-family: 宋体;">文件：</span>
Manifest.xml<span style="font-family: 宋体;">，这个文件保存在工程的根目录下。在这个文件里声明应用程序用到的所有组件，例如：</span>
activities<span style="font-family: 宋体;">，</span>
services<span style="font-family: 宋体;">，等等，而且说明这些组件如何组织到应用程序系统中；例如：可以表明哪一个</span>
activity<span style="font-family: 宋体;">（或者</span>
activities<span style="font-family: 宋体;">）应该出现在设备的主窗口中（例如：</span>
launcher<span style="font-family: 宋体;">）。</span>
</p>
<p><span style="font-family: 宋体;">当你创建工程时，系统帮助生成一个原始的</span>
manifest<span style="font-family: 宋体;">文件。对于只包含一个</span>
activity<span style="font-family: 宋体;">的简单的应用程序，原始的</span>
manifest<span style="font-family: 宋体;">文件够了，或者只需要很小的改动。另外，</span>
manifest<span style="font-family: 宋体;">也可以很复杂，比如</span>
Android<span style="font-family: 宋体;">自带的</span>
API<span style="font-family: 宋体;">样例，该文件就超过</span>
1000<span style="font-family: 宋体;">多行。你的应用程序的</span>
manifest<span style="font-family: 宋体;">行数大概也就介于此间吧。</span>
</p>
<p>manifest<span style="font-family: 宋体;">文件的大部分有趣的功能会在以后相应的章节更加详细的介绍。比如</span>
service<span style="font-family: 宋体;">元素会在创建</span>
service<span style="font-family: 宋体;">章节详细讲述。现在，主要关注</span>
manifest<span style="font-family: 宋体;">文件的作用和它的一般结构。</span>
</p>
<p><strong><span style="font-family: 宋体;">在文件开始，有根，文件基本上就正确</span>
</strong>
</p>
<p>manifest<span style="font-family: 宋体;">文件的根是这样一个</span>
manifest<span style="font-family: 宋体;">元素：</span>
</p>
<p><span style="font-family: 宋体;">&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; package="com.commonsware.android.search"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br />
&lt;/manifest&gt;<br />
</span>
</p>
<p><!--   [if gte vml 1]>
<![endif]--></p>
<p><span style="font-family: 宋体;">注意命名空间声明。奇怪的是，自动生成的</span>
manifest<span style="font-family: 宋体;">文件，命名空间是应用在属性上，而不是元素上（例如，是</span>
manifest<span style="font-family: 宋体;">，不是</span>
android:manifest<span style="font-family: 宋体;">），然而，这种形式工作正确，只要</span>
android<span style="font-family: 宋体;">不发生改变，就坚持用这种形式。</span>
</p>
<p><span style="font-family: 宋体;">根元素</span>
manifest<span style="font-family: 宋体;">里面最有用的信息是</span>
package<span style="font-family: 宋体;">属性（奇怪的是</span>
package<span style="font-family: 宋体;">前没有命名空间）。这里，你可填成你的</span>
java package<span style="font-family: 宋体;">的名子，以后在</span>
manifest<span style="font-family: 宋体;">文件里，如果需要类的名子，就可以用点来代替</span>
package<span style="font-family: 宋体;">的名子，例如：如果在</span>
manifest<span style="font-family: 宋体;">文件需要引用</span>
com.commonsware.android.search.Snicklefritz<span style="font-family: 宋体;">，你就可以写成</span>
.Snicklefitz<span style="font-family: 宋体;">，因为</span>
com.commonsware.android.search<span style="font-family: 宋体;">已经被定义成应用程序的包。</span>
</p>
<p><strong><span style="font-family: 宋体;">权限，特殊工具，和应用程序</span>
</strong>
</p>
<p><span style="font-family: 宋体;">在</span>
manifest<span style="font-family: 宋体;">元素里有如下子元素：</span>
</p>
<p style="margin-left: 21pt; text-indent: -21pt;"><span style="font-family: Wingdings;"><span>l&nbsp;
</span>
</span>
uses-permission<span style="font-family: 宋体;">元素，表示应用程序必须据有这些权限才能工作正常－</span>
permissions<span style="font-family: 宋体;">章节</span>
</p>
<p style="margin-left: 21pt; text-indent: -21pt;"><span style="font-family: Wingdings;"><span>l&nbsp;
</span>
</span>
permission<span style="font-family: 宋体;">元素，定义一些权限，当其它的程序如果想使用你的程序的数据或者逻辑时，必须据有这些权限，参考</span>
permissions<span style="font-family: 宋体;">章节</span>
</p>
<p style="margin-left: 21pt; text-indent: -21pt;"><span style="font-family: Wingdings;"><span>l&nbsp;
</span>
</span>
instrumentation<span style="font-family: 宋体;">元素，表示某些代码，当一些重要的系统事件发生时，这些代码被调用，例如：启动一个</span>
activities<span style="font-family: 宋体;">，打印</span>
log<span style="font-family: 宋体;">或者监视某些信息。</span>
</p>
<p style="margin-left: 21pt; text-indent: -21pt;"><span style="font-family: Wingdings;"><span>l&nbsp;
</span>
</span>
uses-library<span style="font-family: 宋体;">元素，挂钩（</span>
hook<span style="font-family: 宋体;">）进可选的</span>
android<span style="font-family: 宋体;">组件里，例如</span>
mapping
services<span style="font-family: 宋体;">。</span>
</p>
<p style="margin-left: 21pt; text-indent: -21pt;"><span style="font-family: Wingdings;"><span>l&nbsp;
</span>
</span>
application<span style="font-family: 宋体;">元素，定义</span>
manifest<span style="font-family: 宋体;">描述的应用程序的细节。</span>
</p>
<p><!--   [if gte vml 1]>
<![endif]--></p>
<p><span style="font-family: 宋体;">在上面的例子中，</span>
uses-permission<span style="font-family: 宋体;">元素表明了应用程序将要使用的一些设备的功能，在这个例子中，就是程序据有了定位自己的功能。</span>
applicaton<span style="font-family: 宋体;">元素描述了一些</span>
activities<span style="font-family: 宋体;">，</span>
serives<span style="font-family: 宋体;">和其它组成应用的一些组件。</span>
</p>
<p><span style="font-family: 宋体;">&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"<br />
&nbsp;&nbsp; package="com.commonsware.android"&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;uses-permission<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="android.permission.ACCESS_LOCATION" /&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;uses-permission<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="android.permission.ACCESS_GPS" /&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;uses-permission<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="android.permission.ACCESS_ASSISTED_GPS" /&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;uses-permission<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="android.permission.ACCESS_CELL_ID" /&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;application&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br />
&nbsp;&nbsp;&nbsp; &lt;/application&gt;<br />
&lt;/manifest&gt;<br />
</span>
</p>
<p><strong><span style="font-family: 宋体;">应用程序需要实现一些功能，对吗？</span>
</strong>
</p>
<p>manifest<span style="font-family: 宋体;">文件最重要的部分就是</span>
application<span style="font-family: 宋体;">元素的子元素。</span>
</p>
<p><span style="font-family: 宋体;">创建新工程时，默认生成只含一个</span>
activity<span style="font-family: 宋体;">元素的</span>
manifest<span style="font-family: 宋体;">文件，如下：</span>
</p>
<p><!--   [if gte vml 1]>
<![endif]-->&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; package="com.commonsware.android.skeleton"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;application&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;activity android:name=".Now" android:label="Now"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;intent-filter&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action android:name="android.intent.action.MAIN" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;category android:name="android.intent.category.LAUNCHER" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/intent-filter&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/activity&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/application&gt;<br />
&lt;/manifest&gt;</p>
<p><span style="font-family: 宋体;">这个</span>
activity<span style="font-family: 宋体;">元素提供了如下信息，</span>
android:name<span style="font-family: 宋体;">－实现</span>
activity<span style="font-family: 宋体;">的类；和</span>
android:label<span style="font-family: 宋体;">－当运行</span>
activity<span style="font-family: 宋体;">时显示的名字；</span>
intent-filter<span style="font-family: 宋体;">子元素－描述在什么条件下</span>
activity<span style="font-family: 宋体;">才显示。这个</span>
activity<span style="font-family: 宋体;">元素设置在运行时显示这个</span>
activity<span style="font-family: 宋体;">，现在你可以运行它了。在后面的章节，会看到有多个</span>
activities<span style="font-family: 宋体;">的工程。</span>
</p>
<p><span style="font-family: 宋体;">可能还会有一个或者多个</span>
receiver<span style="font-family: 宋体;">元素，表示在一定条件下，一些非</span>
activites<span style="font-family: 宋体;">组件需要被触发，例如收到一条短信。这被称作是</span>
intent
receivers<span style="font-family: 宋体;">，在后续章节会讲到。</span>
</p>
<p><span style="font-family: 宋体;">可能还会有一个或者多个</span>
provider<span style="font-family: 宋体;">元素，表示</span>
content providers<span style="font-family: 宋体;">组件，它们负责提供数据给</span>
activities<span style="font-family: 宋体;">使用，并且，如果有权限，其它应用程序也可以使用它们提供的数据。它们把数据库或者其它数据存储包装成一个接口</span>
<span style="font-family: 宋体;">供其它应用程序使用。后续章节会讲怎么创建</span>
<span style="font-family: 宋体;">content provides和如何使用
content provides。
</span>
</p>
<p>
<span style="font-family: 宋体;">最后，可能会有一个或者多个</span>
<span style="font-family: 宋体;">service元素，描述
services－独立于
activity，并且长期运行的一些代码片段。最好的例子就是
mp3播放器，你想边听音乐，边打开其它
activities，这时候
mp3播放器的使用界面被覆盖。后面有两章会讲如何创建和使用
services。
</span>
</p>
<br />
<br />
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/300046.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2009-10-28 13:47 <a href="http://www.blogjava.net/ThinkingTalking/archive/2009/10/28/300046.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android connection refused</title><link>http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299841.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 26 Oct 2009 13:21:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299841.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/299841.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299841.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/299841.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/299841.html</trackback:ping><description><![CDATA[最近写socket时，总是报connection refused 异常，忙活半天找到是Android不能识别类似localhost或127.0.0.1的环回本地地址。只要cmd到命令行下，输入ipconfig/all就能看到自己的以太网ip地址，对于这个地址android很喜欢的。如果没有看到以太网地址，自己配置一个吧。
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/299841.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2009-10-26 21:21 <a href="http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299841.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android1.6及ADT0.9.3下载</title><link>http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299828.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Mon, 26 Oct 2009 10:57:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299828.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/299828.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299828.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/299828.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/299828.html</trackback:ping><description><![CDATA[Android SDK 1.6<br />
windows: http://androidappdocs.appspot.com/sdk/download.html?v=android-sdk-windows-1.6_r1.zip<br />
Linux: http://androidappdocs.appspot.com/sdk/download.html?v=android-sdk-linux_x86-1.6_r1.tgz<br />
ADT0.9.3:<br />
http://dl.google.com/android/ADT-0.9.3.zip
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/299828.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2009-10-26 18:57 <a href="http://www.blogjava.net/ThinkingTalking/archive/2009/10/26/299828.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android Ubuntu环境搭建</title><link>http://www.blogjava.net/ThinkingTalking/archive/2009/09/22/296078.html</link><dc:creator>David.Ko</dc:creator><author>David.Ko</author><pubDate>Tue, 22 Sep 2009 12:26:00 GMT</pubDate><guid>http://www.blogjava.net/ThinkingTalking/archive/2009/09/22/296078.html</guid><wfw:comment>http://www.blogjava.net/ThinkingTalking/comments/296078.html</wfw:comment><comments>http://www.blogjava.net/ThinkingTalking/archive/2009/09/22/296078.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ThinkingTalking/comments/commentRss/296078.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ThinkingTalking/services/trackbacks/296078.html</trackback:ping><description><![CDATA[1、SDK下载：http://dl.google.com/android/android-sdk-linux_x86-1.5_r3.zip<br />
2、安装eclipe(我的是3.5版本)插件:<a href="http://dl-ssl.google.com/android/eclipse/site.xml" target="_blank" rel="nofollow" editor_id="mce_editor_0" mce_real_href="http://dl-ssl.google.com/android/eclipse/site.xml">http://dl-ssl.google.com/android/eclipse/site.xml</a> <br />
3、重启eclipse后，在首选项里配置一下Android的home path<br />
4、ok!<br />
<img src ="http://www.blogjava.net/ThinkingTalking/aggbug/296078.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ThinkingTalking/" target="_blank">David.Ko</a> 2009-09-22 20:26 <a href="http://www.blogjava.net/ThinkingTalking/archive/2009/09/22/296078.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>