English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 12 March 2018, 16:39   #21
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
Quote:
Originally Posted by bebbo View Post
-g generates old stab debug format. It contains enough information to map source lines to asm offsets and display variables.
Thanks. It looks like it could work nicely. (Lots of parsing to do..)
Toni Wilen is offline  
AdSense AdSense  
Old 12 March 2018, 16:49   #22
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
Quote:
Originally Posted by Toni Wilen View Post
Thanks. It looks like it could work nicely. (Lots of parsing to do..)
take the functions from binutils/bfd...
bebbo is offline  
Old 13 March 2018, 15:24   #23
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
Quote:
Originally Posted by bebbo View Post
take the functions from binutils/bfd...
They probably have too weird code

I checked what -g does with pfs3aio. There is normal HUNK_SYMBOL first with usual symbols, then comes HUNK_DEBUG which has huge amount of binary values (offsets?), no strings. Then comes another HUNK_DEBUG that contains stabs.

What does the first HUNK_DEBUG contain?

First HUNK_DEBUG: (something?)

Code:
00010080h: 6D 50 52 00 00 00 62 C6 00 00 00 00 00 00 03 F2 ; mPR...bÆ.......ò
00010090h: 00 00 03 F1 00 01 1C AC 00 00 00 01 64 00 00 00 ; ...ñ...¬....d...
000100a0h: 00 00 00 00 00 00 00 00 44 00 00 0B 00 00 00 00 ; ........D.......
000100b0h: 00 00 00 00 44 00 00 0E 00 00 00 02 00 00 00 00 ; ....D...........
000100c0h: 44 00 00 0F 00 00 00 04 00 00 00 00 44 00 00 10 ; D...........D...
000100d0h: 00 00 00 08 00 00 00 00 44 00 00 11 00 00 00 0C ; ........D.......
000100e0h: 00 00 00 00 44 00 00 12 00 00 00 10 00 00 00 00 ; ....D...........
000100f0h: 44 00 00 13 00 00 00 14 00 00 00 00 44 00 00 14 ; D...........D...
00010100h: 00 00 00 18 00 00 00 00 44 00 00 17 00 00 00 1C ; ........D.......
00010110h: 00 00 00 00 44 00 00 18 00 00 00 20 00 00 00 00 ; ....D...... ....
00010120h: 44 00 00 1C 00 00 00 24 00 00 00 00 44 00 00 1D ; D......$....D...
00010130h: 00 00 00 26 00 00 00 00 44 00 00 21 00 00 00 2A ; ...&....D..!...*
...
Second HUNK_DEBUG: (stabs)

Code:
00057340h: 01 00 00 00 00 00 00 00 00 00 03 F2 00 00 03 F1 ; ...........ò...ñ
00057350h: 00 03 24 A7 00 73 74 61 72 74 75 70 2E 73 00 00 ; ..$§.startup.s..
00057360h: 00 2F 63 79 67 64 72 69 76 65 2F 63 2F 70 72 6F ; ./cygdrive/c/pro
00057370h: 6A 65 63 74 73 2F 70 66 73 33 61 69 6F 2F 00 62 ; jects/pfs3aio/.b
00057380h: 6F 6F 74 2E 63 00 67 63 63 32 5F 63 6F 6D 70 69 ; oot.c.gcc2_compi
00057390h: 6C 65 64 2E 00 69 6E 74 3A 74 31 3D 72 31 3B 2D ; led..int:t1=r1;-
000573a0h: 32 31 34 37 34 38 33 36 34 38 3B 32 31 34 37 34 ; 2147483648;21474
Toni Wilen is offline  
Old 13 March 2018, 15:47   #24
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
Quote:
Originally Posted by Toni Wilen View Post
They probably have too weird code

I checked what -g does with pfs3aio. There is normal HUNK_SYMBOL first with usual symbols, then comes HUNK_DEBUG which has huge amount of binary values (offsets?), no strings. Then comes another HUNK_DEBUG that contains stabs.

What does the first HUNK_DEBUG contain?

First HUNK_DEBUG: (something?)

Code:
00010080h: 6D 50 52 00 00 00 62 C6 00 00 00 00 00 00 03 F2 ; mPR...bÆ.......ò
00010090h: 00 00 03 F1 00 01 1C AC 00 00 00 01 64 00 00 00 ; ...ñ...¬....d...
000100a0h: 00 00 00 00 00 00 00 00 44 00 00 0B 00 00 00 00 ; ........D.......
000100b0h: 00 00 00 00 44 00 00 0E 00 00 00 02 00 00 00 00 ; ....D...........
000100c0h: 44 00 00 0F 00 00 00 04 00 00 00 00 44 00 00 10 ; D...........D...
000100d0h: 00 00 00 08 00 00 00 00 44 00 00 11 00 00 00 0C ; ........D.......
000100e0h: 00 00 00 00 44 00 00 12 00 00 00 10 00 00 00 00 ; ....D...........
000100f0h: 44 00 00 13 00 00 00 14 00 00 00 00 44 00 00 14 ; D...........D...
00010100h: 00 00 00 18 00 00 00 00 44 00 00 17 00 00 00 1C ; ........D.......
00010110h: 00 00 00 00 44 00 00 18 00 00 00 20 00 00 00 00 ; ....D...... ....
00010120h: 44 00 00 1C 00 00 00 24 00 00 00 00 44 00 00 1D ; D......$....D...
00010130h: 00 00 00 26 00 00 00 00 44 00 00 21 00 00 00 2A ; ...&....D..!...*
...
Second HUNK_DEBUG: (stabs)

Code:
00057340h: 01 00 00 00 00 00 00 00 00 00 03 F2 00 00 03 F1 ; ...........ò...ñ
00057350h: 00 03 24 A7 00 73 74 61 72 74 75 70 2E 73 00 00 ; ..$§.startup.s..
00057360h: 00 2F 63 79 67 64 72 69 76 65 2F 63 2F 70 72 6F ; ./cygdrive/c/pro
00057370h: 6A 65 63 74 73 2F 70 66 73 33 61 69 6F 2F 00 62 ; jects/pfs3aio/.b
00057380h: 6F 6F 74 2E 63 00 67 63 63 32 5F 63 6F 6D 70 69 ; oot.c.gcc2_compi
00057390h: 6C 65 64 2E 00 69 6E 74 3A 74 31 3D 72 31 3B 2D ; led..int:t1=r1;-
000573a0h: 32 31 34 37 34 38 33 36 34 38 3B 32 31 34 37 34 ; 2147483648;21474
my gcc/binutils:

You are looking at an object file: There are the .stab and the .stabstr debug hunk.

The final executable has one DEBUG hunk, where all .stab and .stabstr hunks are combined. That's the same DEBUG hunk as in previous gcc versions. This starts with a magic dword the .stab size and the .stabstr site. Then the combined .stab follows and last the combined .stabstr.
bebbo is offline  
Old 13 March 2018, 15:52   #25
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
No, it is final executable and it has 2 debug hunks.

File 'l:pfs3aio':
HUNK_HEADER
Numhunks = 1 (0 to 0)
Hunk 000 = 58856 ($00E5E8) Bytes

HUNK_CODE 58856 ($00E5E8) Bytes
HUNK_(ABS)RELOC32
Summary 214 entries to hunk 0
HUNK_SYMBOL
HUNK_END

HUNK_DEBUG 291504 ($0472B0) Bytes
HUNK_END

HUNK_DEBUG 823964 ($0C929C) Bytes
HUNK_END
Toni Wilen is offline  
Old 13 March 2018, 16:50   #26
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
Quote:
Originally Posted by Toni Wilen View Post
No, it is final executable and it has 2 debug hunks.

File 'lfs3aio':
HUNK_HEADER
Numhunks = 1 (0 to 0)
Hunk 000 = 58856 ($00E5E8) Bytes

HUNK_CODE 58856 ($00E5E8) Bytes
HUNK_(ABS)RELOC32
Summary 214 entries to hunk 0
HUNK_SYMBOL
HUNK_END

HUNK_DEBUG 291504 ($0472B0) Bytes
HUNK_END

HUNK_DEBUG 823964 ($0C929C) Bytes
HUNK_END
uhm ...

$ hunkdump pfs3aio
reading pfs3aio
hunk 000003f3, HUNK_HEADER, 0
1 sections, 0 - 0
sizes: 57248
hunk 000003e9, HUNK_CODE, 57248
hunk 000003ec, HUNK_RELOC32, 772
HUNK_END
hunk 000003f1, HUNK_DEBUG, 1066612
HUNK_END
bebbo is offline  
Old 13 March 2018, 17:06   #27
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
I only added -g to CFLAGS and removed -s. It still creates two debug hunks. Does it split hunks if they become too big? Or something like that.

I have some changes in my pfs3aio tree that probably can make small difference in size.
Toni Wilen is offline  
Old 13 March 2018, 17:10   #28
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
Quote:
Originally Posted by Toni Wilen View Post
I only added -g to CFLAGS and removed -s. It still creates two debug hunks. Does it split hunks if they become too big? Or something like that.

I have some changes in my pfs3aio tree that probably can make small difference in size.
No, the DEBUG hunk is merged during linking - not split.

I rather think your binutils aren't my binutils.
bebbo is offline  
Old 13 March 2018, 21:30   #29
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
I added some extra printfs to amigaos.c, both HUNK_DEBUGs comes from following code: (amiga_write_section_contents())

Code:
  /* Depending on the type of the section, write out HUNK_{CODE|DATA|BSS} */
  if (section->flags & SEC_CODE) /* Code section */
    n[0] = HUNK_CODE;
  else if (section->flags & (SEC_DATA | SEC_LOAD)) /* data section */
    n[0] = HUNK_DATA;
  else if (section->flags & SEC_ALLOC) /* BSS */
    n[0] = HUNK_BSS;
  else if (section->flags & SEC_DEBUGGING) /* debug section */
    n[0] = HUNK_DEBUG;
  else /* Error */
    {
    	printf("flags=%x\n", section->flags);
#if 0
      bfd_set_error (bfd_error_nonrepresentable_section);
      return FALSE;
#else
      /* FIXME: Just dump everything we don't currently recognize into
       a DEBUG hunk. */
      n[0] = HUNK_DEBUG;
#endif
    }

	printf("Section type is %lx\n",n[0]);
I get following messages after all "INFO: using long.." messages:

Quote:
Section type is 3e9
flags=20204
Section type is 3f1
flags=20200
Section type is 3f1
And finally, for some reason it never reaches code that would write "correct" HUNK_DEBUG:

Code:
	  /* Write out HUNK_DEBUG, size, ZMAGIC, ... */
	  n[0] = HUNK_DEBUG;
	  n[1] = 3 + ((symbols * sizeof(struct external_nlist) + str_size + 3) >> 2);
	  n[2] = ZMAGIC; /* Magic number */
(pfs3aio changes commited now except makefile change)
Toni Wilen is offline  
Old 13 March 2018, 22:19   #30
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
are you using https://github.com/bebbo/amiga-gcc?
bebbo is offline  
Old 13 March 2018, 22:40   #31
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
I put some effort into gdb and my own bgdbserver...

Code:
$ m68k-amigaos-gdb hello-ks13
GNU gdb (GDB) 8.1.50.20180312-git
Copyright (C) 2018 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 "--host=i686-pc-cygwin --target=m68k-amigaos".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello-ks13...(no debugging symbols found)...done.
(gdb) target remote :2222
Remote debugging using :2222
warning: Target reported unsupported offsets: Text=404f3eb0;Data=404f1130;Bss=404f1130;
0x404f3eb0 in ?? ()
asm source code get displayed correctly:
Code:
layout asm
Code:
0x404f3eb0   bsr.w 0x404f3f7c 
0x404f3eb4   move.l a0,-32650(a4)   
0x404f3eb8   move.l d0,-32662(a4)   
0x404f3ebc   move.l #0,d1  
0x404f3ec2   beq.s 0x404f3ed0 
0x404f3ec4   moveq #0,d0   
0x404f3ec6   lea -32714(a4),a1   
0x404f3eca   move.l d0,(a1)+  
0x404f3ecc   subq.l #4,d1  
0x404f3ece   bne.s 0x404f3eca 
0x404f3ed0   move.l sp,-32654(a4)   
0x404f3ed4   movea.l 0x4,a6   
0x404f3ed8   move.l a6,-32658(a4)   
0x404f3edc   suba.l a1,a1  
0x404f3ede   jsr -294(a6)  
0x404f3ee2   movea.l d0,a3 
0x404f3ee4   tst.l 172(a3) 
0x404f3ee8   bne.w 0x404f3f00 
0x404f3eec   lea 92(a3),a0 
0x404f3ef0   jsr -384(a6)  
0x404f3ef4   lea 92(a3),a0 
0x404f3ef8   jsr -372(a6)  
0x404f3efc   move.l d0,-32670(a4)   
0x404f3f00   lea -32750(a4),a2   
0x404f3f04   addq.w #4,a2  
0x404f3f06   moveq #-1,d2  
0x404f3f08   bsr.s 0x404f3f4a
... still some work left until it's usable
Code:
remote Thread 1 In:                                                                                                                                              L??   PC: 0x404f3eb0
(gdb) b main
Breakpoint 1 at 0x404f0470
(gdb)

Last edited by bebbo; 13 March 2018 at 23:10.
bebbo is offline  
Old 14 March 2018, 16:00   #32
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
Quote:
Originally Posted by bebbo View Post
I used amigaos-cross-toolchain, I thought it was same, only difference being build method. Apparently not because amiga-gcc does create single hunk_debug..

Where is the hunk_debug format documented? Or at least which source file generates it?
Toni Wilen is offline  
Old 14 March 2018, 17:05   #33
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
Quote:
Originally Posted by Toni Wilen View Post
I used amigaos-cross-toolchain, I thought it was same, only difference being build method. Apparently not because amiga-gcc does create single hunk_debug..

Where is the hunk_debug format documented? Or at least which source file generates it?
Don't know either...
... but I would look at

  • amiga_load_stab_symbols
  • aout_32_translate_symbol_table
  • aout_32_find_nearest_line
  • ...
that's what objdump uses
bebbo is offline  
Old 14 March 2018, 19:43   #34
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
Unexpectedly file called stabs.c had small description:

Code:
/* Stabs entries use a 12 byte format:
     4 byte string table index
     1 byte stab type
     1 byte stab other field
     2 byte stab desc field
     4 byte stab value
And it seems to work:

Code:
Stab 64 00 0000 00000000 00000001='startup.s'
Stab 44 00 000b 00000000 00000000='NULL'
Stab 44 00 000e 00000002 00000000='NULL'
Stab 44 00 000f 00000004 00000000='NULL'
Stab 44 00 0010 00000008 00000000='NULL'
..
even more N_SLINE entries..
..
Stab 44 00 007f 000000e6 00000000='NULL'
Stab 64 00 0002 000000ec 0000000d='/cygdrive/c/projects/pfs3aio/'
Stab 64 00 0002 000000ec 0000002b='boot.c'
Stab 3c 00 0000 00000000 00000032='gcc2_compiled.'
Stab 80 00 0000 00000000 00000041='int:t1=r1;-2147483648;2147483647;'
Stab 80 00 0000 00000000 00000063='char:t2=r2;0;127;'
Stab 80 00 0000 00000000 00000075='long int:t3=r3;-2147483648;2147483647;'
...
Toni Wilen is offline  
Old 14 March 2018, 21:29   #35
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 47
Posts: 410
A sampling profiler running on host code and not disturbing emulated machine's timing would be nice ....just saying (or wishing)
alkis is offline  
Old 14 March 2018, 22:16   #36
Vousti
Banned
 
Join Date: Mar 2018
Location: Finland
Posts: 36
You're doing cool stuff and I don't understand anything about it. ROCK ON!
Vousti is offline  
Old 16 March 2018, 17:52   #37
pipper
Registered User

 
Join Date: Jul 2017
Location: San Jose
Posts: 68
Hi Toni,
Is this something still work in progress or something I could already try out?
Thanks!
pipper is online now  
Old 16 March 2018, 18:19   #38
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,174
Quote:
Originally Posted by pipper View Post
Hi Toni,
Is this something still work in progress or something I could already try out?
Both I'll probably release first test version later today or tomorrow.

(Did you mean to post in your debugging thread where I already posted more about new uae debugging features? http://eab.abime.net/showthread.php?t=90143)
Toni Wilen is offline  
Old 14 June 2018, 21:24   #39
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 275
With a little luck, time and effort you can debug remotely with gdb 8.1 sooner or later.

Read more at https://franke.ms/amiga/gdb8.wiki

* source code is now displayed
* breakpoints and stepping seems to work
* local variables and parameters are displayed correctly

... still ugly and unexpected seg faults...

Last edited by bebbo; 15 June 2018 at 14:03.
bebbo is offline  
Old 14 June 2018, 23:04   #40
lantus360
Registered User
 
Join Date: Feb 2013
Location: Olathe, Kansas
Posts: 179
i approve of this. well done !
lantus360 is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugging? MartinW Coders. C/C++ 10 03 January 2018 20:59
Debugging over Serial-Port sigma63 support.WinUAE 1 14 March 2016 19:02
Remote C/C++ debugging? alkis Coders. C/C++ 1 03 January 2014 12:17
Remote GDB debugging copse support.WinUAE 6 31 August 2011 01:05
The enemy at the end of a level - strategies Rick Dangerous support.Games 6 05 May 2006 12:58

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:53.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.11505 seconds with 15 queries