Who's Online |
145 user(s) are online ( 112 user(s) are browsing Forums)
Members: 0
Guests: 145
more...
|
|
Headlines |
-
mce.lha - game/utility
Apr 23, 2024
-
theme_list.lha - utility/misc
Apr 23, 2024
-
faac.lha - audio/convert
Apr 22, 2024
-
faad2.lha - audio/convert
Apr 22, 2024
-
seq.lha - audio/misc
Apr 22, 2024
-
libfaac.lha - development/library/audio
Apr 22, 2024
-
libfaad.lha - development/library/audio
Apr 22, 2024
-
image2pdf.lha - utility/text/convert
Apr 22, 2024
-
libharfbuzz.lha - development/library/graphics
Apr 20, 2024
-
libpng.lha - development/library/graphics
Apr 20, 2024
|
|
|
|
Re: GDB
|
Posted on: 2021/3/4 16:56
#41
|
Just popping in
|
Sorry I've been away from this for a few days, I should now have a chance to catch up.
|
|
|
|
Re: GDB
|
Posted on: 2021/2/25 10:00
#42
|
Just popping in
|
kas1e described it well, I'd just add a couple of extra things. With gdb you can set breakpoints at any point in a program which will halt the program at that point so you can inspect variables, etc and can step through the program line by line. It will also allow you to check c variables and even call functions to check their results within gdb itself. It makes development so much easier!
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 21:59
#43
|
Just popping in
|
@salass00
I'll dig through the code to find out where the file is opened and let you know tomorrow. Given that the code used was real_fseek in bfdio.c, I'd guess that some printfs to lines 121-124 in that file will show which one was called or checking for where HAVE_FOPEN64 is defined. I can checkout the branch before we fixed it tomorrow and let you know if that's ok.
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 21:45
#44
|
Just popping in
|
@kas1e
Great idea on adding the tickets, my memory is rubbish at the best of times so having those to look through is the way forward. I'll have another look at the code tomorrow and we can try and work out how to get the exec part sorted. Does that sound ok to you?
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 21:39
#45
|
Just popping in
|
@kas1e
Ah sorry for missing that messag, you were ahead of me in spring the problem as seems to offered be the case 😊
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 18:02
#46
|
Just popping in
|
@kas1e Ah! Thanks for coming to the rescue with -lunix, works perfectly. So I currently have a crash in amigaos_create_inferior () when you run a program within gdb. Going by the debug printouts it is crashing in dos library from this call
debug_data.current_process = IDOS->CreateNewProcTags(
NP_Seglist, exec_seglist,
NP_FreeSeglist, FALSE,
// NP_Child, TRUE,
NP_Name, exec_file,
NP_Cli, TRUE,
NP_Arguments, args,
NP_Input, IDOS->Input(),
NP_CloseInput, FALSE,
NP_Output, IDOS->Output(),
NP_CloseOutput, FALSE,
NP_Error, IDOS->ErrorOutput(),
NP_CloseError, FALSE,
(homedir ? NP_ProgramDir: TAG_IGNORE),homedir,
TAG_DONE
);
with
exec_seglist = 0
exec_file = "/Workspace/helloworld"
args = ""
homedir "NULL"
when I do a run within gdb on helloworld Does anyone see anything immediately wrong with that call before I head off to the os autodocs ? exec_seglist being 0 maybe? I haven't used CreateNewProc () before so I'm just guessing
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 17:50
#47
|
Just popping in
|
@salass00
I'll try and see if I can extract the bits that gdb is doing into a separate program and get that to you
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 16:43
#48
|
Just popping in
|
@kas1e I've submitted a pull request, see if it works for you. I'm getting weird issue that https://github.com/kas1e/gdb/tree/81af ... 013839d99f854762f33b2c74c allows me to do file helloworld and I get the illegal seeks but all builds from https://github.com/kas1e/gdb/tree/b880 ... 6e85518997b5be86053dce255 onwards give me requester asking for /usr/local/lib/debugWorkspace: /usr/local/share/gdb/auto-loadWorkspace: workspace: being the partition with helloworld on. The bits before workspace: are paths defined by bfd so at least I can see where they come from The only thing changed between those two revisions are the "o64" undefs, etc. Does it all work for you? hopefully it's some stupid setting on my system.
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 14:21
#49
|
Just popping in
|
@kas1e
I've replaced BREAKPOINT_FROM_PC, REGISTER_NAME and GDB_SIGNAL_to_name and altered the breakpoint function signatures to match the new spec. Just need to do some testing then I'll do another pull request.
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 10:41
#50
|
Just popping in
|
@sTix You're very right!
|
|
|
|
Re: GDB
|
Posted on: 2021/2/24 7:42
#51
|
Just popping in
|
@kas1e Quote: Are you sure about PC_REGNUM to be just 3?
Ack sorry, that was a total mistake! 😳 Yeah that's definitely wrong, I meant to go back and fix that and forgot to do that last night. I'll carry on working on that file and make another pull request later. The signatures for the functions to add and remove breakpoints have changed quite a bit so that's the next thing that I'll update.
Edited by billyfish on 2021/2/24 9:52:52
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 22:22
#52
|
Just popping in
|
@kas1e
Cheers Roman, great work again. current_regcache looks like an easy fix it's just setting it from get_current_regcache (). I'm working my way through that and the warnings for amigaos-nat.c and will make a pull request for you when I'm done.
BREAKPOINT_FROM_PC (), amigaos_find_lib () and amigaos_add_lib () are currently undefined, are they defined in the 6.3 branch anywhere?
Edited by billyfish on 2021/2/23 23:50:07
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 18:47
#53
|
Just popping in
|
@kas1e
Yup, that looks likely. From this gdb code, it should be really easy to create a small test program to show the problem.
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 17:57
#54
|
Just popping in
|
Ok so after a few debugging printf () calls, the failing function is fseeko64 ()
int
real_fseek (FILE *file, file_ptr offset, int whence)
{
#if defined (HAVE_FSEEKO64)
printf ("using fseeko64\n");
return fseeko64 (file, offset, whence);
#elif defined (HAVE_FSEEKO)
printf ("using fseeko\n");
return fseeko (file, offset, whence);
#else
printf ("using fseek\n");
return fseek (file, offset, whence);
#endif
}
from bfd/bfdio.c:57
(gdb) file helloworld
file helloworld
0 calling bfd seek with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
bfd_seek called with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
bfd_seek called with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
cache_bseek f not null with Workspace:/helloworld with pos 12060 (8) and direction 0 (4)
using fseeko64
real_fseek returned -1 with Workspac:/helloworld with pos 12060 (8) and direction 0 (4)
1: seeking Workspace:/helloworld with pos 12060 and direction 0 has result 89
4: seeking Workspace:/helloworld has error 29
returning Workspace:/helloworld : 89
"Workspace:/helloworld": not in executable format: Illegal seek
(gdb)
Reverting to the standard c versions by adding
#ifdef __amigaos4__
#undef HAVE_FSEEKO64
#undef HAVE_FSEEKO
#undef HAVE_FTELLO64
#undef HAVE_FTELLO
#undef HAVE_FOPEN64
#endif
to bfdio.c, we get
4.Workspace:> gdb-newlib
GNU gdb (GDB) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "ppc-amigaos".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file helloworld
file helloworld
0 calling bfd seek with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
bfd_seek called with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
bfd_seek called with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
cache_bseek f not null with Workspace:/helloworld with pos 12060 (8) and direction 0 (4)
using fseek
real_fseek returned 0 with Workspace:/helloworld with pos 12060 (8) and direction 0 (4)
1: seeking Workspace:/helloworld with pos 12060 and direction 0 has result 88
4: seeking Workspace:/helloworld has error 2
returning Workspace:/helloworld : 88
"Workspace:/helloworld": not in executable format: No such file or directory
(gdb)
Which is a slight improvement and hopefully by setting HAVE_FSEEKO64 HAVE_FSEEKO HAVE_FTELLO64 HAVE_FTELLO HAVE_FOPEN64 etc., correctly across the entire project we may be getting there as I'm hoping the later failure is due to other parts of the io code still using the "o64" function calls.
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 16:10
#55
|
Just popping in
|
@salass00 Ah yup 64 bit! So the debug print is now
(gdb) file helloworld
file helloworld
0 calling bfd seek with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
bfd_seek called with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
BFD: BFD (GNU Binutils) 2.22.52.20120718 assertion fail ../../bfd/elf.c:241
bfd_seek called with Workspace:/helloworld with pos 0 (8) and direction 0 (4)
1: seeking Workspace:/helloworld with pos 12060 and direction 0 has result -1
4: seeking Workspace:/helloworld has error 29
returning Workspace:/helloworld : -1
"Workspace:/helloworld": not in executable format: Illegal seek
(gdb)
The numbers in the brackets after the pos and direction are the sizeof values to make sure I don't get caught out with that again So it's calculated the right position to scroll to for my executable but the subseqeunt seek to this position fails
Edited by billyfish on 2021/2/23 16:52:57 Edited by billyfish on 2021/2/23 17:11:45
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 15:04
#56
|
Just popping in
|
OK so I added this at format.c line 206
printf ("0 calling bfd seek with %s with pos %d and direction %d\n", abfd -> filename, (file_ptr) 0, SEEK_SET);
and
int
bfd_seek (bfd *abfd, file_ptr position, int direction)
{
int result;
file_ptr file_position;
/* For the time being, a BFD may not seek to it's end. The problem
is that we don't easily have a way to recognize the end of an
element in an archive. */
printf ("bfd_seek called with %s with pos %d and direction %d\n", abfd -> filename, position, direction);
BFD_ASSERT (direction == SEEK_SET || direction == SEEK_CUR);
if (direction == SEEK_CUR && position == 0)
return 0;
if (abfd->format != bfd_archive && abfd->my_archive == 0)
{
if (direction == SEEK_SET && (bfd_vma) position == abfd->where)
return 0;
}
else
{
/* We need something smarter to optimize access to archives.
Currently, anything inside an archive is read via the file
handle for the archive. Which means that a bfd_seek on one
component affects the `current position' in the archive, as
well as in any other component.
It might be sufficient to put a spike through the cache
abstraction, and look to the archive for the file position,
but I think we should try for something cleaner.
In the meantime, no optimization for archives. */
}
file_position = position;
if (direction == SEEK_SET)
{
bfd *parent_bfd = abfd;
while (parent_bfd->my_archive != NULL)
{
file_position += parent_bfd->origin;
parent_bfd = parent_bfd->my_archive;
}
}
if (abfd->iovec)
{
result = abfd->iovec->bseek (abfd, file_position, direction);
printf ("1: seeking %s with pos %d and direction %d has result %d\n", abfd -> filename, file_position, direction, result);
}
else
{
printf ("2: iovec for %s is null\n", abfd -> filename);
result = -1;
}
if (result != 0)
{
int hold_errno = errno;
/* Force redetermination of `where' field. */
bfd_tell (abfd);
/* An EINVAL error probably means that the file offset was
absurd. */
if (hold_errno == EINVAL)
{
printf ("3: seeking %s EINVAL\n", abfd -> filename);
bfd_set_error (bfd_error_file_truncated);
}
else
{
bfd_set_error (bfd_error_system_call);
errno = hold_errno;
printf ("4: seeking %s has error %d\n", abfd -> filename, hold_errno);
}
}
else
{
/* Adjust `where' field. */
if (direction == SEEK_SET)
{
printf ("5: seeking %s\n", abfd -> filename);
abfd->where = position;
}
else
{
printf ("6: seeking %s\n", abfd -> filename);
abfd->where += position;
}
}
printf ("returning %s : %d\n", abfd -> filename, result);
return result;
}
and got the following output:
0 calling bfd seek with Workspace:/helloworld with pos 0 and direction 0
bfd seek called with Workspace:/helloworld with pos 0 and direction 0
BFD: BFD (GNU Binutils) 2.22.52.20120718 assertion fail ../../bfd/elf.c:241
bfd_seek called with Workspace:/helloworld with pos 0 and direction 12060
1: seeking Workspace:/helloworld with pos 0 and direction 12060 has result 0
4: seeking Workspace:/helloworld has error 29
returning Worksapce:/helloworld : -1
"Workspace:/helloworld": not in executable format: illegal seek
So the direction then being 12060 seems like where things go very wrong! Unless some weird redefining is going on, direction should be 0, 1 or 2 for SEEK_SET, SEEK_CUR and SEEK_END. Even the GNU extensions only add values for 3 and 4. So somewhere direction is getting set strangely.
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 11:47
#57
|
Just popping in
|
@kas1e Quote: It adds -let and -lunix not at the end of linking line as expected, but at the beginning, before "-o gdb", so it didn't taken into account :(
make LOADLIBES="$LOADLIBES -lunix -lnet"
will do it. Also we can use EXEEXT flag at the build stage and it will automatically put that at the end of the gdb program name e.g.
make LOADLIBES="$LOADLIBES -lunix -lnet" EXEEXT="-clib2"
will end up with an executeable called gdb-clib2
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 11:35
#58
|
Just popping in
|
@kas1e
Awesome! Yup it's even better without the extra flag, one less thing to remember!
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 11:09
#59
|
Just popping in
|
@kas1e Quote: Just need to understand how to deal with that adding of undefs to alloca/process/malloc without patch , but from configure line (so to not have needs to patch things after configuring, and less steps in build process)
Totally agree. We could have blocks like
#ifdef __amigaos4__
#ifdef CLIB2
<blah>
#else /* newlib */
<blah>
#endif
what do you think? in inflow.c that block at line 45 is what causes the problem, when building with clib2 so instead of
#ifdef __amigaos4__
#undef HAVE_TERMIOS
#define HAVE_TERMIO 1
#endif
we could have
#ifdef __amigaos4__
#ifdef CLIB2
#undef HAVE_TERMIO
#else
#undef HAVE_TERMIOS
#define HAVE_TERMIO 1
#endif
#endif
Ideally at the config stage we should just be able to put -DCLIB2=1 in the CFLAGS to switch from newlib to clib2. I did this in the makefiles for simplegit and libgit2 as it'#s a pain in neck/arse to get it building with the two different libs!
|
|
|
|
Re: GDB
|
Posted on: 2021/2/23 9:50
#60
|
Just popping in
|
config.patch:
--- config.h 2021-02-22 19:00:25.228937154 +0000
+++ config.h-new 2021-02-22 18:59:39.383470770 +0000
@@ -9,7 +9,8 @@
/* #undef CRAY_STACKSEG_END */
/* Define to 1 if you have the <alloca.h> header file. */
-#define HAVE_ALLOCA_H 1
+/*#define HAVE_ALLOCA_H 1 */
+#undef HAVE_ALLOCA_H
/* Define to 1 if you have the `asprintf' function. */
#define HAVE_ASPRINTF 1
@@ -141,7 +142,8 @@
/* #undef HAVE_MACHINE_HAL_SYSINFO_H */
/* Define to 1 if you have the <malloc.h> header file. */
-#define HAVE_MALLOC_H 1
+/* #define HAVE_MALLOC_H 1 */
+#undef HAVE_MALLOC_H
/* Define to 1 if you have the `memchr' function. */
#define HAVE_MEMCHR 1
@@ -174,7 +176,8 @@
/* #undef HAVE_ON_EXIT */
/* Define to 1 if you have the <process.h> header file. */
-#define HAVE_PROCESS_H 1
+/* #define HAVE_PROCESS_H 1 */
+#undef HAVE_PROCESS_H
/* Define to 1 if you have the `psignal' function. */
/* #undef HAVE_PSIGNAL */
@@ -297,7 +300,8 @@
/* #undef HAVE_SYS_ERRLIST */
/* Define to 1 if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
+/* #define HAVE_SYS_FILE_H 1 */
+#undef HAVE_SYS_FILE_H
/* Define to 1 if you have the <sys/mman.h> header file. */
/* #undef HAVE_SYS_MMAN_H */
@@ -306,7 +310,8 @@
/* #undef HAVE_SYS_NERR */
/* Define to 1 if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
+/* #define HAVE_SYS_PARAM_H 1 */
+#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/prctl.h> header file. */
/* #undef HAVE_SYS_PRCTL_H */
|
|
|
|