Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
116 user(s) are online (83 user(s) are browsing Forums)

Members: 1
Guests: 115

skynet, more...

Support us!

Headlines

 
  Register To Post  

« 1 2 (3) 4 5 6 ... 10 »
Re: GDB
Just popping in
Just popping in


See User information
@kas1e

Awesome! Yup it's even better without the extra flag, one less thing to remember!

Go to top
Re: GDB
Home away from home
Home away from home


See User information
@sTix
Quote:

I've started to investigate how to incorporate this into adtools so that gdb is built per default when gcc and binutils is built.


Good!

If you have time you may also try to check our 2 issues: why newlib has "illegal seek" when we load the file in, while clib2 did not that, and why we have the "select ." command in a terminal in a row blocking terminal. The more people work on real coding issues the better :)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Just popping in
Just popping in


See User information
@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

Go to top
Re: GDB
Just popping in
Just popping in


See User information
@kas1e

The plan is to start with all the rest in binutils, it's sort of glued together with gdb so I think we need to do some work on the current patch set. After that I can have a look at amigaos-nat and co. It's not yet clear to me how this works but if we just do some random work here and there it will probably work out in the end

Go to top
Re: GDB
Home away from home
Home away from home


See User information
@sTix
Quote:

The plan is to start with all the rest in binutils, it's sort of glued together with gdb so I think we need to do some work on the current patch set. After that, I can have a look at amigaos-nat and co. It's not yet clear to me how this works but if we just do some random work here and there it will probably work out in the end


I not very much understand it too, but seems GDB has inside just a "copy" of the BFD library from Binutils. So we either can use one from Binutils, or, build always one coming with GDB itself (as we do now).

Downloading the original 8.3.1 source code of GDB shows that BFD directory is here. While downloading morphos' SDK, shows that they instead delete it from there, and use one from binutils. Probably reasons because they implement it one and for once, so all other programs (like objdump and co) will use it, so why not use ready on in GDB too.


@billyfish

Quote:

make LOADLIBES="$LOADLIBES -lunix -lnet"


Oh, I remember, for now, it's just we shouldn't use LDFLAGS for the libraries, but LIBS instead, will check if can deal with just from configure line, without adding anything to make command



Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Home away from home
Home away from home


See User information
@billyfish

It seems that "illegal seek" on newlib indeed happens inside of bfd/format.c's bfd_check_format_matches().

The error seems to come from the bfd_seek on line 206: https://github.com/kas1e/gdb/blob/main/gdb-7.5.1/bfd/format.c#L206

At least if i add prinfs before all 3 bfd_seeks() in that fucntion, i have printfs before that one when it quite with "illegal seek". But, if i comment this one out, it still exit, and still with the same illegal seek :) We may need to prinfs values of abfd, and file_ptr on both newlib and clib2 builds, so we can see if values are differs much.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Just can't stay away
Just can't stay away


See User information
@kas1e

The only major difference between clib2 and newlib seek implementations that I can see is that clib2 allows out of bounds seeks by extending the file also if the file is opened as O_RDONLY, whereas newlib only auto extends for O_WRONLY and O_RDWR.

Go to top
Re: GDB
Just popping in
Just popping in


See User information
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_ptr0SEEK_SET);


and

int
bfd_seek 
(bfd *abfdfile_ptr positionint 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 -> filenamepositiondirection);


  
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_vmaposition == 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 (abfdfile_positiondirection);
          
printf ("1: seeking %s with pos %d and direction %d has result %d\n"abfd -> filenamefile_positiondirectionresult);
      }
  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 -> filenamehold_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 -> filenameresult);

  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 Binutils2.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 formatillegal 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.



Go to top
Re: GDB
Just can't stay away
Just can't stay away


See User information
@billyfish

Have you checked what type file_ptr is. If it's 64-bit (long long) then you need to use %lld. If the low 32-bit of pos is printed as direction then that would explain where the 12060 is coming from.

Go to top
Re: GDB
Just popping in
Just popping in


See User information
@salass00


Ah yup 64 bit! So the debug print is now

(gdbfile 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)
BFDBFD (GNU Binutils2.22.52.20120718 assertion fail ../../bfd/elf.c:241
bfd_seek called with Workspace
:/helloworld with pos 0 (8) and direction 0 (4)
1seeking 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 formatIllegal 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
Go to top
Re: GDB
Just popping in
Just popping in


See User information
Ok so after a few debugging printf () calls, the failing function is

fseeko64 ()

int
real_fseek 
(FILE *filefile_ptr offsetint whence)
{
#if defined (HAVE_FSEEKO64)
printf ("using fseeko64\n");
    return 
fseeko64 (fileoffsetwhence);
#elif defined (HAVE_FSEEKO)
    
printf ("using fseeko\n");
  return 
fseeko (fileoffsetwhence);
#else
  
printf ("using fseek\n");
  return 
fseek (fileoffsetwhence);
#endif
}


from bfd/bfdio.c:57


(gdbfile 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)
1seeking 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 formatIllegal 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 
(GDB7.5.1
Copyright 
(C2012 Free Software FoundationInc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free softwareyou are free to change and redistribute it.
There is NO WARRANTYto the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "ppc-amigaos".
For 
bug reporting instructionsplease see:
<
http://www.gnu.org/software/gdb/bugs/>.
(gdbfile 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)
1seeking 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 formatNo 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.


Go to top
Re: GDB
Home away from home
Home away from home


See User information
@billyfish

Just simple adding to the gdb-build/bfd/config.h after configuring done, at the end those undefs you mention, and recompiling the whole thing, make it all works! No more illegal seek!

Now, we need to check, if on clib2 those defines enabled at all? Maybe not, and that why it works on clib2. Through, it still looks like newlib ones are guilty anyway, is it correct?


Probably now while we at least kind of understand issues with illegal seek, we need to understand wtf with another issue: why when we have gdb_wait_for_event (0); in event_loop(), we have that "select ." typing always in gdb terminal in the loop. After that, we will be at least at beginning of polish things and then concentrate on that "amigaos-nat" part. Once it will work on peg2/x1000/etc where the old one works, we then can concentrate on x5000 and we have a new version :)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Home away from home
Home away from home


See User information
@All
Ahaha, config.h of bfd of clib2 build:

Quote:

/* #undef HAVE_FSEEKO64 */
#define HAVE_FSEEKO 1
/* #undef HAVE_FTELLO64 */
#define HAVE_FTELLO 1
/* #undef HAVE_FOPEN64 */
#define HAVE_DECL_FSEEKO64 0
#define HAVE_DECL_FTELLO64 0


That kind of explains why it works on clib2: because on clib2 it didn't use those x64 functions, while on newlib we have them, and tried to use them, and fail. Meaning it's not clib2 there better, it's just clib2 didn't have those functions, while newlib have (through, they seem to have issues?) At least FTELLO64 and FSEEKO64?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Just popping in
Just popping in


See User information
@kas1e

Yup, that looks likely. From this gdb code, it should be really easy to create a small test program to show the problem.

Go to top
Re: GDB
Home away from home
Home away from home


See User information
@billyfish
That will help for sure. Can you made such a small test case ? (i just not very well understand issue, so can't myself). If Frederik in interest to deal with in newlib testcase will help.

We for time being can of course easy workaround it in the repo while (and if) fixed newlib will be avail.

For now tryng to debug that gdb_wait_for_event (0); in event_loop() issue. Strange why it call "select .". "Select" is probabaly short-named command for selecting a frame ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Just popping in
Just popping in


See User information
@kas1e
Quote:
For now tryng to debug that gdb_wait_for_event (0); in event_loop() issue. Strange why it call "select .". "Select" is probabaly short-named command for selecting a frame ?


It's POSIX I/O lingo

Not sure if there are any limitations in the Amiga implementation, if so, you also have the option of using poll().

Go to top
Re: GDB
Home away from home
Home away from home


See User information
@sTix
Quote:

Not sure if there are any limitations in the Amiga implementation, if so, you also have the option of using poll().


Not sure if we can, at least I didn't find poll.h file in the whole SDK.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Home away from home
Home away from home


See User information
@billyfish
Added to Repo ftello64/fseeko64/fopen64 workaround for newlib: https://github.com/kas1e/gdb/commit/b8 ... 6e85518997b5be86053dce255

just in bfd's sysdep.h, so all will automatically be taken exactly for aos4/newlib only. We can keep this one until fixed newlib will be out, but for time being workaround is good enough for sure, not worse than how it was with clib2 builds before.

not sure if it possible to "configure" the gdb line to say "disable ftello64/fseeko64"? If not, the way how I did it can be kept IMHO? (just one single change, not a big deal).

@all
And I tested dwarf2/4 support: our old GDB indeed only supports dwarw2, while 7.5.1 can load up dwarf 4 bins! See:

(open in new tab for full size)
Resized Image

There I show that binary compiled with dwarf4 support, then tried to load it up with old-current gdb: says sorry, 4 not support, and then load it up with our new v7.5.1: it works. So, once we have done with nat-amigaos.c, we at least will have one major feature right away: working dwarf4 support. Then if x5000 support will be added it will be something at last (after 10 years ?)

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Home away from home
Home away from home


See User information
@all
Updated repo with :

1). added original and old amigaos-nat.c from old version of our gdb from adtools on sourceforge.
2). changed gdb/config/amigaos.mh, so amigaos-nat.c will be compiled and linked now.
3). get rid of most compilation errors in it (see latest commits history). There were just one DOS difference, then bunch of pure-rename functions in the GDB itself since v.6.3 times, and disabled sobjs for now (first we need to make it works at all).

Now, what is left is 2 undefs on compiling stage

PC_REGNUM
and
current_regcache

"PC_REGNUM" it seems now "gdbarch_pc_regnum (gdbarch)", or maybe "PPC_MQ_REGNUM", that need to be checked with context. And "current_regcache" in our case it seems now just "regcache". Through, both of them give me "undefined" so probably some gdb includes need to be added or something. Seems those ones need to be changed in the function's arguments and filled in some other functions.



Edited by kas1e on 2021/2/23 21:22:56
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Just popping in
Just popping in


See User information
@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
Go to top

  Register To Post
« 1 2 (3) 4 5 6 ... 10 »

 




Currently Active Users Viewing This Thread: 2 ( 0 members and 2 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project