bluedrum 发表于 2011-12-22 08:51

Linux oops信息的分析

<b>&nbsp;Andrew Huang </b>&lt;bluedrum@163.com&gt; 转载请注明作者及网址<br><br>&nbsp;oops是英语口语"糟糕"的意思,当LINUX 内核发生严重错误时,比如内存段错误时,将会提示一大段信息。就提示 Oops,因此得名,<br>&nbsp; Oops提示信息相当多,包括出问题时的,各个常用寄存器的值,调用的堆栈,以及出错的可能原因<br><br><br><font size="5"><b>1.oops 的格式</b></font><br><br>&nbsp; 内核的文档里的详细的Oops的说明,的名字是<br>&nbsp; Documentation/oops-tracing.txt<br>&nbsp; <a href="http://www.mjmwired.net/kernel/Documentation/oops-tracing.txt" target="_blank" target="_blank">http://www.mjmwired.net/kernel/Documentation/oops-tracing.txt</a><br><br>&nbsp; oops第一段出错是内存page地址,<br>&nbsp;&nbsp;&nbsp; 例如提示 <br>&nbsp; Unable to handle kernel <b>NULL pointer </b>dereference at virtual address 00000000<br>pgd = c7510000<br>&nbsp; 往往表示碰到空指针了。<br>&nbsp; <br>&nbsp; 第二段出错时是寄存器的快照,不同CPU显示不同情况。<br>&nbsp;&nbsp; 其中基本上所有CPU都会有的PC寄存器(Program counter register),它保存最后出问题的地址。<br>&nbsp;&nbsp; LR保存着函数返回地址。这里就比较容易看出是谁出问题<br>&nbsp;&nbsp; <b>&lt;8&gt;PC is at memcpy+0x48/0x330<br>&nbsp;&nbsp; &lt;8&gt;LR is at s3c_fimc_v4l2_enum_fmt_vid_cap+0x44/0x4c</b><br>&nbsp; 这里可以看出,最后出问题代码在 memcpy里,而它是被s3c_fimc_v4l2_enum_fmt_vid_cap调用。结合前面的原因,可以知道应该是在memcpy里碰到空指针。<br>&nbsp;&nbsp; 函数名后面的两个数字,第一个是调用偏移量,第二个是函数总尺寸。<br>&nbsp; <br>&nbsp; 比如上例,在s3c_fimc_v4l2_enum_fmt_vid_cap的函数机器代码总尺寸是0x4c,在偏移量 0x44处调用了memcpy,而memcpy本身的总尺寸是0x330,而在偏移量0x48处,导致出现Oops信息<br><br>&nbsp; <br>&nbsp; 最重要是第三段,即可出错的调用堆栈(Call Trace).从这里即可推算出错的所在函数,参考下例.<br>&nbsp;&nbsp; 这里被调用函数上,调用函数在下。<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; <br><div id="codeText" class="codeText"><ol style="margin: 0pt 1px 0pt 0pt; padding: 5px 0pt;" start="1" class="dp-css"><li>&lt;8&gt;Backtrace:</li><li>
&lt;8&gt;[&lt;c02000f4&gt;] (s3c_fimc_v4l2_enum_fmt_vid_cap+0x0/0x4c) from [&lt;c01caee8&gt;] (__video_do_ioctl+0x600/0x3238)</li><li>
&lt;8&gt;[&lt;c01ca8e8&gt;] (__video_do_ioctl+0x0/0x3238) from [&lt;c01d04b4&gt;] (v4l1_compat_get_capabilities+0x1c0/0x25c)</li><li>
&lt;8&gt;[&lt;c01d02f4&gt;] (v4l1_compat_get_capabilities+0x0/0x25c) from [&lt;c01d14b0&gt;] (v4l_compat_translate_ioctl+0x150/0x238)</li><li>
&lt;8&gt;[&lt;c01d1360&gt;] (v4l_compat_translate_ioctl+0x0/0x238) from [&lt;c01caa00&gt;] (__video_do_ioctl+0x118/0x3238)</li><li>
&lt;8&gt;[&lt;c01ca8e8&gt;] (__video_do_ioctl+0x0/0x3238) from [&lt;c01cdcb8&gt;] (__video_ioctl2+0x198/0x2a0)</li><li>
&lt;8&gt;[&lt;c01cdb20&gt;] (__video_ioctl2+0x0/0x2a0) from [&lt;c01cdddc&gt;] (video_ioctl2+0x1c/0x20)</li><li>
&lt;8&gt;[&lt;c01cddc0&gt;] (video_ioctl2+0x0/0x20) from [&lt;c009e108&gt;] (vfs_ioctl+0x64/0x74)</li><li>
&lt;8&gt;[&lt;c009e0a4&gt;] (vfs_ioctl+0x0/0x74) from [&lt;c009e57c&gt;] (do_vfs_ioctl+0x438/0x488)</li></ol></div>&nbsp;上述最后几个调用就是<br>&nbsp;&nbsp; v4l1_compat_get_capabilities--&gt;&nbsp; __video_do_ioctl --&gt; s3c_fimc_v4l2_enum_fmt_vid_cap<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 函数名前的地址表示调用地址,函数名后面两个数字,也是表示调用入口偏移量(总是0x0)和函数机器代码总尺寸<br>&nbsp; 而from后面的地址是调用该函数的地址。以及对应的函数名和其偏移量/总尺寸<br>&nbsp; 如下例:<br>&nbsp;&nbsp;&nbsp;&nbsp; <b>[&lt;c02000f4&gt;] (s3c_fimc_v4l2_enum_fmt_vid_cap+0x0/0x4c) from [&lt;c01caee8&gt;] (__video_do_ioctl+0x600/0x3238)<br>&nbsp;&nbsp;&nbsp; [&lt;c01ca8e8&gt;] (__video_do_ioctl+0x0/0x3238) from [&lt;c01d04b4&gt;]</b><br><br>&nbsp;&nbsp;&nbsp; __video_do_ioctl在 该函数总尺寸是0x3238,调用子函数的偏移量为0x0,这个偏移量的绝对地址是0xc01ca8e8处,这里调用函数s3c_fimc_v4l2_enum_fmt_vid_cap.<br>&nbsp;&nbsp;&nbsp; s3c_fimc_v4l2_enum_fmt_vid_cap这个函数总尺寸是0x4c,而它的from后的地址,正好就是上一个调用函数的地址。并且在括号内部注明是__video_do_ioctl的偏移量0x600处.<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; <br><font size="5"><b>2.一个oops实例</b></font><br>&nbsp; 我自己写了一个v4l2的测试程序,在s3c6410(linux 2.6.28)对cmos的的摄像头的驱动执行了ioctl的VIDIOC_ENUM_FMT操作来查询它支持的视频格式,结果就出了oops信息了。<br>&nbsp;&nbsp; <br><div id="codeText" class="codeText"><ol style="margin: 0pt 1px 0pt 0pt; padding: 5px 0pt;" start="1" class="dp-css"><li><span style="color: rgb(0, 0, 0);">###Unable <span style="color: rgb(0, 0, 255);">to</span> handle kernel <span style="color: rgb(0, 0, 255);">NULL</span> pointer dereference at virtual address 00000000<br></span></li><li>
pgd <span style="color: rgb(0, 0, 204);">=</span> c7510000<br></li><li>
<span style="color: rgb(0, 0, 204);">[</span>00000000<span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">*</span>pgd<span style="color: rgb(0, 0, 204);">=</span>574f6031<span style="color: rgb(0, 0, 204);">,</span> <span style="color: rgb(0, 0, 204);">*</span>pte<span style="color: rgb(0, 0, 204);">=</span>00000000<span style="color: rgb(0, 0, 204);">,</span> <span style="color: rgb(0, 0, 204);">*</span>ppte<span style="color: rgb(0, 0, 204);">=</span>00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Internal <span style="color: rgb(0, 0, 255);">error</span><span style="color: rgb(0, 0, 204);">:</span> Oops<span style="color: rgb(0, 0, 204);">:</span> 17 <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">#</span>1<span style="color: rgb(0, 0, 204);">]</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Modules linked <span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 204);">:</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>CPU<span style="color: rgb(0, 0, 204);">:</span> 0    <span style="color: rgb(0, 0, 255);">Not</span> tainted<span style="color: rgb(0, 0, 204);">(</span>2<span style="color: rgb(0, 0, 204);">.</span>6<span style="color: rgb(0, 0, 204);">.</span>28<span style="color: rgb(0, 0, 204);">.</span>6<span style="color: rgb(0, 0, 204);">-</span>FriendlyARM #70<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>PC <span style="color: rgb(0, 0, 255);">is</span> at memcpy<span style="color: rgb(0, 0, 204);">+</span>0x48<span style="color: rgb(0, 0, 204);">/</span>0x330<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>LR <span style="color: rgb(0, 0, 255);">is</span> at s3c_fimc_v4l2_enum_fmt_vid_cap<span style="color: rgb(0, 0, 204);">+</span>0x44<span style="color: rgb(0, 0, 204);">/</span>0x4c<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>pc <span style="color: rgb(0, 0, 204);">:</span> <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c0170c08<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span>    lr <span style="color: rgb(0, 0, 204);">:</span> <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c0200138<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span>    psr<span style="color: rgb(0, 0, 204);">:</span> 80000013<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>sp <span style="color: rgb(0, 0, 204);">:</span> c74fba84ip <span style="color: rgb(0, 0, 204);">:</span> 00000000fp <span style="color: rgb(0, 0, 204);">:</span> c74fbabc<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>r10<span style="color: rgb(0, 0, 204);">:</span> c04dc710r9 <span style="color: rgb(0, 0, 204);">:</span> 00000001r8 <span style="color: rgb(0, 0, 204);">:</span> c0405602<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>r7 <span style="color: rgb(0, 0, 204);">:</span> c74766e0r6 <span style="color: rgb(0, 0, 204);">:</span> c04dc710r5 <span style="color: rgb(0, 0, 204);">:</span> 00000000r4 <span style="color: rgb(0, 0, 204);">:</span> c74fbc80<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>r3 <span style="color: rgb(0, 0, 204);">:</span> 00000000r2 <span style="color: rgb(0, 0, 204);">:</span> ffffffc0r1 <span style="color: rgb(0, 0, 204);">:</span> 00000000r0 <span style="color: rgb(0, 0, 204);">:</span> c74fbc80<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Flags<span style="color: rgb(0, 0, 204);">:</span> NzcvIRQs <span style="color: rgb(0, 0, 255);">on</span>FIQs <span style="color: rgb(0, 0, 255);">on</span>Mode SVC_32ISA ARMSegment user<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Control<span style="color: rgb(0, 0, 204);">:</span> 00c5387dTable<span style="color: rgb(0, 0, 204);">:</span> 57510008DAC<span style="color: rgb(0, 0, 204);">:</span> 00000015<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Process test_v4l <span style="color: rgb(0, 0, 204);">(</span>pid<span style="color: rgb(0, 0, 204);">:</span> 642<span style="color: rgb(0, 0, 204);">,</span> stack limit <span style="color: rgb(0, 0, 204);">=</span> 0xc74fa260<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Stack<span style="color: rgb(0, 0, 204);">:</span> <span style="color: rgb(0, 0, 204);">(</span>0xc74fba84 <span style="color: rgb(0, 0, 255);">to</span> 0xc74fc000<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>ba80<span style="color: rgb(0, 0, 204);">:</span>          00000000 c04dc710 c74766e0 c0405602 c74fbc80 c74fbc80 c0200138<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>baa0<span style="color: rgb(0, 0, 204);">:</span> c02000f4 c74fbc80 c0495488 c037313c c74fbbac c74fbac0 c01caee8 c0200100<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bac0<span style="color: rgb(0, 0, 204);">:</span> c032ddf4 c73049c0 c005be40 c74fbacc c74fbacc c008ec04 c74fbb04 c74fbae8<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bae0<span style="color: rgb(0, 0, 204);">:</span> c74fbb18 c007107c c04e7c18 00000000 00000000 c0397cc8 ffffffea c74fbb08<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bb00<span style="color: rgb(0, 0, 204);">:</span> c031995c c0319820 00000000 c74aabe0 00000000 c74fbba0 c74fbb3c c74fbb28<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bb20<span style="color: rgb(0, 0, 204);">:</span> c0319a14 00000064 c68cd200 00000000 00000000 c74fbb9c c03141e4 c0319978<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bb40<span style="color: rgb(0, 0, 204);">:</span> c032bd1c 00000000 c74d5e00 c74fbba0 c0397cc8 00000000 bf000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bb60<span style="color: rgb(0, 0, 204);">:</span> c747c804 c74cb00c c74fbb8c c74fbb78 c73049f0 75e3b180 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bb80<span style="color: rgb(0, 0, 204);">:</span> c74fbbb4 c74fbe38 c7501100 c74766e0 c01ca8e8 00000000 c74fbc80 00000001<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bba0<span style="color: rgb(0, 0, 204);">:</span> c74fbd2c c74fbbb0 c01d04b4 c01ca8f4 c74fbc1c 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bbc0<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bbe0<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bc00<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bc20<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bc40<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bc60<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bc80<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bca0<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bcc0<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 c0040a90 00000004 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bce0<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bd00<span style="color: rgb(0, 0, 204);">:</span> c00417f8 c74fbe38 c0495488 c037313c c74766e0 803c7601 00000000 c04dc710<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bd20<span style="color: rgb(0, 0, 204);">:</span> c74fbd3c c74fbd30 c01d14b0 c01d0300 c74fbe2c c74fbd40 c01caa00 c01d136c<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bd40<span style="color: rgb(0, 0, 204);">:</span> c74fbd5c c74fbd50 c01a96a4 c01941f4 c74fbd74 c74fbd60 c004c4c4 c01a9698<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bd60<span style="color: rgb(0, 0, 204);">:</span> c04cd140 c74fa000 c74fbda4 c74fbd78 c004ca24 c004c8c0 c006c830 c032de08<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bd80<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000045 0000001a c72ff425 00000000 c0483b18 c74fbdb4 c74fbda8<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bda0<span style="color: rgb(0, 0, 204);">:</span> c004ca90 c004c95c c74fbdcc c74fbdb8 c74fbdd4 c74fbdc0 c006bfd4 c003783c<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bdc0<span style="color: rgb(0, 0, 204);">:</span> c0471c88 c0476e4c c74fbdf4 c74fbdd8 c006bf20 c006bfac 00020000 c0476e4c<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bde0<span style="color: rgb(0, 0, 204);">:</span> c04768f4 c680c7b8 c74fbe14 c74fbdf8 c006eb64 c01749b4 00000000 c748b7e8<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>be00<span style="color: rgb(0, 0, 204);">:</span> c680c7b4 00000000 c74766e0 c74fbe38 00000000 00000000 00000000 803c7601<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>be20<span style="color: rgb(0, 0, 204);">:</span> c74fbee4 c74fbe30 c01cdcb8 c01ca8f4 00000002 bec77c88 2d633373 636d6966<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>be40<span style="color: rgb(0, 0, 204);">:</span> 00000030 00000000 00000000 00000000 00000000 00000000 00000029 00000002<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>be60<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000000 00000000 00000000 00000000 c748b7e8 c74fbedc c74fbe88<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>be80<span style="color: rgb(0, 0, 204);">:</span> c007ca1c c006ee54 c00417f8 0000007d c75249f4 00000000 c74b2870 4007d000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bea0<span style="color: rgb(0, 0, 204);">:</span> 00000000 00000042 4007d000 c0565960 c74fbed4 00000000 c748b7e8 c74766e0<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bec0<span style="color: rgb(0, 0, 204);">:</span> 803c7601 00000000 00000003 c002df08 c74fa000 00000000 c74fbef4 c74fbee8<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bee0<span style="color: rgb(0, 0, 204);">:</span> c01cdddc c01cdb2c c74fbf14 c74fbef8 c009e108 c01cddcc c68aa1b8 bec77c88<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bf00<span style="color: rgb(0, 0, 204);">:</span> c74766e0 803c7601 c74fbf7c c74fbf18 c009e57c c009e0b0 c74fbfb0 c748b7e8<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bf20<span style="color: rgb(0, 0, 204);">:</span> c74fbf3c c74fbf30 c005f5f8 c0176364 c74fbf7c c74fbf40 c0034394 c005f5f4<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bf40<span style="color: rgb(0, 0, 204);">:</span> c00927d0 c00bab14 00000000 00000200 c70b0dc0 ffffffff c74766e0 bec77c88<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bf60<span style="color: rgb(0, 0, 204);">:</span> 803c7601 00000003 c002df08 c74fa000 c74fbfa4 c74fbf80 c009e60c c009e150<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bf80<span style="color: rgb(0, 0, 204);">:</span> 60000010 00000000 00009154 00000140 00000000 00000036 00000000 c74fbfa8<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bfa0<span style="color: rgb(0, 0, 204);">:</span> c002dd60 c009e5d8 00009154 00000140 00000003 803c7601 bec77c88 bec77c88<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bfc0<span style="color: rgb(0, 0, 204);">:</span> 00009154 00000140 00000000 00000036 00000000 00000000 40180b60 bec77cd4<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>bfe0<span style="color: rgb(0, 0, 204);">:</span> 00000000 bec77c80 0000884c 4010ac3c 60000010 00000003 00000000 00000000<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Backtrace<span style="color: rgb(0, 0, 204);">:</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c02000f4<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>s3c_fimc_v4l2_enum_fmt_vid_cap<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x4c<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01caee8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>__video_do_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x600<span style="color: rgb(0, 0, 204);">/</span>0x3238<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span> r6<span style="color: rgb(0, 0, 204);">:</span>c037313c r5<span style="color: rgb(0, 0, 204);">:</span>c0495488 r4<span style="color: rgb(0, 0, 204);">:</span>c74fbc80 r3<span style="color: rgb(0, 0, 204);">:</span>c02000f4<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01ca8e8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>__video_do_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x3238<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01d04b4<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>v4l1_compat_get_capabilities<span style="color: rgb(0, 0, 204);">+</span>0x1c0<span style="color: rgb(0, 0, 204);">/</span>0x25c<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01d02f4<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>v4l1_compat_get_capabilities<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x25c<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01d14b0<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>v4l_compat_translate_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x150<span style="color: rgb(0, 0, 204);">/</span>0x238<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01d1360<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>v4l_compat_translate_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x238<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01caa00<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>__video_do_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x118<span style="color: rgb(0, 0, 204);">/</span>0x3238<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01ca8e8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>__video_do_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x3238<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01cdcb8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>__video_ioctl2<span style="color: rgb(0, 0, 204);">+</span>0x198<span style="color: rgb(0, 0, 204);">/</span>0x2a0<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01cdb20<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>__video_ioctl2<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x2a0<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01cdddc<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>video_ioctl2<span style="color: rgb(0, 0, 204);">+</span>0x1c<span style="color: rgb(0, 0, 204);">/</span>0x20<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c01cddc0<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>video_ioctl2<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x20<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c009e108<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>vfs_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x64<span style="color: rgb(0, 0, 204);">/</span>0x74<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c009e0a4<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>vfs_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x74<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c009e57c<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>do_vfs_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x438<span style="color: rgb(0, 0, 204);">/</span>0x488<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span> r6<span style="color: rgb(0, 0, 204);">:</span>803c7601 r5<span style="color: rgb(0, 0, 204);">:</span>c74766e0 r4<span style="color: rgb(0, 0, 204);">:</span>bec77c88 r3<span style="color: rgb(0, 0, 204);">:</span>c68aa1b8<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c009e144<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>do_vfs_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x488<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c009e60c<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>sys_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x40<span style="color: rgb(0, 0, 204);">/</span>0x64<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span> r9<span style="color: rgb(0, 0, 204);">:</span>c74fa000 r8<span style="color: rgb(0, 0, 204);">:</span>c002df08 r7<span style="color: rgb(0, 0, 204);">:</span>00000003 r6<span style="color: rgb(0, 0, 204);">:</span>803c7601 r5<span style="color: rgb(0, 0, 204);">:</span>bec77c88<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>r4<span style="color: rgb(0, 0, 204);">:</span>c74766e0<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c009e5cc<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>sys_ioctl<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x64<span style="color: rgb(0, 0, 204);">)</span> from <span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(0, 0, 204);">&lt;</span>c002dd60<span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">(</span>ret_fast_syscall<span style="color: rgb(0, 0, 204);">+</span>0x0<span style="color: rgb(0, 0, 204);">/</span>0x2c<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span> r7<span style="color: rgb(0, 0, 204);">:</span>00000036 r6<span style="color: rgb(0, 0, 204);">:</span>00000000 r5<span style="color: rgb(0, 0, 204);">:</span>00000140 r4<span style="color: rgb(0, 0, 204);">:</span>00009154<br></li><li>
<span style="color: rgb(0, 0, 204);">&lt;</span>8<span style="color: rgb(0, 0, 204);">&gt;</span>Code<span style="color: rgb(0, 0, 204);">:</span> ba000002 f5d1f03c f5d1f05c f5d1f07c <span style="color: rgb(0, 0, 204);">(</span>e8b151f8<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">[</span> <span style="color: rgb(0, 0, 255);">end</span> trace 1c239a4a0a70678b <span style="color: rgb(0, 0, 204);">]</span><span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">-</span><br></li><li>
<br></li><li>
Segmentation fault</li></ol></div>如果从这一些信息看出来,是s3c_fimc_v4l2_enum_fmt_vid_cap调用的memcpy中出错,而调用位置在较后的位置(0x4c中0x40处)。查看代码如下:<br>&nbsp; <br><div id="codeText" class="codeText"><ol style="margin: 0pt 1px 0pt 0pt; padding: 5px 0pt;" start="1" class="dp-css"><li><span style="color: rgb(0, 0, 0);">static <span style="color: rgb(255, 0, 0);">int</span> s3c_fimc_v4l2_enum_fmt_vid_cap<span style="color: rgb(0, 0, 204);">(</span>struct file <span style="color: rgb(0, 0, 204);">*</span>filp<span style="color: rgb(0, 0, 204);">,</span> void <span style="color: rgb(0, 0, 204);">*</span>fh<span style="color: rgb(0, 0, 204);">,</span><br></span></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct v4l2_fmtdesc <span style="color: rgb(0, 0, 204);">*</span>f<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">{</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;struct s3c_fimc_control <span style="color: rgb(0, 0, 204);">*</span>ctrl <span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(0, 0, 204);">(</span>struct s3c_fimc_control <span style="color: rgb(0, 0, 204);">*</span><span style="color: rgb(0, 0, 204);">)</span> fh<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(255, 0, 0);">int</span> index <span style="color: rgb(0, 0, 204);">=</span> f<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>index<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span>index <span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">=</span> S3C_FIMC_MAX_CAPTURE_FORMATS<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return <span style="color: rgb(0, 0, 204);">-</span>EINVAL<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;memset<span style="color: rgb(0, 0, 204);">(</span>f<span style="color: rgb(0, 0, 204);">,</span> 0<span style="color: rgb(0, 0, 204);">,</span> sizeof<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">*</span>f<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;memcpy<span style="color: rgb(0, 0, 204);">(</span>f<span style="color: rgb(0, 0, 204);">,</span> ctrl<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>v4l2<span style="color: rgb(0, 0, 204);">.</span>fmtdesc <span style="color: rgb(0, 0, 204);">+</span> index<span style="color: rgb(0, 0, 204);">,</span> sizeof<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">*</span>f<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;return 0<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span></li></ol></div>从这里看,比较明显是memcpy碰到空指针了。可以有能是f,也有可以是ctrl(即fh).因此可以,这里一f是应用程序传来,如果有问题,在memset处就出错了,因此只可能是ctrl处为空指地,打印一下,发现<br>&nbsp;ctrl-&gt;v4l2.fmtdesc 空指针。因此加入判断语句<br><br>因此修改代码如下<br><div id="codeText" class="codeText"><ol style="margin: 0pt 1px 0pt 0pt; padding: 5px 0pt;" start="1" class="dp-css"><li><span style="color: rgb(0, 0, 0);">static <span style="color: rgb(255, 0, 0);">int</span> s3c_fimc_v4l2_enum_fmt_vid_cap<span style="color: rgb(0, 0, 204);">(</span>struct file <span style="color: rgb(0, 0, 204);">*</span>filp<span style="color: rgb(0, 0, 204);">,</span> void <span style="color: rgb(0, 0, 204);">*</span>fh<span style="color: rgb(0, 0, 204);">,</span><br></span></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct v4l2_fmtdesc <span style="color: rgb(0, 0, 204);">*</span>f<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">{</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;struct s3c_fimc_control <span style="color: rgb(0, 0, 204);">*</span>ctrl <span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(0, 0, 204);">(</span>struct s3c_fimc_control <span style="color: rgb(0, 0, 204);">*</span><span style="color: rgb(0, 0, 204);">)</span> fh<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(255, 0, 0);">int</span> index <span style="color: rgb(0, 0, 204);">=</span> f<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>index<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span>index <span style="color: rgb(0, 0, 204);">&gt;</span><span style="color: rgb(0, 0, 204);">=</span> S3C_FIMC_MAX_CAPTURE_FORMATS<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return <span style="color: rgb(0, 0, 204);">-</span>EINVAL<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;memset<span style="color: rgb(0, 0, 204);">(</span>f<span style="color: rgb(0, 0, 204);">,</span> 0<span style="color: rgb(0, 0, 204);">,</span> sizeof<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">*</span>f<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 204);">(ctrl-&gt;v4l2.fmtdesc&nbsp; == 0</span><span style="color: rgb(0, 0, 255);"></span><span style="color: rgb(0, 0, 204);">)</span> //add by Andrew Huang <br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return <span style="color: rgb(0, 0, 204);">-</span>EINVAL<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;memcpy<span style="color: rgb(0, 0, 204);">(</span>f<span style="color: rgb(0, 0, 204);">,</span> ctrl<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>v4l2<span style="color: rgb(0, 0, 204);">.</span>fmtdesc <span style="color: rgb(0, 0, 204);">+</span> index<span style="color: rgb(0, 0, 204);">,</span> sizeof<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">*</span>f<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;return 0<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span></li></ol></div>修改测试后,果然不出现oops信息,应用程序运行正常.<br>&nbsp;但深层次的原因没有解决,这里是原因是<br>&nbsp;&nbsp; ctrl = (struct s3c_fimc_control *) fh,而<br>&nbsp; fh 是 __video_do_ioctl():void *fh = file-&gt;private_data; <br>&nbsp; 而file-&gt;private_data;初始化在<br>&nbsp;&nbsp; static int s3c_fimc_open(struct inode *inode, struct file *filp)()<br><br>&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; id = MINOR(inode-&gt;i_rdev);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ctrl = &amp;s3c_fimc.ctrl;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; filp-&gt;private_data = ctrl;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;在s3c_fimc.ctrl[].v4l2 的各个指针完全没有初始化。这个当然驱动本身没有完全实现功能。<br>&nbsp; <br>&nbsp;另外一个同样问题是出现在对v4l1的 VIDIOCGPICT支持问题上。<br>&nbsp; 同样没有初始化,出现除0错误.在除0前判断一下。<br>&nbsp; <br><div id="codeText" class="codeText"><ol style="margin: 0pt 1px 0pt 0pt; padding: 5px 0pt;" start="1" class="dp-css"><li><span style="color: rgb(0, 0, 0);">static noinline <span style="color: rgb(255, 0, 0);">int</span> v4l1_compat_get_picture<span style="color: rgb(0, 0, 204);">(</span><br></span></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct video_picture <span style="color: rgb(0, 0, 204);">*</span>pict<span style="color: rgb(0, 0, 204);">,</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct file <span style="color: rgb(0, 0, 204);">*</span>file<span style="color: rgb(0, 0, 204);">,</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v4l2_kioctl drv<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
<span style="color: rgb(0, 0, 204);">{</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(255, 0, 0);">int</span> <span style="color: rgb(255, 0, 0);">err</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;struct v4l2_format <span style="color: rgb(0, 0, 204);">*</span>fmt<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;fmt <span style="color: rgb(0, 0, 204);">=</span> kzalloc<span style="color: rgb(0, 0, 204);">(</span>sizeof<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">*</span>fmt<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">,</span> GFP_KERNEL<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">!</span>fmt<span style="color: rgb(0, 0, 204);">)</span> <span style="color: rgb(0, 0, 204);">{</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(255, 0, 0);">err</span> <span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(0, 0, 204);">-</span>ENOMEM<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return <span style="color: rgb(255, 0, 0);">err</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;pict<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>brightness <span style="color: rgb(0, 0, 204);">=</span> get_v4l_control<span style="color: rgb(0, 0, 204);">(</span>file<span style="color: rgb(0, 0, 204);">,</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   V4L2_CID_BRIGHTNESS<span style="color: rgb(0, 0, 204);">,</span> drv<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;pict<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>hue <span style="color: rgb(0, 0, 204);">=</span> get_v4l_control<span style="color: rgb(0, 0, 204);">(</span>file<span style="color: rgb(0, 0, 204);">,</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    V4L2_CID_HUE<span style="color: rgb(0, 0, 204);">,</span> drv<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;pict<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>contrast <span style="color: rgb(0, 0, 204);">=</span> get_v4l_control<span style="color: rgb(0, 0, 204);">(</span>file<span style="color: rgb(0, 0, 204);">,</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V4L2_CID_CONTRAST<span style="color: rgb(0, 0, 204);">,</span> drv<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;pict<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>colour <span style="color: rgb(0, 0, 204);">=</span> get_v4l_control<span style="color: rgb(0, 0, 204);">(</span>file<span style="color: rgb(0, 0, 204);">,</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       V4L2_CID_SATURATION<span style="color: rgb(0, 0, 204);">,</span> drv<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;pict<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>whiteness <span style="color: rgb(0, 0, 204);">=</span> get_v4l_control<span style="color: rgb(0, 0, 204);">(</span>file<span style="color: rgb(0, 0, 204);">,</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;V4L2_CID_WHITENESS<span style="color: rgb(0, 0, 204);">,</span> drv<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;fmt<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>type <span style="color: rgb(0, 0, 204);">=</span> V4L2_BUF_TYPE_VIDEO_CAPTURE<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(255, 0, 0);">err</span> <span style="color: rgb(0, 0, 204);">=</span> drv<span style="color: rgb(0, 0, 204);">(</span>file<span style="color: rgb(0, 0, 204);">,</span> VIDIOC_G_FMT<span style="color: rgb(0, 0, 204);">,</span> fmt<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(255, 0, 0);">err</span> <span style="color: rgb(0, 0, 204);">&lt;</span> 0<span style="color: rgb(0, 0, 204);">)</span> <span style="color: rgb(0, 0, 204);">{</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 204);"></span>dprintk<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(255, 0, 255);">"VIDIOCGPICT / VIDIOC_G_FMT: %d\n"</span><span style="color: rgb(0, 0, 204);">,</span> <span style="color: rgb(255, 0, 0);">err</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp; <br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto done<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<br></li><li>
&nbsp;&nbsp; <br></li><li>
&nbsp;&nbsp;&nbsp;<u>&nbsp;<b><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 204);">(</span>fmt<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>fmt<span style="color: rgb(0, 0, 204);">.</span>pix<span style="color: rgb(0, 0, 204);">.</span>width <span style="color: rgb(0, 0, 204);">&gt;</span>0<span style="color: rgb(0, 0, 204);">)</span> <span style="color: rgb(0, 0, 204);">/</span><span style="color: rgb(0, 0, 204);">/</span>add by Andrew Huang </b></u><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp; pict<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>depth   <span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">(</span>fmt<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>fmt<span style="color: rgb(0, 0, 204);">.</span>pix<span style="color: rgb(0, 0, 204);">.</span>bytesperline <span style="color: rgb(0, 0, 204);">&lt;</span><span style="color: rgb(0, 0, 204);">&lt;</span> 3<span style="color: rgb(0, 0, 204);">)</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 204);">+</span> <span style="color: rgb(0, 0, 204);">(</span>fmt<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>fmt<span style="color: rgb(0, 0, 204);">.</span>pix<span style="color: rgb(0, 0, 204);">.</span>width <span style="color: rgb(0, 0, 204);">-</span> 1<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">)</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 204);">/</span> fmt<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>fmt<span style="color: rgb(0, 0, 204);">.</span>pix<span style="color: rgb(0, 0, 204);">.</span>width<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;printk<span style="color: rgb(0, 0, 204);">(</span>KERN_WARNING <span style="color: rgb(255, 0, 255);">"hxy %s:02\n"</span><span style="color: rgb(0, 0, 204);">,</span>__func__<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;<br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;pict<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>palette <span style="color: rgb(0, 0, 204);">=</span> pixelformat_to_palette<span style="color: rgb(0, 0, 204);">(</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fmt<span style="color: rgb(0, 0, 204);">-</span><span style="color: rgb(0, 0, 204);">&gt;</span>fmt<span style="color: rgb(0, 0, 204);">.</span>pix<span style="color: rgb(0, 0, 204);">.</span>pixelformat<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
done<span style="color: rgb(0, 0, 204);">:</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;kfree<span style="color: rgb(0, 0, 204);">(</span>fmt<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
&nbsp;&nbsp;&nbsp;&nbsp;return <span style="color: rgb(255, 0, 0);">err</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span></li></ol></div><br><br><font size="5">3.oops进一步处理</font><br><br>&nbsp; 如果需要进一步处理,可以用dmesg 把原始的oops导入到一个文本文件当中,用应用程序工具 ksymoops 来操作.但一般这个对桌面版的LINUX比较有效<br><br>&nbsp;&nbsp; ksymoops 需要几项内容:Oops 消息输出、来自正在运行的内核的 System.map 文件,还有 /proc/ksyms、vmlinux 和 /proc/modules。关于如何使用 ksymoops,内核源代码 /usr/src/linux/Documentation/oops-tracing.txt 中或 ksymoops 手册页上有完整的说明可以参考。Ksymoops 反汇编代码部分,指出发生错误的指令,并显示一个跟踪部分表明代码如何被调用。<br><br><font size="5">4.扩展阅读:</font><br><br>&nbsp; &lt;&lt;掌握 Linux 调试技术 -- 在 Linux 上找出并解决程序错误的主要方法&gt;&gt;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http://www.ibm.com/developerworks/cn/linux/sdk/l-debug/index.html<br><br>&nbsp; <br><br><br><br><br><br>&nbsp;<br>

wangfeifeiwc 发表于 2013-01-01 10:15

楼主在 "oops进一步处理" 提到可以使用 Ksymoops用来分析 oops
不过在 http://www.mjmwired.net/kernel/Documentation/oops-tracing.txt
有提到 2.6 上最好不要使用 Ksymoops。
"
NOTE: ksymoops is useless on 2.6.Please use the Oops in its original format
(from dmesg, etc).Ignore any references in this or other docs to "decoding
the Oops" or "running it through ksymoops".If you post an Oops from 2.6 that
has been run through ksymoops, people will just tell you to repost it.
"
不知道linux 3.0下,还可以使用Ksymoops吗?       
页: [1]
查看完整版本: Linux oops信息的分析