solib-absolute-prefix 和solib-search-path的区别
2015-04-28 14:48
344 查看
solib-absolute-prefix 和solib-search-path是 gdb比较常用的选项,用来设置符号文件的位置。
那么,它们有什么区别呢?
solib-absolute-prefix设置的是被搜索文件路径的前缀,solib-search-path设置的是被搜索文件的路径。
solib-search-path可以有多个路径,中间按用:隔开, solib-absolute-prefix的值只能有一个。
下面以一个例子说明。
先载入一个 core dump文件:
先执行下 info sharedlibrary:
有两个动态库还没有载入。
假设当前目录下有文件 libshared.so, 可以执行下面的命令:
再看下动态库的加载情况:
还有一个没有载入。
假设文件 libc.so.6在 /media/DATA/lib/libc.so.6下:
这时,可以用 solib-absolute-path。
这时,gdb用前缀 /media/DATA + /lib/libc.so.6,就找到了文件。
/lib 是可执行文件在 目标机上 link libc.so.6的位置。
那么,它们有什么区别呢?
solib-absolute-prefix设置的是被搜索文件路径的前缀,solib-search-path设置的是被搜索文件的路径。
solib-search-path可以有多个路径,中间按用:隔开, solib-absolute-prefix的值只能有一个。
下面以一个例子说明。
先载入一个 core dump文件:
[plain] view plaincopyprint? (gdb) core-file core [New LWP 489] warning: Could not load shared library symbols for 2 libraries, e.g. /mnt/libshared.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? Core was generated by `./main'. Program terminated with signal 11, Segmentation fault. #0 0x2ac02508 in ?? ()
先执行下 info sharedlibrary:
[plain] view plaincopyprint? (gdb) info sharedlibrary From To Syms Read Shared Object Library No /mnt/libshared.so No /lib/libc.so.6 0x2ab417e0 0x2ab52bf0 Yes (*) /home/charles/code/gcc-arm-2012.04-linux/arm-linux-gnueabi/libc/lib/ld-linux.so.3 (*): Shared library is missing debugging information.
有两个动态库还没有载入。
假设当前目录下有文件 libshared.so, 可以执行下面的命令:
[plain] view plaincopyprint? (gdb) set solib-search-path . Reading symbols from /home/charles/libshared.so...done. Loaded symbols for /home/charles/libshared.so
再看下动态库的加载情况:
[plain] view plaincopyprint? (gdb) info sharedlibrary From To Syms Read Shared Object Library 0x2ac0240c 0x2ac02510 Yes /home/charles/libshared.so No /lib/libc.so.6 0x2ab417e0 0x2ab52bf0 Yes (*) /home/charles/code/gcc-arm-2012.04-linux/arm-linux-gnueabi/libc/lib/ld-linux.so.3 (*): Shared library is missing debugging information.
还有一个没有载入。
假设文件 libc.so.6在 /media/DATA/lib/libc.so.6下:
[plain] view plaincopyprint? ~$ ls /media/DATA/lib/ -l total 860 -rw------- 1 charles charles 876656 Nov 18 03:56 libc.so.6
这时,可以用 solib-absolute-path。
[plain] view plaincopyprint? (gdb) set solib-absolute-prefix /media/DATA Reading symbols from /media/DATA/lib/libc.so.6...(no debugging symbols found)...done. Loaded symbols for /media/DATA/lib/libc.so.6
这时,gdb用前缀 /media/DATA + /lib/libc.so.6,就找到了文件。
/lib 是可执行文件在 目标机上 link libc.so.6的位置。
[plain] view plaincopyprint? (gdb) bt full #0 0x2ac02508 in fun () at testsharedlib.c:3 No locals. #1 0x00008570 in main () at main.c:6 No locals. (gdb) l *0x2ac02508 0x2ac02508 is in fun (testsharedlib.c:3). 1 void fun(void) 2 { 3 *(int *)0 = 0; 4 }
相关文章推荐
- solib-absolute-prefix 和solib-search-path的区别
- solib-absolute-prefix 和solib-search-path的区别
- solib-absolute-prefix 和solib-search-path的区别
- solib-absolute-prefix 和solib-search-path的区别
- GDB: solib-absolute-prefix vs. solib-search-path
- java中File类的getPath(),getAbsolutePath(),getCanonicalPath()区别
- getPath(),getAbsolutePath(),getCanonicalPath()区别
- java.io.File 中 getPath(), getAbsolutePath() 和 getCanonicalPath() 三个方法的区别
- java.io.File 中 getPath(), getAbsolutePath() 和 getCanonicalPath() 三个方法的区别
- java.io.File 中 getPath(), getAbsolutePath() 和 getCanonicalPath() 三个方法的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- java里getPath、 getAbsolutePath、getCanonicalPath的区别
- getPath getAbsolutePath和getCanonicalPath的区别
- Java中file类getPath(),getAbsolutePath(),getCanonicalPath()方法区别
- java中File类的getPath(),getAbsolutePath(),getCanonicalPath()区别
- java文件操作getAbsolutePath和getCanonicalPath的区别
- java中File类的getPath(),getAbsolutePath(),getCanonicalPath()区别
- File的getPath(),getAbsolutePath(),getCanonicalPath()区别
- file.getPath() getAbsolutePath() getCanonicalPath()区别
- FilePath类的getPath(),getAbsolutePath(),getCanonicalPath的区别