Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
155 user(s) are online (138 user(s) are browsing Forums)

Members: 0
Guests: 155

more...

Support us!

Headlines

 
  Register To Post  

« 1 (2) 3 4 5 ... 10 »
Re: GDB
Home away from home
Home away from home


See User information
@billyfish

So let's stick to 7.5.1 for the moment, and once we will deal with elf32-amiga.c and amiga-nat.c adaptation and it will work, we then can go further with no problems (and also have more experience).

Also probably 7.5.1 will be the best choice for start as later versions maybe need newer Binutils (because of BFD parts in that elf32-amigaos.c).

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


See User information
@kas1e

Great work! I agree, just sticking with something not too new is a good idea. Otherwise you'll need to solve 12^324 problems at once.

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


See User information
@sTix
Tried to traceback from where that strange terminal issue come (i.e. why it spawn for us "select: No such file or directory." and then in a row give "select: .").

I for sake of tests, port 6.3a version in the same way as I do for 7.5.1 (i.e. not adtools version, just fresh one, with the same kind of changes, same workarounds i do for 7.5.1): and this one didn't have that bug. Terminal works. I even tried to use the same readline library (just in case) from 6.3, but it's the same.

I added traces to main.c and top.c , and so far all passes fine in top.c's gdb_init(), init_main() and in main.c's captured_main() , that crap happens later.

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


See User information
@kas1e

I'm not at my amiga right now, so my dodgy memory might get this wrong. On linux, for the program that you're trying to debug, say it's called foobar, run

objdump -g foobar

and look for the part after "Contents of the .debug_info section:"

The DW_AT_name and DW_AT_comp_dir fields should be filled in for the DW_AT_compile_unit section and give the name of the source file and the directory that it is in respectively.

This is what gdb is looking for on linux at least.

Does the amiga program that you're running gdb with have these parts filled in? If so, we will at least know that the info is in the right place.

Tomorrow I should be able to get on my amiga and look properly rather than having to guess!


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


See User information
@billyfish

At this time i didnt tried to load anything: its just i run gdb as it and it says that cant open something and terminal start to act strange. I.e without loading anything. Loading of binary to debug surely will not works as elf32-amiga is empty stabs and no nat implementation added.

Maybe this 7.5.1 tried to load something automatically which 6.3 didnt, and tried to use non-implemented parts, dunno.

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
At least I find out the code triggered this: gdb/event-loop.c, function gdb_wait_for_event() and we have in loop that:

/* Dont print anything if we got a signal, let gdb handle
         it.  */
      
if (errno != EINTR)
        
perror_with_name (("select"));
    }


So that the "select" we have in a row when run gdb. Then i find out which call of that function exactly causes this, and this is in the same event-loop.c file, from the gdb_do_one_even(), there is the guilty part which was added after 6.3 (i.e. 6.3 do have the same function, but don't have that kind of code, so it's new):

/* To level the fairness across event sources, we poll them in a
     round-robin fashion.  */
  
for (current 0current number_of_sourcescurrent++)
    {
      switch (
event_source_head)
    {
    case 
0:
      
/* Are any timers that are ready? If so, put an event on the
         queue.  */
      
poll_timers ();
      break;
    case 
1:
      
/* Are there events already waiting to be collected on the
         monitored file descriptors?  */
      
gdb_wait_for_event (0);
      break;
    case 
2:
      
/* Are there any asynchronous event handlers ready?  */
      
check_async_event_handlers ();
      break;
    }

      
event_source_head++;
      if (
event_source_head == number_of_sources)
    
event_source_head 0;
    }


The one in "case 1" is guilty. Once I comment out this gdb_wait_for_event(0), then the gdb terminal starts to behave correctly.

Resized Image


Is anyone can see anything wrong with that gdb_wait_for_event (0) call ?


Edited by kas1e on 2021/2/22 7:31:44
Edited by kas1e on 2021/2/22 8:19:08
Edited by kas1e on 2021/2/22 8:20:42
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Just popping in
Just popping in


See User information
@kas1e

Well found! Looking at the code, it looks like that gdb_select (), which is calling posix select () in posix_hdep.c, and that is returning -1. I'll add some debug messages to see what error is actually happening.

If the problem doesn't occur when we use gdb with a filename on the command line, then it won't affect how gdb is mostly used I guess.


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


See User information
@billyfish
Quote:

Looking at the code, it looks like that gdb_select (), which is calling posix select () in posix_hdep.c, and that is returning -1. I'll add some debug messages to see what error is actually happening.


Yeah, it can be very well some os4 specific issue to the select() as well...

Quote:

If the problem doesn't occur when we use gdb with a filename on the command line, then it won't affect how gdb is mostly used I guess.


We anyway need to understand wtf is happening so as to make a proper fix (even if it didn't break gdb usable in whole).

Btw, to make life easier to understand what we need to adapt from older versions is 2 files:

BFD/elf32-AmigaOS.c - that one already in repo, fully commented out at moment, with simple stubs at the top. This file is specific platform-dependent executable file support (in our case 32bit ELF). It's in BFD because BFD is an object file library, and used not only by GDB, but also by GAS, LD, and all those binary utils like objdump,readelf, etc, etc. Once we will adapt that file, then GDB will be able to load our debug-EFLs (but just load, i.e. GDB will be able to parse our ELF executables).

GDB/AmigaOS-nat.c - that one I didn't add to the repo at moment, but this one is must be adapted too, as this one is native-dependent code exactly for amigaos4 (for every system they have such files, like amd64-nat, arm-Linux-nat, etc, etc). As far as I see, that the file where all our magic happens: inserting breakpoints, creating amiga specific threads/tasks, fetching/store registers, etc, etc.

So once we deal with elf32-amigaos4.c i assume we will be able to just do "gdb test" , and inside of gdb do "list" to see source file. That will mean our elf32 support ok. Then we can concetrate on the amigaos4-nat (that will be for exactly debugging, disassembling, etc).


ps. checked the old adtools version, basically, elf32-amigaos4.c is in most parts straight copy of the elf32-ppc.c! So I assume we can follow the same way : copy over elf32-ppc.c, and replace only relevant parts as done in elf32-amigaos.c



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

Checked more close elf32-ppc.c and elf32-amigaos.c files in adtools repo, and they for real just almost straigh copy with minimal changes. So i adapt the same way to 7.5.1.

Now, once i run gdb, and tryig to load binary in, i have then :

Quote:

7/0.RAM Disk:> gdb
(gdb) file helloworld
"RAM Disk:helloworld": not in executable format: Illegal seek
(gdb)


And now, the funny part : i tried to build adtools's version (our old 6.3 one) via newlib, and it cause the same issue ! I.e. works via clib2, but didn't via newlib and bring that "illegal seek" error.

I tried to just build 6.3 version as it (without other amiga patches) , and with adapted elf32-amiga it has exactly the same issue with newlib !

So, seems we have or bug in newlib's seek(), or it just some different implementation. But the fact that it works with clib2 , mean that it's not GDB code guilty imho.


@Salas00

Have you maybe any idea what can be wrong with newlib's seek() ?

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


See User information
@kas1e

So that is coming from exec_file_attach (), lin2 252 in gdb/exec.c, I'm guessing. It may not be a seek problem, but the code to check might be bfd_check_format_matches() in bfd/format.c.

Just to clarify, if you run

objdump -g helloworld

does it work?



It's me being slow, so apologies for this, but are you saying that you are getting that error for both clib2 and newlib on 7.5.1? And for 6.3,it works for clib2 but not newlib?


Hopefully be on my amiga in a couple of hours to check this too, but it looks like clib2 might be the way to go then.

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


See User information
@billyfish
Quote:

objdump -g helloworld


That what it output:

3/0.Work:aaobjdump -g test

test
:     file format elf32-amigaos

Warning
numeric overflow: (0,8);-9223372036854775808;9223372036854775807;
test.c:
typedef int32 int;
typedef uint8 char;
typedef int32 long int;
typedef uint32 unsigned int;
typedef uint32 long unsigned int;
typedef uint32 __int128;
typedef uint32 __int128 unsigned;
typedef void long long int;
typedef uint64 long long unsigned int;
typedef int16 short int;
typedef uint16 short unsigned int;
typedef int8 signed char;
typedef uint8 unsigned char;
typedef float float;
typedef double double;
typedef double long double;
typedef float _Float32;
typedef double _Float64;
typedef double _Float32x;
typedef void void;
int main ()
/* 0x10004c0 */
  /* file test.c line 3 addr 0x10004c0 */
  /* file test.c line 4 addr 0x10004d4 */
  /* file <built-in> line 0 addr 0x10004e0 */
  /* file test.c line 5 addr 0x10004e4 */
/* 0x1000500 */
struct __va_list_tag /* id 0 */
};
 /
SDK/newlib/include/stdio.h:
typedef struct __sFILE64 /* id 1 */ FILE;
typedef long int fpos_t;
typedef long long int fpos64_t;
 /
Work/SDK/gcc/lib/gcc/ppc-amigaos/8.3.0/include/stddef.h:
typedef unsigned int size_t;
typedef unsigned int wint_t;
typedef int ptrdiff_t;
typedef long int wchar_t;
typedef struct %anon2 /* size 16 */
  
long long int __max_align_ll/* bitsize 64, bitpos 0 */
  
long double __max_align_ld/* bitsize 64, bitpos 64 */
max_align_t;
 /
Work/SDK/gcc/lib/gcc/ppc-amigaos/8.3.0/include/stdarg.h:
typedef struct __va_list_tag /* id 0 */ __gnuc_va_list[1]:uint32;
 /
SDK/newlib/include/sys/reent.h:
typedef long unsigned int __ULong;
struct _Bigint /* size 24 id 3 */
  
struct _Bigint /* id 3 */ *_next/* bitsize 32, bitpos 0 */
  
int _k/* bitsize 32, bitpos 32 */
  
int _maxwds/* bitsize 32, bitpos 64 */
  
int _sign/* bitsize 32, bitpos 96 */
  
int _wds/* bitsize 32, bitpos 128 */
  
__ULong _x[1]:uint32/* bitsize 32, bitpos 160 */
};
struct __tm /* size 36 id 4 */
  
int __tm_sec/* bitsize 32, bitpos 0 */
  
int __tm_min/* bitsize 32, bitpos 32 */
  
int __tm_hour/* bitsize 32, bitpos 64 */
  
int __tm_mday/* bitsize 32, bitpos 96 */
  
int __tm_mon/* bitsize 32, bitpos 128 */
  
int __tm_year/* bitsize 32, bitpos 160 */
  
int __tm_wday/* bitsize 32, bitpos 192 */
  
int __tm_yday/* bitsize 32, bitpos 224 */
  
int __tm_isdst/* bitsize 32, bitpos 256 */
};
struct _on_exit_args /* size 264 id 5 */
  
void *_fnargs[32]:uint32/* bitsize 1024, bitpos 0 */
  
void *_dso_handle[32]:uint32/* bitsize 1024, bitpos 1024 */
  
__ULong _fntypes/* bitsize 32, bitpos 2048 */
  
__ULong _is_cxa/* bitsize 32, bitpos 2080 */
};
struct _atexit /* size 400 id 6 */
  
struct _atexit /* id 6 */ *_next/* bitsize 32, bitpos 0 */
  
int _ind/* bitsize 32, bitpos 32 */
  
void (*_fns[32]) (/* unknown */):uint32/* bitsize 1024, bitpos 64 */
  
struct _on_exit_args /* id 5 */ _on_exit_args/* bitsize 2112, bitpos 1088 */
};
struct __sbuf /* size 8 id 7 */
  
unsigned char *_base/* bitsize 32, bitpos 0 */
  
int _size/* bitsize 32, bitpos 32 */
};
typedef long int _fpos_t;
typedef long long int _fpos64_t;
struct __sFILE /* size 136 id 8 */
  
unsigned char *_p/* bitsize 32, bitpos 0 */
  
int _r/* bitsize 32, bitpos 32 */
  
int _w/* bitsize 32, bitpos 64 */
  
short int _flags/* bitsize 16, bitpos 96 */
  
short int _file/* bitsize 16, bitpos 112 */
  
struct __sbuf /* id 7 */ _bf/* bitsize 64, bitpos 128 */
  
int _lbfsize/* bitsize 32, bitpos 192 */
  
void *_cookie/* bitsize 32, bitpos 224 */
  
int (*_read) (/* unknown */); /* bitsize 32, bitpos 256 */
  
int (*_write) (/* unknown */); /* bitsize 32, bitpos 288 */
  
_fpos_t (*_seek) (/* unknown */); /* bitsize 32, bitpos 320 */
  
int (*_close) (/* unknown */); /* bitsize 32, bitpos 352 */
  
struct __sbuf /* id 7 */ _ub/* bitsize 64, bitpos 384 */
  
unsigned char *_up/* bitsize 32, bitpos 448 */
  
int _ur/* bitsize 32, bitpos 480 */
  
unsigned char _ubuf[3]:uint32/* bitsize 24, bitpos 512 */
  
unsigned char _nbuf[1]:uint32/* bitsize 8, bitpos 536 */
  
struct __sbuf /* id 7 */ _lb/* bitsize 64, bitpos 544 */
  
int _blksize/* bitsize 32, bitpos 608 */
  
int _offset/* bitsize 32, bitpos 640 */
  
struct _reent /* id 9 */ *_data/* bitsize 32, bitpos 672 */
  
short int _lock[23]:uint32/* bitsize 368, bitpos 704 */
};
struct __sFILE64 /* size 152 id 1 */
  
unsigned char *_p/* bitsize 32, bitpos 0 */
  
int _r/* bitsize 32, bitpos 32 */
  
int _w/* bitsize 32, bitpos 64 */
  
short int _flags/* bitsize 16, bitpos 96 */
  
short int _file/* bitsize 16, bitpos 112 */
  
struct __sbuf /* id 7 */ _bf/* bitsize 64, bitpos 128 */
  
int _lbfsize/* bitsize 32, bitpos 192 */
  
struct _reent /* id 9 */ *_data/* bitsize 32, bitpos 224 */
  
void *_cookie/* bitsize 32, bitpos 256 */
  
int (*_read) (/* unknown */); /* bitsize 32, bitpos 288 */
  
int (*_write) (/* unknown */); /* bitsize 32, bitpos 320 */
  
_fpos_t (*_seek) (/* unknown */); /* bitsize 32, bitpos 352 */
  
int (*_close) (/* unknown */); /* bitsize 32, bitpos 384 */
  
struct __sbuf /* id 7 */ _ub/* bitsize 64, bitpos 416 */
  
unsigned char *_up/* bitsize 32, bitpos 480 */
  
int _ur/* bitsize 32, bitpos 512 */
  
unsigned char _ubuf[3]:uint32/* bitsize 24, bitpos 544 */
  
unsigned char _nbuf[1]:uint32/* bitsize 8, bitpos 568 */
  
struct __sbuf /* id 7 */ _lb/* bitsize 64, bitpos 576 */
  
int _blksize/* bitsize 32, bitpos 640 */
  
int _flags2/* bitsize 32, bitpos 672 */
  
long long int _offset/* bitsize 64, bitpos 704 */
  
_fpos64_t (*_seek64) (/* unknown */); /* bitsize 32, bitpos 768 */
  
short int _lock[23]:uint32/* bitsize 368, bitpos 800 */
};
typedef struct __sFILE64 /* id 1 */ __FILE;
struct _glue /* size 12 id 10 */
  
struct _glue /* id 10 */ *_next/* bitsize 32, bitpos 0 */
  
int _niobs/* bitsize 32, bitpos 32 */
  
__FILE *_iobs/* bitsize 32, bitpos 64 */
};
struct _rand48 /* size 14 id 11 */
  
short unsigned int _seed[3]:uint32/* bitsize 48, bitpos 0 */
  
short unsigned int _mult[3]:uint32/* bitsize 48, bitpos 48 */
  
short unsigned int _add/* bitsize 16, bitpos 96 */
};
struct fd /* size 28 id 12 */
  
int _private[7]:uint32/* bitsize 224, bitpos 0 */
};
struct _reent /* size 8208 id 9 */
  
int _errno/* bitsize 32, bitpos 0 */
  
__FILE *_stdin/* bitsize 32, bitpos 32 */
  
__FILE *_stdout/* bitsize 32, bitpos 64 */
  
__FILE *_stderr/* bitsize 32, bitpos 96 */
  
unsigned int ___private[2048]:uint32/* bitsize 65536, bitpos 128 */
};
 /
SDK/newlib/include/sys/_types.h:
typedef long int _off_t;
typedef long long int _off64_t;
typedef int _ssize_t;
typedef struct %anon13 /* size 8 */
  
int __count/* bitsize 32, bitpos 0 */
  
union %anon14 /* size 4 */
    
wint_t __wch/* bitsize 32, bitpos 0 */
    
unsigned char __wchb[4]:uint32/* bitsize 32, bitpos 0 */
  
__value/* bitsize 32, bitpos 32 */
_mbstate_t;
typedef short int _flock_t[23]:uint32;
typedef void *_iconv_t;
 /
SDK/newlib/include/setjmp.h:
 /
SDK/newlib/include/machine/setjmp.h:
typedef double jmp_buf[64]:uint32;
 /
SDK/newlib/include/sys/resource.h:
struct rusage /* size 16 id 15 */
  
struct timeval /* id 16 */ ru_utime/* bitsize 64, bitpos 0 */
  
struct timeval /* id 16 */ ru_stime/* bitsize 64, bitpos 64 */
};
 /
SDK/newlib/include/sys/time.h:
struct timezone /* size 8 id 17 */
  
int tz_minuteswest/* bitsize 32, bitpos 0 */
  
int tz_dsttime/* bitsize 32, bitpos 32 */
};
struct itimerval /* size 16 id 18 */
  
struct timeval /* id 16 */ it_interval/* bitsize 64, bitpos 0 */
  
struct timeval /* id 16 */ it_value/* bitsize 64, bitpos 64 */
};
 /
SDK/newlib/include/sys/types.h:
typedef unsigned char u_char;
typedef short unsigned int u_short;
typedef unsigned int u_int;
typedef long unsigned int u_long;
typedef short unsigned int ushort;
typedef unsigned int uint;
typedef long long unsigned int clock_t;
typedef long int time_t;
struct timespec /* size 8 id 19 */
  
time_t tv_sec/* bitsize 32, bitpos 0 */
  
long int tv_nsec/* bitsize 32, bitpos 32 */
};
typedef long int daddr_t;
typedef char *caddr_t;
typedef long unsigned int ino_t;
typedef long unsigned int dev_t;
typedef long int off_t;
typedef short unsigned int uid_t;
typedef short unsigned int gid_t;
typedef int pid_t;
typedef long int key_t;
typedef _ssize_t ssize_t;
typedef unsigned int mode_t;
typedef long unsigned int nlink_t;
typedef long unsigned int clockid_t;
typedef long unsigned int timer_t;
typedef long unsigned int useconds_t;
typedef long int suseconds_t;
 /
SDK/newlib/include/machine/_types.h:
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short int __int16_t;
typedef short unsigned int __uint16_t;
typedef __int16_t __int_least16_t;
typedef __uint16_t __uint_least16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef __int32_t __int_least32_t;
typedef __uint32_t __uint_least32_t;
typedef long long int __int64_t;
typedef long long unsigned int __uint64_t;
 /
SDK/newlib/include/machine/types.h:
typedef long int __off_t;
typedef int __pid_t;
typedef long long int __loff_t;
 /
SDK/newlib/include/sys/select.h:
struct timeval /* size 8 id 16 */
  
time_t tv_sec/* bitsize 32, bitpos 0 */
  
suseconds_t tv_usec/* bitsize 32, bitpos 32 */
};
typedef long int fd_mask;
struct fd_set /* size 32 id 20 */
  
fd_mask fds_bits[8]:uint32/* bitsize 256, bitpos 0 */
};
typedef struct fd_set /* id 20 */ fd_set;
 /
SDK/newlib/include/sys/timeb.h:
struct timeb /* size 12 id 21 */
  
time_t time/* bitsize 32, bitpos 0 */
  
short unsigned int millitm/* bitsize 16, bitpos 32 */
  
short int timezone/* bitsize 16, bitpos 48 */
  
short int dstflag/* bitsize 16, bitpos 64 */
};
 /
SDK/newlib/include/signal.h:
typedef int sig_atomic_t;
typedef void (*sig_t) (/* unknown */);
typedef void (*sighandler_t) (/* unknown */);
 /
SDK/newlib/include/sys/signal.h:
typedef long unsigned int sigset_t;
typedef void (*_sig_func_ptr) (/* unknown */);
 <
built-in>:


In meantime i will try to build 7.5.1 with adapted elf32-amiga.c over clib2, to see, if that "illegal seek" gone.


Quote:

It's me being slow, so apologies for this, but are you saying that you are getting that error for both clib2 and newlib on 7.5.1? And for 6.3,it works for clib2 but not newlib?


"Illegal seek" error happens on 7.5.1 and on 6.3 if build with newlib. If build 6.3 with clib2, then no such error. Trying to build 7.5.1 now with clib2 to test.

I.e. it looks like clib2 builds not have error, but newlib ones have. But need to finish clib2 build of 7.5.1 to prove that.

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


See User information
@kas1e

Cheers ok that makes sense to my slow brain now So clib2 is hopefully the way to go. I found that to be the case with simplegit too when it comes to Posix compatibility.

Finally(!) on my amiga, and if I run gdb 7.5.1 on a simple hello_world program with


gdb helloworld


I get a grim reaper pointing at bfd_check_format_matches+ 0.210 (section 1 @0x230EC0) which ties in with my first guess of where the seek bug is that we need to fix.


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


See User information
@billyfish

Quote:

I get a grim reaper pointing at bfd_check_format_matches+ 0.210 (section 1 @0x230EC0) which ties in with my first guess of where the seek bug is that we need to fix.


That all about our issue with "select" stuff. To avoid it for the moment just load gdb as it, and then "file HelloWorld" to have illegal seek :)

Also, I not sure if the clib2 version is the way to go, at the moment I have some troubles build the clib2 version: it builds mostly fine, but when about to builds GDB part itself start screaming about LONG/SHORT/FLOAT etc being redeclared (while for newlib there no such errors), tried to understand wtf.

If you want to try to build clib2 version, then:

Quote:


1.
../configure --host=ppc-amigaos --target=ppc-amigaos --build=x86_64 --disable-nls --disable-werror --disable-sim CFLAGS="-mcrt=clib2"

2.

1. add some empty files in the clib2 includes (malloc.h, process.h, file.h)

3.
libiberty/pex-unix.c :
#define FD_CLOEXEC 1

4. gdb/gnuimport/localcharset.c

//#ifdef STATIC
//STATIC
//#endif


And after that you will have issues with FLOAT/LONG/SHORT being rediclared (happens with clib2 only, not with newlib), and i had to fix it by some hackish way currently: via commenting out in the clib2/include/unistd.h line 59, which is include of sys/select.h.

The add on the linking -lnet as well (for select() and ioctl() ), and then it links.

And, it kind of works. At least i can run gdb, then "file helloworld", it then bring skippable DSI, some pathes issues, and then load the file with my efl32-amiga. I even can list the source meaning that sections reads fine, see (press open in new tab for fullsize):

Resized Image


Edited by kas1e on 2021/2/22 17:03:44
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Home away from home
Home away from home


See User information
@billifish

Updated the repo with the new elf32-amiga.c which is a pure copy of elf32-ppc.c (as it was in our old version), with very minimal changes about names, etc. Also some ifndefs in the elf32-ppc.c itself to avoid "multiple definitions" of some functions (it can be dealing with compiler flags too, but less crap with configure/make files, the better).

I tested the same way by build 6.3 version (i.e. the same straight copy of elf32-ppc.c to elf32-amiga.c with the same minimal changes) and it reacts the same as expected, so chances that all fine is high.

Currently, it will work only if you build it with clib2 (because of illegal seek error), and with commented out gdb_wait_for_event (0) on line 439 in event_loop.c. By "will work" I mean you can load a file, it will be parsed, you can see source by "list" command, etc.

Through, I to be honest don't understand why it was done like this. Imho, there no need for that elf32-amiga.c file at all, can be just used original elf32-ppc.c, just with minimal ifdefs inside. But that, not a big deal, we can clean it all later if there will be needs.

Quote:

I get a grim reaper pointing at bfd_check_format_matches+ 0.210 (section 1 @0x230EC0) which ties in with my first guess of where the seek bug is that we need to fix.


To clarify things a bit more, that what we have now:

1). "Illegal seek" error happens with newlib, but not with clib2, and that on 6.3 from adtools repo and with our 7.5.1 as well.

2). with both builds, newlib or clib2 of 7.5.1 we have on running "select ." calling in a row blocking terminal. To work around it we had to comment out in gdb/event-loop.c calling of gdb_wait_for_event (0);, on line 439.

So those 2 seem to be just separate issues.

Of course, for us will be better if we can use both newlib and clib2 builds because technically speaking, for GDB that should not matter if we use newlib or clib2, and that a good chance to find out a bug be it newlib or whatever.

In meantime will trying to adapt nat-amigaos.c, which seems _THAT_ file which for real mean amigaos4 work.


EDIT: traced a bit more that "illegal seek" issue, and that for sure come from bfd_seek() function: https://github.com/kas1e/gdb/blob/main/gdb-7.5.1/bfd/bfdio.c#L281 , i have printfs from there before we fail.

And it fails when called not from bfd_check_format_matches() for sure (i tried to comment out all of them inside of bfd_check_format_matches(), same error, so that not it).

Strangely it says before "not in executable format" which is in exec.c , but this one didn't call any bfd_seek..


Edited by kas1e on 2021/2/23 7:44:13
Edited by kas1e on 2021/2/23 8:02:26
Edited by kas1e on 2021/2/23 8:04:16
Edited by kas1e on 2021/2/23 8:22:23
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: GDB
Just popping in
Just popping in


See User information
@kas1e

Awesome!

I managed to get a clib2-ified build going avoiding some of the hacking. The config.h in libiberty was getting wrong values for clib2 which meant that it was trying to get alloca.h, process.h, etc. The __USE_CLIB2_TIMEVAL define removes the need to edit the sys/select.h file and I don't get the cast problems


1. ../configure --host=ppc-amigaos --target=ppc-amigaos --build=x86_64 --disable-nls --disable-werror --disable-sim CFLAGS="$CFLAGS -mcrt=clib2 -D__USE_CLIB2_TIMEVAL=1" LDFLAGS="$LDFLAGS -L/home/billy/Projects/amiga-gdb/ -lnet -lunix"

2. cd libiberty

3. patch < config.patch

4. cd ..

5. make

But my clib2 is causing me problems on the final linking of gdb with a missing getpgrp so I need to add that to the linking

However if I can't get the clib2 version to fully build, and given that it works on your set up, it's going to be that I'm missing something on my clib2 installation, I can still build the newlib version fine so I can work on both issues there hopefully.

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


See User information
config.patch:

--- config.h    2021-02-22 19:00:25.228937154 +0000
+++ config.h-new    2021-02-22 18:59:39.383470770 +0000
@@ -9,+9,@@
 
/* #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,+142,@@
 
/* #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,+176,@@
 
/* #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,+300,@@
 
/* #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,+310,@@
 
/* #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 */

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


See User information
@billyfish
Quote:

But my clib2 is causing me problems on the final linking of gdb with a missing getpgrp so I need to add that to the linking

However if I can't get the clib2 version to fully build, and given that it works on your set up, it's going to be that I'm missing something on my clib2 installation, I can still build the newlib version fine so I can work on both issues there hopefully.


I have the same missing getpgrp in the inflow.c, so i just commente this call out in 2 places for have final linking.

That at least will give you ability to start it and load a file to see that elf32-amiga.c works. But IMHO we need to deal with that "seek" issue on newlib. It's just easer to build newlib version for now, and it's anyway better for our tests to have 2 builds.

At least we need to find our from where bsd_seek() call causing this issue, then add prinfs and build clib2 and newlib versions to see wtf happens. But seeing code of that bsd_seek() with all those SEEK_CUR and SEEK_SET i start to remember we have something of that sort issue when build MUI-VIM , so we had to build clib2 version of it, and not newlib one. Very possible that all related.

Quote:

D__USE_CLIB2_TIMEVAL


Good catch ! Will be good to update repo so it can build newlb and clib2 versions. 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)

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


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

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


See User information
@billifish

Andreas remind that while clib2 proabaly didn't have own define, but newlib have, so to support both clib2 and newlib in the same code we don't need new flag, but:

Quote:

#ifdef __amigaos4__
#ifdef _NEWLIB
#undef HAVE_TERMIOS
#define HAVE_TERMIO 1
#else
#undef HAVE_TERMIOS
#endif
#endif


Also sadly when i provide configuring line of such kind:

Quote:

../configure --host=ppc-amigaos --target=ppc-amigaos --build=x86_64 --disable-nls --disable-werror --disable-sim CFLAGS="$CFLAGS -mcrt=clib2 -D__USE_CLIB2_TIMEVAL=1" LDFLAGS="$LDFLAGS -lnet -lunix"


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 :(

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


See User information
@billyfish
@kas1e

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

Go to top

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

 




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




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project