-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Gprof still a problem with DJGPP ? #45
Comments
Hi!
Which commit did you build from? Just yesterday I changed the way these libraries are built, this should be fixed now. Will try your test case. I have used gprof before with djgpp, it should work. |
Test case works for me with arguments received from With regular 000017ff <main>:
17ff: 8d 4c 24 04 lea ecx,[esp+0x4]
1803: 83 e4 f0 and esp,0xfffffff0
1806: ff 71 fc push DWORD PTR [ecx-0x4]
1809: 55 push ebp
180a: 89 e5 mov ebp,esp
180c: 56 push esi
180d: 53 push ebx
180e: 51 push ecx
180f: 83 ec 1c sub esp,0x1c
1812: ba e8 5e 01 00 mov edx,0x15ee8
1817: e8 44 3d 00 00 call 5560 <mcount>
181c: 89 cb mov ebx,ecx GCC stores the argument pointer in |
" git rev-parse HEAD" answer me "106759c1ca7e43e3eef66b798214aadc37f8c17e" |
Ok, perhaps I have made a mistake using the tool, I'm learning it.... Workflow:
run on target and get back generated "GMON.OUT", (size 42ko)
Command doesn't talk about "printf()", "foo1()" and "foo2()" call.
Thanks for your analyse, time and work Edit : Add output_sample.txt and updated Makefile with "test" target and different build option |
Yes, it was broken then, sorry. It didn't build gmp/mpfr for gdb, only gcc. Has been fixed now.
The profiler uses a 55ms tick rate (hooks IRQ 0), your test program exits before it can gather any data. On a longer-running program, you will see results. BTW, the Now for the segfault, the question is who is to blame: gcc or libc? |
OK, I have build a new tool-chain with updated git tree, all is fine.
OK, I begun to look closer to this, my final work use a ~1ms interupt to make thread scheduling and other things, there will be a clash somewhere later.
Ok, Is it due to the COFF32 executable format ?
When you are lucky enough to clone a git tree during a work in progress, finding a 18 years old bug is quiet natural. ;) I have found a trace of modification in a file called mcount.c on DJGPP history. It sims to be the origine of some bug report about problem to use Gprof with DJGPP. That why in the DJGPP FAQ it's adviced to use V2.3. You will find in the zip file a Quick and Dirty test to wrap function defined on mcount.c, if it help to debug. |
You can reprogram the timer after SIGPROF has hooked it, I think that should be okay. Note that
Correct, it doesn't support PIC/PIE.
I've sent a message to the list. If nothing comes of that, I can patch it in the build scripts here.
void __real_mcount (int);
__attribute((no_caller_saved_registers, target("general-regs-only"), no_instrument_function))
void __wrap_mcount (int _to)
{
__real_mcount (_to);
} Edit: nevermind, that wouldn't work since the address of |
Draft patch: jwt27/djgpp-cvs#15 |
OK, I was mistaken - the missing call graph is not due to short execution time, it is in fact a bug in gprof/binutils. Patched it locally, then I get:
|
Ok, I've tried to build a toolchain with "jwt27-mcount" branch, it didn't work. Your Gprof output is like what I'm looking for. |
The patch was based off Binutils needs the following patch (bug report here): --- a/gprof/corefile.c
+++ b/gprof/corefile.c
@@ -605,6 +605,9 @@ core_create_function_syms (void)
default:
break;
case bfd_target_coff_flavour:
+ if (startswith (core_bfd->xvec->name, "coff-go32"))
+ break;
+ /* FALLTHROUGH */
case bfd_target_ecoff_flavour:
case bfd_target_xcoff_flavour:
case bfd_target_elf_flavour: And to get the complete call graph, libc is compiled with --- a/build-djgpp.sh
+++ b/build-djgpp.sh
@@ -265,6 +265,7 @@ if [ ! -z ${DJGPP_VERSION} ]; then
export LDFLAGS="$LDFLAGS_FOR_TARGET"
sed -i 's/Werror/Wno-error/' makefile.cfg
${MAKE} config || exit 1
+ echo '-pg' >> gcc.opt
echo "${TARGET}:${DST}:${CFLAGS_FOR_TARGET}" > configure-options
${MAKE_J} -C mkdoc || exit 1
${MAKE_J} -C libc || exit 1 |
Seeing a strange bug after rebasing. The histogram is clobbered with special value |
ok, "ftpmirror.gnu.org" is down for the moment, I'll test when it will be back. |
I have tried to build a DJGPP cross toolchain with the script on a fresh debian.
There were trouble with missing depedencies, I installed libgmp-dev libmpfr-dev to solve part of them and manualy copy libgmp.la and another lib from build directory to install directory. It seemed to be weird, but, the script was able to build GDB and finished the install.
This toolchain were build to try Gprof, so I write a litle program and a makefile to test it.
The program just print some compile info and its parameters and environnement and call 2 handmade functions.
tst-gprof.zip
First things: Using argument's counter and argument's string array make the program crash (SIGSEGV). To solve this, "__crt0_argc" and "__crt0_argv" from "crt0.h" were used.
Second things: "gmon.out" is written but, it is not usable, like an empty file.
it look like this stackoverflow question, so "-no-pie" and "-fno-pie" were used but nothing change.
Is this a bug or did i make something wrong ?
Software in use :
GNU gprof (GNU Binutils) 2.43.1
gcc version 14.2.0 (GCC)
DJGPP 2.5
The text was updated successfully, but these errors were encountered: