GDB: Lessfs; How to Trace

China☆狼群 提交于 2020-01-15 20:11:45

问题


I am trying to trace this open source program called lessfs: and inline data deduplication filesystem for linux, but I am having trouble stepping through step by step using GDB

Lessfs can be found here: http://www.lessfs.com/wordpress/

Are there any other tools recommended for tracing large open source programs as such? The source code is about 3,000 lines with multiple files, and I understand which part of the files I would be working on, but it would be great if there were a program that showed me step by step, which methods are being called and such, just as GDB does

Currently, I having complications on how to actually implement this:

Since I am not really running a simple C file into GDB, but rather a group of large C files, I am a little lost on how to properly run GDB knowing there are multiple files

Here are the commands that I am using regularly, which can be found here in this tutorial:

http://www.linuxjournal.com/content/data-deduplication-linux

Regular commands (without GDB)

sudo cp etc/lessfs.cfg /etc/

sudo mkdir -p /data/{dta,mta}

///** Above are pre requisites **///

///** To start lessfs **///

./lessfs

sudo mklessfs -c /etc/lessfs.cfg

sudo lessfs /etc/lessfs.cfg /mnt

///** Testing **///

df -t fuse.lessfs

ls -a /mnt/

sudo r dd if=/dev/zero of=/mnt/test.dat bs=1M count=100

df -t fuse.lessfs

///** Using GDB **///

Now running with GDB (I have found an idea here: https://groups.google.com/forum/#!msg/lessfs/dkXDckXYnqw/ns5NpDegL_YJ)

gdb ./lessfs

set args /etc/lessfs.cfg /fuse -d -o\ hard_remove,negative_timeout=0,entry_timeout=0,attr_timeout=0,use_ino,readdir_ino,default_permissions,allow_other,big_writes,max_read=131072,max_write=131072

(Running it, am I doing it properly??)

(gdb) r mklessfs /etc/lessfs.cfg
Starting program: /home/hb2/lessfs/lessfs1/lessfs mklessfs /etc/lessfs.cfg
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Inferior 1 (process 3621) exited with code 0377]


(gdb) r lessfs /etc/lessfs.cfg /mnt
Starting program: /home/hb2/lessfs/lessfs1/lessfs lessfs /etc/lessfs.cfg /mnt
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Inferior 1 (process 3633) exited with code 0377]


(gdb) r df -t fuse.lessfs
Starting program: /home/hb2/lessfs/lessfs1/lessfs df -t fuse.lessfs
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGUSR1, User defined signal 1.
0x00007ffff7386707 in kill () from /lib/x86_64-linux-gnu/libc.so.6


(gdb) r dd if=/dev/zero of=/mnt/test.dat bs=1M count=100
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/hb2/lessfs/lessfs1/lessfs dd if=/dev/zero of=/mnt/test.dat bs=1M count=100
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGUSR1, User defined signal 1.
0x00007ffff7386707 in kill () from /lib/x86_64-linux-gnu/libc.so.6


(gdb) next
Single stepping until exit from function kill,
which has no line number information.

Program terminated with signal SIGUSR1, User defined signal 1.
The program no longer exists.
(gdb) 

What I really want to do, is have some print statements in the file lib_commons.c and print some data out from there, but how do I do that when there are so many files combined in this open source program?

Thank you for your time,

来源:https://stackoverflow.com/questions/24640838/gdb-lessfs-how-to-trace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!