Best practice for debugging Amiga app on MorphOS
  • Just looking around
    Posts: 9 from 2018/5/8
    Hi

    I've recently discovered MorphOS and am interested in getting an old Amiga app I wrote (a basic word-processr called TextEngine) to run on this OS. TextEngine was written in M68k assembler but didn't hit the hardware so my hope is that it shouldn't be too difficult to get to work in MorphOS.

    I've downloaded TextEngine from Aminet and just tried to run it but it isn't opening on MorphOS 3.10. My guess is a library is failing to load on start-up or something similar. Question is, what is the best approach to debug a M68k app on MorphOS?

    When I get some time I'll fire-up Devpac in UAE and will build a version with some debugging embedded to try to pin-point the failure, but if anyone knows of any simpler methods then I'd appreciate your thoughts.

    Oh, and the source-code is up on GitHub in case anyone can spot the bug! :-)

    Thanks
    Nick
  • »08.05.18 - 20:07
    Profile Visit Website
  • jPV
  • Paladin of the Pegasos
    Paladin of the Pegasos
    jPV
    Posts: 1438 from 2003/2/24
    From: po-RNO
    There's Snoopium in the Tools directory, which should reveal if some library or resource is missing, but quickly tested it didn't show anything with this program.

    Debug screenbar module should also reveal if the program crashes, but doesn't seem to be case either.

    Is there something in the initializing code that would check something and fail without being verbose?
  • »09.05.18 - 06:05
    Profile Visit Website
  • Just looking around
    Posts: 9 from 2018/5/8
    Hi JPV - many thanks for making those tests on my dusty old code! The initialisation routines open all the Amiga libraries required to run the programme and if any fail to open it will gracefully quit but will produce no error message. Sounds like I need to re-compile with some verbose errors added to help me pin this down.
  • »09.05.18 - 08:24
    Profile Visit Website
  • Just looking around
    Posts: 9 from 2018/5/8
    Quote:

    unholyeyebrows wrote:
    Hi JPV - many thanks for making those tests on my dusty old code! The initialisation routines open all the Amiga libraries required to run the programme and if any fail to open it will gracefully quit but will produce no error message. Sounds like I need to re-compile with some verbose errors added to help me pin this down.


    These are the libraries opened at start-up in case any of these are obviously incompatible with MorphOS, although of course the bug may well lie elsewhere:

    GadToolsName: dc.b "gadtools.library",0
    IntuitionName: dc.b "intuition.library",0
    GfxName: dc.b "graphics.library",0
    UtilityName: dc.b "utility.library",0
    ASLName: dc.b "asl.library",0
    DOSName: dc.b "dos.library",0
    WorkbenchName: dc.b "workbench.library",0
  • »09.05.18 - 08:40
    Profile Visit Website
  • Just looking around
    Posts: 9 from 2018/5/8
    I've done some further debugging and can see the error is during the creation of the window by the GadToolsBox generated code. With time I should be able to pin this down but it might take a while.
  • »09.05.18 - 10:55
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 1681 from 2003/3/5
    From: Poland
    Disabling trance will give you a more meaningful crash report.
  • »09.05.18 - 12:19
    Profile Visit Website
  • Just looking around
    Posts: 9 from 2018/5/8
    OK, probably going a bit off-topic here, but the point of failure is when OpenWindowTagList is called from the Intuition Library to open the main window. This is failing and sending my programme down an abort path. The code being executed was generated by GadToolsBox which I used to design the GUI - see the snippet below. Does anyone with knowledge of how Morphos might be handling this call have any clues why it may be failing?

    Code:

    OpenWindowTagList EQU -606

    move.l d0,MainEditWindowH+4
    move.l _IntuitionBase,a6
    suba.l a0,a0
    lea.l MainEditWindowWindowTags,a1
    jsr OpenWindowTagList(a6)
    move.l d0,MainEditWindowWnd
    tst.l d0
    beq MainEditWindowWError ;* We are failing here on MorphOS but we pass on AmigaOS


    XDEF MainEditWindowWindowTags
    MainEditWindowWindowTags:
    DC.L $80000093,1
    MainEditWindowL:
    DC.L $80000064,0
    MainEditWindowT:
    DC.L $80000065,0
    MainEditWindowW:
    DC.L $80000066,0
    MainEditWindowH:
    DC.L $80000067,0
    DC.L $8000006A,$0040037E
    DC.L $8000006B,$0000123F
    DC.L $8000006E,MainEditWindowWTitle
    DC.L $8000006F,MainEditWindowSTitle
    DC.L $80000072,92
    DC.L $80000073,65
    DC.L $80000074,640
    DC.L $80000075,256
    DC.L $00000000

    MainEditWindowWTitle:
    DC.B 'Untitled',0
    CNOP 0,2

    MainEditWindowSTitle:
    DC.B 'TextEngine V5.2',0
    CNOP 0,2
  • »09.05.18 - 12:19
    Profile Visit Website
  • Moderator
    Kronos
    Posts: 1813 from 2003/2/24
    Do you really have the tag values in hex in your sourcecode instead of the constants defined in the includes?

    Well, the "solution" should be to 1st decipher what every tag actually refers to and then reduce it to the bare essentials.



    Code:
     
    DC.L $80000074,640
    DC.L $80000075,256


    This looks like the window dimensions, could it be that something fails here due to bigger fonts and such (shouldn't be but better sure then sorry)

    [ Edited by Kronos 09.05.2018 - 14:59 ]
    --------------------- May the 4th be with you ------------------
    Mother Russia dance of the Zar, don't you know how lucky you are
  • »09.05.18 - 12:56
    Profile
  • Just looking around
    Posts: 9 from 2018/5/8
    Fair point about the tags. I simply didn't have the include files back in the 90s!

    Here's the translation:

    Code:
        XDEF    MainEditWindowWindowTags
    MainEditWindowWindowTags:
    DC.L $80000093,1 #define WA_NewLookMenus (WA_Dummy + 0x30)
    MainEditWindowL:
    DC.L $80000064,0 #define WA_Left (WA_Dummy + 0x01)
    MainEditWindowT:
    DC.L $80000065,0 #define WA_Top (WA_Dummy + 0x02)
    MainEditWindowW:
    DC.L $80000066,0 #define WA_Width (WA_Dummy + 0x03)
    MainEditWindowH:
    DC.L $80000067,0 #define WA_Height (WA_Dummy + 0x04)
    DC.L $8000006A,$0040037E #define WA_IDCMP (WA_Dummy + 0x07)
    DC.L $8000006B,$0000123F #define WA_Flags (WA_Dummy + 0x08)
    DC.L $8000006E,MainEditWindowWTitle #define WA_Title (WA_Dummy + 0x0B)
    DC.L $8000006F,MainEditWindowSTitle #define WA_ScreenTitle (WA_Dummy + 0x0C)
    DC.L $80000072,92 #define WA_MinWidth (WA_Dummy + 0x0F)
    DC.L $80000073,65 #define WA_MinHeight (WA_Dummy + 0x10)
    DC.L $80000074,640 #define WA_MaxWidth (WA_Dummy + 0x11)
    DC.L $80000075,256 #define WA_MaxHeight (WA_Dummy + 0x12)
    DC.L $00000000

    WA_IDCMP $0040037E
    10000000000001101111110
    #define IDCMP_NEWSIZE 0x00000002L
    #define IDCMP_REFRESHWINDOW 0x00000004L
    #define IDCMP_MOUSEBUTTONS 0x00000008L
    #define IDCMP_MOUSEMOVE 0x00000010L
    #define IDCMP_GADGETDOWN 0x00000020L
    #define IDCMP_GADGETUP 0x00000040L
    #define IDCMP_MENUPICK 0x00000100L
    #define IDCMP_CLOSEWINDOW 0x00000200L
    #define IDCMP_ACTIVEWINDOW 0x00040000L

    WA_Flags $0000123F
    1001000111111
    #define WFLG_SIZEGADGET 0x00000001L /* include sizing system-gadget? */
    #define WFLG_DRAGBAR 0x00000002L /* include dragging system-gadget? */
    #define WFLG_DEPTHGADGET 0x00000004L /* include depth arrangement gadget? */
    #define WFLG_CLOSEGADGET 0x00000008L /* include close-box system-gadget? */

    #define WFLG_SIZEBRIGHT 0x00000010L /* size gadget uses right border */
    #define WFLG_SIZEBBOTTOM 0x00000020L /* size gadget uses bottom border */
    #define WFLG_REPORTMOUSE 0x00000200L /* to hear about every mouse move */
    #define WFLG_ACTIVATE 0x00001000L /* when Window opens, it's Active */


    [ Edited by unholyeyebrows 09.05.2018 - 14:17 ]
  • »09.05.18 - 13:16
    Profile Visit Website
  • Just looking around
    Posts: 9 from 2018/5/8
    Quote:

    Kronos wrote:
    Do you really have the tag values in hex in your sourcecode instead of the constants defined in the includes?

    Well, the "solution" should be to 1st decipher what every tag actually refers to and then reduce it to the bare essentials.



    Code:
     
    DC.L $80000074,640
    DC.L $80000075,256


    This looks like the window dimensions, could it be that something fails here due to bigger fonts and such (shouldn't be but better sure then sorry)


    The GadToolsBox generated sourcecode applies logic to some of the window tags to adjust for different font sizes on the Amiga Workbench so I'm wondering if some of that logic isn't working correctly on Morphos. I may see if I can get a later version of GadToolsBox and re-generate the GUI in case that helps things. I'm suspecting there may not be a simple solution to getting this working...
  • »09.05.18 - 13:26
    Profile Visit Website
  • Moderator
    Kronos
    Posts: 1813 from 2003/2/24
    So you do set min and max sizes for the window (92x65 vs. 640x256) but set the default width/height to 0 ?


    AFAIR none of the tags are mandatory (but if you pass them make sure they have proper values) so as a start I would do:

    - set the defaults to something close to 640x256

    - if that fails remove all the tags for default min and max sizes, this should open a fullscreen window
    --------------------- May the 4th be with you ------------------
    Mother Russia dance of the Zar, don't you know how lucky you are
  • »09.05.18 - 13:30
    Profile
  • Moderator
    Kronos
    Posts: 1813 from 2003/2/24
    If GadTools messes with these values:

    Print them out just before OpenWindowTagList()

    Or just up them to say 1024x768 to make sure their is enough room.
    --------------------- May the 4th be with you ------------------
    Mother Russia dance of the Zar, don't you know how lucky you are
  • »09.05.18 - 13:33
    Profile
  • Just looking around
    Posts: 9 from 2018/5/8
    I've now pinpointed the issue to the GadToolsBox code which scale the UI depending on the Amiga system font. After making an ugly work-around I can now run TextEngine on MorphOS which is pretty cool. I can now spend some time finding a more robust solution, in which case I'll upload an update to Aminet.

    Thanks all for the ideas which helped me figure this out.
    Nick
  • »09.05.18 - 18:20
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Stevo
    Posts: 813 from 2004/1/24
    From: #AmigaZeux
    Quote:

    unholyeyebrows wrote:
    I've now pinpointed the issue to the GadToolsBox code which scale the UI depending on the Amiga system font. After making an ugly work-around I can now run TextEngine on MorphOS which is pretty cool. I can now spend some time finding a more robust solution, in which case I'll upload an update to Aminet.

    Thanks all for the ideas which helped me figure this out.
    Nick



    ...and thank you Nick for your update of TextEngine :-)
    ---
    http://www.iki.fi/sintonen/logs/its_only_football.txt
  • »20.06.18 - 20:10
    Profile
  • Just looking around
    Posts: 9 from 2018/5/8
    Just to say TextEngine v5.3 which runs on Morphos 3.10 is now available on Aminet:

    http://aminet.net/package/text/edit/TextEngine5.3

    Might come in handy for anyone who needs to edit any old documents or convert them to ASCII!
  • »25.06.18 - 08:55
    Profile Visit Website
  • MorphOS Developer
    Nadir
    Posts: 134 from 2003/3/17
    Quote:

    unholyeyebrows wrote:
    Just to say TextEngine v5.3 which runs on Morphos 3.10 is now available on Aminet:

    http://aminet.net/package/text/edit/TextEngine5.3

    Might come in handy for anyone who needs to edit any old documents or convert them to ASCII!


    Nice that this was made to work on MorphOS!

    Just to note that also Flow Studio can handle old Amiga text documents (Latin-1, i.e. 8859-1). Files can be saved to ASCII or a bunch of other encodings.
  • »25.06.18 - 09:31
    Profile