robertknight / Qt-Inspector

Utility to browse the Qt object tree of a running Qt application and edit object properties on the fly.
GNU Lesser General Public License v3.0
401 stars 70 forks source link

./qtinspector pid can not work #5

Open watertoeast opened 9 years ago

watertoeast commented 9 years ago

gdb.log info: &"call dlopen(\"/home/kkk/fk/Qt-Inspector-master/lib/libQtInspector.so\",2)\n" ~"\nProgram received signal " ~"SIGSEGV, Segmentation fault.\n" ~"0x00000002 in ?? ()\n"

shell output: Local socket state changed QLocalSocket::ConnectingState Local socket reported error QLocalSocket::ServerNotFoundError Local socket state changed QLocalSocket::UnconnectedState Failed to connect to local socket server in target process 6656 Failed to inject helper library into process Failed to send top-level widget request fetch to child process

How to fix it?

robertknight commented 9 years ago

You need to find out why the program is crashing when trying to call dlopen(). In GdbLibraryInjector.cpp, it might be helpful to tell gdb to print a backtrace after executing call dlopen(...).

Change this:

QString flag_RTLD_NOW = QString::number(RTLD_NOW);
gdbStream << "call dlopen(\"" << fullLibraryPath << "\"," << flag_RTLD_NOW << ")\n";

To

QString flag_RTLD_NOW = QString::number(RTLD_NOW);
gdbStream << "call dlopen(\"" << fullLibraryPath << "\"," << flag_RTLD_NOW << ")\n";
gdbStream << "backtrace\n";

And let me know what output you get in gdb.log

watertoeast commented 9 years ago

uname -a info: Linux centos66 2.6.32-504.el6.i686 #1 SMP Wed Oct 15 03:02:07 UTC 2014 i686 i686 i386 GNU/Linux traceback info: (gdb) &"call dlopen(\"/home/kkk/fk/Qt-Inspector/lib/libQtInspector.so\",2)\n" ~"\nProgram received signal " ~"SIGSEGV, Segmentation fault.\n" ~"0x00000000 in ?? ()\n" &"The program being debugged was signaled while in a function called from GDB.\n" &"GDB has restored the context to what it was before the call.\n" &"To change this behavior use \"set unwindonsignal off\".\n" &"Evaluation of the expression containing the function\n" &"(dlopen@plt) will be abandoned.\n" ^error,msg="The program being debugged was signaled while in a function called from GDB.\nGDB has restored the context to what it was before the call.\nTo change this behavior use \"set unwindonsignal off\".\nEvaluation of the expression containing the function\n(dlopen@plt) will be abandoned." (gdb) &"backtrace\n" ~"#0 0x002d8424 in __kernel_vsyscall ()\n" ~"#1 0x00ce5c0b in poll () from /lib/libc.so.6\n" ~"#2 0x0017d3bc in ?? () from /lib/libglib-2.0.so.0\n" ~"#3 0x0016fb44 in ?? () from /lib/libglib-2.0.so.0\n" ~"#4 0x0016ff49 in ?? () from /lib/libglib-2.0.so.0\n" ~"#5 0x008c0be6 in ?? () from /usr/lib/libQtCore.so.4\n" ~"#6 0x036f2f86 in ?? () from /usr/lib/libQtGui.so.4\n" ~"#7 0x008971da in ?? () from /usr/lib/libQtCore.so.4\n" ~"#8 0x0089751a in ?? () from /usr/lib/libQtCore.so.4\n" ~"#9 0x00899be7 in ?? () from /usr/lib/libQtCore.so.4\n" ~"#10 0x03644e88 in ?? () from /usr/lib/libQtGui.so.4\n" ~"#11 0x08048884 in main (argc=1, argv=0xbfd61644) at main.cpp:12\n" ^done (gdb)

robertknight commented 9 years ago

That stacktrace is missing useful information unfortunately because as GDB's output says, it put the program back into the state it was in before the crash happened. Can you try adding the 'set unwindonsignal off' command before the 'call dlopen(...)' command as it suggests:

gdbStream << "set unwindonsignal off\n";
gdbStream << "call dlopen(\"" << fullLibraryPath << "\"," << flag_RTLD_NOW << ")\n";
gdbStream << "backtrace\n";
watertoeast commented 9 years ago

after add gdbStream << "set unwindonsignal off\n"; the output: (gdb) &"sharedlibrary libdl\n" ~"Reading symbols from /lib/libdl.so.2..." ~"(no debugging symbols found)...done.\n" ~"Loaded symbols for /lib/libdl.so.2\n" ^done (gdb) &"set unwindonsignal off\n" ^done (gdb) &"call dlopen(\"/home/kkk/fk/Qt-Inspector/lib/libQtInspector.so\",2)\n" ~"\nProgram received signal " ~"SIGSEGV, Segmentation fault.\n" ~"0x00000000 in ?? ()\n" &"The program being debugged was signaled while in a function called from GDB.\n" &"GDB remains in the frame where the signal was received.\n" &"To change this behavior use \"set unwindonsignal on\".\n" &"Evaluation of the expression containing the function\n" &"(dlopen@plt) will be abandoned.\n" &"When the function is done executing, GDB will silently stop.\n" ^error,msg="The program being debugged was signaled while in a function called from GDB.\nGDB remains in the frame where the signal was received.\nTo change this behavior use \"set unwindonsignal on\".\nEvaluation of the expression containing the function\n(dlopen@plt) will be abandoned.\nWhen the function is done executing, GDB will silently stop." (gdb) &"backtrace\n" ~"#0 0x00000000 in ?? ()\n" ~"#1 \n" ~"#2 0x008de424 in __kernel_vsyscall ()\n" ~"#3 0x00ce5c0b in poll () from /lib/libc.so.6\n" ~"#4 0x004a83bc in ?? () from /lib/libglib-2.0.so.0\n" ~"#5 0x0049ab44 in ?? () from /lib/libglib-2.0.so.0\n" ~"#6 0x0049af49 in ?? () from /lib/libglib-2.0.so.0\n" ~"#7 0x00369be6 in ?? () from /usr/lib/libQtCore.so.4\n" ~"#8 0x036f2f86 in ?? () from /usr/lib/libQtGui.so.4\n" ~"#9 0x003401da in ?? () from /usr/lib/libQtCore.so.4\n" ~"#10 0x0034051a in ?? () from /usr/lib/libQtCore.so.4\n" ~"#11 0x00342be7 in ?? () from /usr/lib/libQtCore.so.4\n" ~"#12 0x03644e88 in ?? () from /usr/lib/libQtGui.so.4\n" ~"#13 0x08048884 in main (argc=1, argv=0xbfa2a7a4) at main.cpp:12\n" ^done (gdb) &"print ((char*)(dlerror()))\n" ~"$1 = 0x0\n" ^done (gdb) &"sharedlibrary /home/kkk/fk/Qt-Inspector/lib/libQtInspector.so\n" ~"No loaded shared libraries match the pattern `/home/kkk/fk/Qt-Inspector/lib/libQtInspector.so'.\n" ^done (gdb) &"call qtInspectorInit()\n" &"No symbol \"qtInspectorInit\" in current context.\n" ^error,msg="No symbol \"qtInspectorInit\" in current context." (gdb) &"detach\n" ~"Detaching from program: /home/kkk/\346\241\214\351\235\242/qthello/qthello, process 17943\n" =thread-group-exited,id="i1" =library-unloaded,id="/usr/lib/libQtGui.so.4",target-name="/usr/lib/libQtGui.so.4",host-name="/usr/lib/libQtGui.so.4",thread-group="i1" =library-unloaded,id="/usr/lib/libQtCore.so.4",target-name="/usr/lib/libQtCore.so.4",host-name="/usr/lib/libQtCore.so.4",thread-group="i1" =library-unloaded,id="/lib/libpthread.so.0",target-name="/lib/libpthread.so.0",host-name="/lib/libpthread.so.0",thread-group="i1"

robertknight commented 9 years ago

~"Detaching from program: /home/kkk/\346\241\214\351\235\242/qthello/qthello, process 17943\n

Ah, that's interesting. What is the full path to the 'qthello' program? There might be an issue with handling of non-ASCII characters.

Can you also install the QtCore debugging libraries (typically in an Apt package such as libqt4-dbg) and repeat the steps above. That will give more info in the backtrace.

Also, to repeat what I said earlier, you don't need to email me manually when you reply to the bug report. GitHub sends me notification emails automatically.

watertoeast commented 9 years ago

I move qthello to non-ASCII path, but the output is just same as before. And I try to install the libqt4-dbg by yum install libqt4-dbg, but there is no this package.