Skip to main content

When strace is not enough

I’ve got START_VIDEO working, I got the colorspace converted, I emulated all ioctls() ezx camera is sending and even got the picture. But it looks like the mmaped area is read before or after the synchronization happens.

The first time I read the image after camera app finishes it comes pretty good, all subsequent attempts result in a broken image. So I decided to dig more into the data camera app passes through ioctl.

I found just what I needed: Using LD_PRELOAD libraries and glibc backtrace function for debugging by Scary Reasoner. This will allow not only camera app to be investigated but… mmm… much, much more. BTW, read() on camera interface usually gives you a random piece of memory, so use mmap()ed region instead.

Update: Here is the promised trace:

# LD_PRELOAD=./libwrapioctl.so.1.0 /usr/SYSqtapp/camera/camera
ioctl : wrapping ioctl
next_ioctl = 0x4112b480
ioctl: wrapping done
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
ioctl WCAM_VIDIOCSINFOR: { val1=15, val2=16 }
ioctl WCAM_VIDIOCSBUFCOUNT: 4
ioctl WCAM_VIDIOCSFLICKER: 50
ioctl WCAM_VIDIOCSFPS: { minfps=30, maxfps=30 }
ioctl WCAM_VIDIOCSMIRROR: 0
ioctl WCAM_VIDIOCSNIGHTMODE: 0
ioctl WCAM_VIDIOCSBRIGHT: 0
ioctl WCAM_VIDIOCSLIGHT: 0
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
ioctl WCAM_VIDIOCSSTYLE: 0
QLinuxFbDoubleScreen::flip() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::flip() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
ioctl WCAM_VIDIOCSJPEGQUALITY: 6
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x42525f58, flags=0x44960000 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl WCAM_VIDIOCSBRIGHT: 1
ioctl WCAM_VIDIOCSBRIGHT: 2
ioctl WCAM_VIDIOCSBRIGHT: 3
ioctl WCAM_VIDIOCSBRIGHT: 4
ioctl WCAM_VIDIOCSBRIGHT: 3
ioctl WCAM_VIDIOCSBRIGHT: 2
ioctl WCAM_VIDIOCSBRIGHT: 1
ioctl WCAM_VIDIOCSBRIGHT: 0
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 358
ioctl WCAM_VIDIOCSSZOOM: 358
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 512
ioctl WCAM_VIDIOCSSZOOM: 512
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 717
ioctl WCAM_VIDIOCSSZOOM: 717
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=572, h=430 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 1024
ioctl WCAM_VIDIOCSSZOOM: 1024
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=400, h=300 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 1280
ioctl WCAM_VIDIOCSSZOOM: 1434
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=286, h=214 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 1280
ioctl WCAM_VIDIOCSSZOOM: 2048
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=200, h=150 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 1280
ioctl WCAM_VIDIOCSSZOOM: 1434
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=286, h=214 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 1024
ioctl WCAM_VIDIOCSSZOOM: 1024
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=400, h=300 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 717
ioctl WCAM_VIDIOCSSZOOM: 717
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=572, h=430 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 512
ioctl WCAM_VIDIOCSSZOOM: 512
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x64000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 358
ioctl WCAM_VIDIOCSSZOOM: 358
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x44960000, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
QLinuxFbDoubleScreen::flip() called, but flipping disabled
QLinuxFbDoubleScreen::redirectQtToBack() called, but flipping disabled
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=180, height=240,
chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=900, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=180, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=1600, h=1200 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=1024, h=768 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=1600, h=1200 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=1024, h=768 }
ioctl VIDIOCSWIN: {  x=0x107, y=0x40002118, width=320, height=240, chromakey=0xd9, clipcount=0x40002234, flags=0x400021c8 }
ioctl WCAM_VIDIOCSSSIZE: { w=1600, h=1200 }
ioctl WCAM_VIDIOCSZOOM: 256
ioctl WCAM_VIDIOCSSZOOM: 256
ioctl WCAM_VIDIOCSOSIZE: { w=320, h=240 }
ioctl WCAM_VIDIOCSCSIZE: { w=640, h=480 }
ioctl WCAM_VIDIOCSNIGHTMODE: 1
ioctl WCAM_VIDIOCSNIGHTMODE: 0
ioctl WCAM_VIDIOCSSTYLE: 1
ioctl WCAM_VIDIOCSSTYLE: 2
ioctl WCAM_VIDIOCSSTYLE: 3
ioctl WCAM_VIDIOCSSTYLE: 4
ioctl WCAM_VIDIOCSSTYLE: 0
ioctl WCAM_VIDIOCSLIGHT: 1
ioctl WCAM_VIDIOCSLIGHT: 2
ioctl WCAM_VIDIOCSLIGHT: 3
ioctl WCAM_VIDIOCSLIGHT: 0
destroy ShareImage Object
UTIL_ShareImage::destroy()
UTIL_ShareImage::destroy() : data detched

Time to sleep…