ChrisZim / edb-debugger

Automatically exported from code.google.com/p/edb-debugger
GNU General Public License v2.0
0 stars 0 forks source link

Build fails on Freebsd 8.0-release #67

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
g++ -c -pipe -fvisibility=hidden -ansi -pedantic -W -Wall -Wno-long-long -O2 
-Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED 
-I/usr/local/share/qt4/mkspecs/freebsd-g++ -I. -I/usr/local/include/qt4/QtCore 
-I/usr/local/include/qt4/QtGui -I/usr/local/include/qt4 -Iwidgets -I../include 
-Ios/unix -I../include/os/unix -Iarch/i386 -I../include/arch/i386 
-I../include/arch/i386/edisassm -I. -I. -I/usr/local/include -o DialogAttach.o 
os/unix/DialogAttach.cpp
os/unix/DialogAttach.cpp: In member function 'void 
DialogAttach::updateList(const QString&)':
os/unix/DialogAttach.cpp:120: error: '_PATH_DEVNULL' was not declared in this 
scope
os/unix/DialogAttach.cpp:120: error: 'O_RDONLY' was not declared in this scope
os/unix/DialogAttach.cpp:122: error: 'KERN_PROC_ALL' was not declared in this 
scope
os/unix/DialogAttach.cpp:126: error: invalid use of incomplete type 'struct 
kinfo_proc'
/usr/include/kvm.h:56: error: forward declaration of 'struct kinfo_proc'
os/unix/DialogAttach.cpp:126: error: base operand of '->' has non-pointer type 
'kinfo_proc'
os/unix/DialogAttach.cpp:127: error: invalid use of incomplete type 'struct 
kinfo_proc'
/usr/include/kvm.h:56: error: forward declaration of 'struct kinfo_proc'
os/unix/DialogAttach.cpp:127: error: base operand of '->' has non-pointer type 
'kinfo_proc'
os/unix/DialogAttach.cpp:128: error: invalid use of incomplete type 'struct 
kinfo_proc'
/usr/include/kvm.h:56: error: forward declaration of 'struct kinfo_proc'
os/unix/DialogAttach.cpp:128: error: base operand of '->' has non-pointer type 
'kinfo_proc'
*** Error code 1

Original issue reported on code.google.com by evan.teran on 3 Oct 2012 at 3:21

GoogleCodeExporter commented 9 years ago
Yea, the *BSD ports are very much a work in progress. I actually have made a 
lot of progress with the OpenBSD port lately (it doesn't quite debug yet, but 
it builds which is a huge improvement).

Thank you for the bug report, hopefully I'll be able to get the FreeBSD and 
OpenBSD (which should help with the OSX ports as well) ports up and running 
sometime soon.

Original comment by evan.teran on 3 Oct 2012 at 4:34

GoogleCodeExporter commented 9 years ago
Great to hear its a work in progress. The BSD platform is devoid of a nice 
binary based debugger.

Original comment by evan.teran on 3 Oct 2012 at 4:34

GoogleCodeExporter commented 9 years ago
After few fixes i've managed to build edb 0.9.13 on FREEBSD-8-STABLE, but got 
this at runtime:

arr: ~/debugger> ./edb
Starting EDB Version: 0.9.13 
Please Report Bugs & Requests At: http://bugs.codef00.com/
[loadPlugins] Cannot load library /usr/home/arr/debugger/libAnalyzer.so: 
(/usr/home/arr/debugger/libAnalyzer.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")                                
[loadPlugins] Cannot load library /usr/home/arr/debugger/libBinarySearcher.so: 
(/usr/home/arr/debugger/libBinarySearcher.so: Undefined symbol "_ZTV9MemRegion")
[loadPlugins] Cannot load library /usr/home/arr/debugger/libBookmarks.so: 
(/usr/home/arr/debugger/libBookmarks.so: Undefined symbol 
"_ZN3edb2v18getDWORDEyRbR15ExpressionErrorPv")
[loadPlugins] Cannot load library 
/usr/home/arr/debugger/libBreakpointManager.so: 
(/usr/home/arr/debugger/libBreakpointManager.so: Undefined symbol 
"_ZN3edb2v18getDWORDEyRbR15ExpressionErrorPv")
[loadPlugins] Loading Plugin: libCheckVersion.so             : 0x803bcde50
[loadPlugins] Plugin verification data mismatch in 
'/usr/home/arr/debugger/libDebuggerCore.so'
[loadPlugins] Cannot load library /usr/home/arr/debugger/libDumpState.so: 
(/usr/home/arr/debugger/libDumpState.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")
[loadPlugins] Cannot load library /usr/home/arr/debugger/libELFBinaryInfo.so: 
(/usr/home/arr/debugger/libELFBinaryInfo.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")
[loadPlugins] Cannot load library /usr/home/arr/debugger/libEnvironment.so: 
(/usr/home/arr/debugger/libEnvironment.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")
[loadPlugins] Loading Plugin: libFunctionDB.so               : 0x803b7aa80
[loadPlugins] Cannot load library /usr/home/arr/debugger/libFunctionFinder.so: 
(/usr/home/arr/debugger/libFunctionFinder.so: Undefined symbol "_ZTV9MemRegion")
[loadPlugins] Cannot load library 
/usr/home/arr/debugger/libHardwareBreakpoints.so: 
(/usr/home/arr/debugger/libHardwareBreakpoints.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")
[loadPlugins] Cannot load library /usr/home/arr/debugger/libHeapAnalyzer.so: 
(/usr/home/arr/debugger/libHeapAnalyzer.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")
[loadPlugins] Cannot load library /usr/home/arr/debugger/libOpcodeSearcher.so: 
(/usr/home/arr/debugger/libOpcodeSearcher.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")
[loadPlugins] Cannot load library /usr/home/arr/debugger/libReferences.so: 
(/usr/home/arr/debugger/libReferences.so: Undefined symbol 
"_ZN3edb2v112debuggerBaseE")
[loadPlugins] Loading Plugin: libSessionManager.so           : 0x803b7ca20
[loadPlugins] Cannot load library /usr/home/arr/debugger/libStringSearcher.so: 
(/usr/home/arr/debugger/libStringSearcher.so: Undefined symbol 
"_ZN3edb2v110debuggerUIE")
[loadPlugins] Cannot load library /usr/home/arr/debugger/libSymbolViewer.so: 
(/usr/home/arr/debugger/libSymbolViewer.so: Undefined symbol 
"_ZN3edb2v110debuggerUIE")
/libexec/ld-elf.so.1: /usr/home/arr/debugger/libFunctionDB.so: Undefined symbol 
"_ZN3edb2v113setFunctionDBEP10FunctionDB"</thetext>

Original comment by evan.teran on 3 Oct 2012 at 4:35

GoogleCodeExporter commented 9 years ago
For unix and related OSes there is often a flag to enable shared libs seeing 
symbols in the application that loads them. This is almost certainly the issue.

For OpenBSD it is "-Wl,--export-dynamic"
For Linux it is "-rdynamic"

I would guess that the OpenBSD flags would work for FreeBSD too.

Could you please send me a patch so I can include your fixes? I am fairly close 
to doing my next release, it would be wonderful if I could get things just one 
step closer to working on other platforms besides Linux ;).

Original comment by evan.teran on 3 Oct 2012 at 4:35

GoogleCodeExporter commented 9 years ago
Ok, in os/unix/freebsd/DialogAttach.cpp i made following changes:

line
#include <kvm.h>
replaced with
#include <fcntl.h>
#include <kvm.h>

#include <paths.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>

then at line 64
procInfo.pid    = kprocaccess[i]->ki_pid;
procInfo.uid    = kprocaccess[i]->ki_uid;
procInfo.name   = kprocaccess[i]->ki_comm;

changed to

procInfo.pid    = (kprocaccess+i)->ki_pid;
procInfo.uid    = (kprocaccess+i)->ki_uid;
procInfo.name   = (kprocaccess+i)->ki_comm;

because kprocaccess is struct kinfo_proc pointer, not array.

Then, in os/unix/freebsd/MemRegion.cpp i removed #include "SmartPointer.h", 
because it was not found.

After that i tried to pass this flags you told me, but since im not familiar 
with qt at all, i just did
gmake CXXFLAGS="-Wl,--export-dynamic -fPIC" CFLAGS="-Wl,--export-dynamic -fPIC"

I've added -fPIC because of linker complaining about it at link stage.

Finally running edb gave me this:
Starting EDB Version: 0.9.13
Please Report Bugs & Requests At: http://bugs.codef00.com/
[loadPlugins] Loading Plugin: libAnalyzer.so                 : 0x803bc9580
[loadPlugins] Loading Plugin: libBinarySearcher.so           : 0x803b7aa60
[loadPlugins] Loading Plugin: libBookmarks.so                : 0x803bcb470
[loadPlugins] Loading Plugin: libBreakpointManager.so        : 0x803bfdeb0
[loadPlugins] Loading Plugin: libCheckVersion.so             : 0x803bcd070
[loadPlugins] Plugin verification data mismatch in 
'/usr/home/arr/debugger/libDebuggerCore.so'
[loadPlugins] Loading Plugin: libDumpState.so                : 0x803b7ac20
[loadPlugins] Loading Plugin: libELFBinaryInfo.so            : 0x803b7ac80
[loadPlugins] Loading Plugin: libEnvironment.so              : 0x803bcd430
[loadPlugins] Loading Plugin: libFunctionDB.so               : 0x803b7ae00
[loadPlugins] Loading Plugin: libFunctionFinder.so           : 0x803bcd580
[loadPlugins] Loading Plugin: libHardwareBreakpoints.so      : 0x80992c140
[loadPlugins] Loading Plugin: libHeapAnalyzer.so             : 0x803bcd640
[loadPlugins] Loading Plugin: libOpcodeSearcher.so           : 0x803bcd6d0
[loadPlugins] Loading Plugin: libReferences.so               : 0x803bcd760
[loadPlugins] Loading Plugin: libSessionManager.so           : 0x803b7cd80
[loadPlugins] Loading Plugin: libStringSearcher.so           : 0x803bcd850
[loadPlugins] Loading Plugin: libSymbolViewer.so             : 0x803bcd910
[loadPlugins] The file '/usr/home/arr/debugger/libDebuggerCore.so' is not a 
valid Qt plugin.
/libexec/ld-elf.so.1: /usr/home/arr/debugger/libAnalyzer.so: Undefined symbol 
"_ZN3edb2v111setAnalyzerEP17AnalyzerInterface"</thetext>

Original comment by evan.teran on 3 Oct 2012 at 4:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Definitely getting closer to a functional version :-).

I've made the changes you suggested. I imagine that (kprocaccess+i)->ki_pid; 
could just as easily be kprocaccess[i].->ki_pid; But same difference.

Anyway, at some point I'll setup a freebsd VM and see if I can get the 
finishing touches in there.

Thanks!

Original comment by evan.teran on 3 Oct 2012 at 4:37

GoogleCodeExporter commented 9 years ago
Hello, how it's going? Can't wait to see working version on FreeBSD.

Original comment by evan.teran on 3 Oct 2012 at 4:37

GoogleCodeExporter commented 9 years ago
I've had a little lull in development, but things are moving along. I too would 
love to add the BSD family to the list of official supported OSes :-).

(In reply to comment #7)
> Hello, how it's going? Can't wait to see working version on FreeBSD.

Original comment by evan.teran on 3 Oct 2012 at 4:37

GoogleCodeExporter commented 9 years ago
Hello!

I created FreeBSD port for edb:
http://aldis.git.bsdroot.lv/devel/edb/

I marked it BROKE, because currently it doesn't work
Also I haven't send pr to FreeBSD to create new port

dekstop.pc $ edb                                                               
Starting EDB Version: 0.9.15 
Please Report Bugs & Requests At: http://bugs.codef00.com/
[loadPlugins] Loading Plugin: libAnalyzer.so                 : 0x29c3a940
[loadPlugins] Loading Plugin: libBinarySearcher.so           : 0x29c39720
[loadPlugins] Loading Plugin: libBookmarks.so                : 0x29c38d60
[loadPlugins] Loading Plugin: libBreakpointManager.so        : 0x29c3aae0
[loadPlugins] Loading Plugin: libCheckVersion.so             : 0x29c3aba0
[loadPlugins] The file '/usr/local/lib/edb/libDebuggerCore.so' is not a valid 
Qt plugin. 
[loadPlugins] Loading Plugin: libDumpState.so                : 0x29c39800
[loadPlugins] Loading Plugin: libELFBinaryInfo.so            : 0x29c39830
[loadPlugins] Loading Plugin: libEnvironment.so              : 0x297d1da0
[loadPlugins] Loading Plugin: libFunctionDB.so               : 0x29c39790
[loadPlugins] Loading Plugin: libFunctionFinder.so           : 0x29c3adc0
[loadPlugins] Loading Plugin: libHardwareBreakpoints.so      : 0x29c3ae80
[loadPlugins] Loading Plugin: libHeapAnalyzer.so             : 0x29c3af40
[loadPlugins] Loading Plugin: libOpcodeSearcher.so           : 0x29c3c300
[loadPlugins] Loading Plugin: libReferences.so               : 0x29c3c360
[loadPlugins] Loading Plugin: libSessionManager.so           : 0x29c39940
[loadPlugins] Loading Plugin: libStringSearcher.so           : 0x29c3c3c0
[loadPlugins] Loading Plugin: libSymbolViewer.so             : 0x29c43080
[Function Database] loaded with 103 function definitions. 

I hope that we will get working FreeBSD version soon :D

Original comment by evan.teran on 3 Oct 2012 at 4:38

GoogleCodeExporter commented 9 years ago
Last build was with some bad patched...

here's error, of current build

[loadPlugins] Plugin verification data mismatch in 
'/usr/local/lib/edb/libDebuggerCore.so'

Original comment by evan.teran on 3 Oct 2012 at 4:38

GoogleCodeExporter commented 9 years ago
van, it looks you don't have much time to work on edb. How about opening its 
source?

Original comment by evan.teran on 3 Oct 2012 at 4:38

GoogleCodeExporter commented 9 years ago
@arrowdodger: edb is open source :-P. However, I am actually actively 
developing it, pretty much constantly. Some changes are bigger under the hood 
than others so they take longer to get to a point where I feel they are release 
worthy.

I do plan to continue to work on this, and am especially working on the 
non-linux platforms. So rest assured, it is coming.

Certainly, if you have some patches for this particular issue, please either 
post them here or email them to me directly.

Original comment by evan.teran on 3 Oct 2012 at 4:39

GoogleCodeExporter commented 9 years ago
(In reply to comment #12)
> @arrowdodger: edb is open source :-P. However, I am actually actively
> developing it, pretty much constantly. Some changes are bigger under the hood
> than others so they take longer to get to a point where I feel they are 
release
> worthy.
> 
> I do plan to continue to work on this, and am especially working on the
> non-linux platforms. So rest assured, it is coming.
> 
> Certainly, if you have some patches for this particular issue, please either
> post them here or email them to me directly.

Yes, i've put it wrong. I meant that it would be nice, if you create VCS 
repository somewhere. It would allow people to track development progress and, 
most importantly, easily create patches and send them to you.

Original comment by evan.teran on 3 Oct 2012 at 4:39

GoogleCodeExporter commented 9 years ago
I've made a lot of progress getting things to work on openbsd, to the point 
where things actually "debug" :-). I am hoping that this work will help with 
the freebsd work. I made a release today (10/20/10) so everyone is welcome to 
check out the progress.

NOTE: I have not attempted to compile edb on freebsd in a while. However, both 
FreeBSD and OSX are my primary targets for the next version (and I am hoping 
that the next version wont take quite as long).

Original comment by evan.teran on 3 Oct 2012 at 4:39

GoogleCodeExporter commented 9 years ago
Changes i've made:
1. In src/os/unix/freebsd/DebugEvent.cpp:188
change

=reinterpret_cast<...>(0);

to simply

=0;

2. In include/os/unix/freebsd/MemRegion.h
added at around line 84

private:
void set_permissions(bool read, bool write, bool execute, edb::address_t 
temp_address);

After that i've got some warnings and then finally link error:
obj/release-shared/DebuggerMain.o(.text+0x95f1): In function 
`DebuggerMain::attach(int)':
: undefined reference to `edb::v1::get_parent_pid(int)'

Original comment by evan.teran on 3 Oct 2012 at 4:40

GoogleCodeExporter commented 9 years ago
hanks. Those are actually the same things I've needed to get the openbsd port 
to work correctly :-). The cast was there because there is supposed to be an 
address_t variable representing the fault address which is unknown for now. I 
need to look into the structures available through kvm on freebsd.

I'll keep you guys posted and try to get a "functional" version out soon.

Original comment by evan.teran on 3 Oct 2012 at 4:40

GoogleCodeExporter commented 9 years ago
Fix for 0.9.17.

I've built and ran EDB with this patch, however disassembly and stack views are 
empty during debugging and all registers contain zeros. But debugee seems to 
run perfectly.

Original comment by evan.teran on 3 Oct 2012 at 4:41

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch! It is applied in my subversion. As for the blank views, 
did you try running edb as root?

IIRC, it currently requires privs to access the KVM API for a few things. I am 
going to work on removing that need (perhaps the debugging core will be a 
standalone app which is SUID root and using IPC with the main app, I dunno).

Original comment by evan.teran on 3 Oct 2012 at 4:42

GoogleCodeExporter commented 9 years ago
Yes, i've tried it. Still same issue. As far as i know there is no KVM on 
FreeBSD.

Original comment by evan.teran on 3 Oct 2012 at 4:42

GoogleCodeExporter commented 9 years ago

Original comment by evan.teran on 3 Oct 2012 at 4:42

GoogleCodeExporter commented 9 years ago

Original comment by evan.teran on 4 Apr 2014 at 3:47