Code Monkey home page Code Monkey logo

patchwork's Introduction

PatchWork

PatchWork is a debugging tool similar to MuForce and Mungwall. It asserts that calls to AmigaOS libraries are AutoDocs conformous. Illegal parameters (e.g. NULL where a pointer is expected) are reported. PatchWork helps you to make your code more robust and future proof. ๐Ÿ˜‰

The source code was closed, like almost all of my Amiga projects. I have reviewed and reformatted the files, translated the comments from German to English, and made the project compilable on Linux (and probably other targets) using vbcc. The source is now open to everyone for contributing, studying, archiving, or just enjoying the good old Amiga times.

Features

  • Validates commodities, dos, exec, gadtools, graphics, intuition and utility library calls, up to AmigaOS 3.2.
  • Reports to the debugging console (e.g. Sushi).
  • Shows a code extract of the violating code if DisLib by Thomas Richter is installed.
  • 100% hand-made assembler code, so PatchWork only has a neglectable performance impact on your system, and can just be kept running.
  • Works on any 68000 based CPU, no MMU required.
  • GPL licensed, open source.
  • Source Code is available at GitHub.

Example Output

This is how a full PatchWork hit with all options enabled looks like:

exec.library OldOpenLibrary("dos.library")
Severity 1: obsoleted, use OpenLibrary() instead
PC=07E9BCFC TCB=07BF34A0 ("Shell Process")
Data: FFFFFFFF 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Addr: 07EA2A3A 07E9FF46 00000000 00000000 00000000 00000000 078007F8 07BF4510
----> 07EA2A3A - "pwtest"	Hunk 0001, Offset 00008A4A
----> 07E9FF46 - "pwtest"	Hunk 0001, Offset 00005F56
PC-8: 51CEFF22 4E7570FF 23C007EA 251E41FA 6D4E23C8 07EA2522 43FA4250 2C780004
PC *: 4EAEFE68 23C007EA 253A6100 7F886100 089A23C0 07EA266A 6700024C 203C0000
07e9bcdc :  51ce ff22                  dbra d6,$7e9bc00
07e9bce0 :  4e75                       rts
07e9bce2 :  70ff                       moveq.l #-$1,d0
07e9bce4 :  23c0 07ea 251e             move.l d0,$7ea251e
07e9bcea :  41fa 6d4e                  lea.l $7ea2a3a(pc),a0
07e9bcee :  23c8 07ea 2522             move.l a0,$7ea2522
07e9bcf4 :  43fa 4250                  lea.l $7e9ff46(pc),a1
07e9bcf8 :  2c78 0004                  movea.l $4.w,a6
07e9bcfc : *4eae fe68                  jsr -$198(a6)
07e9bd00 :  23c0 07ea 253a             move.l d0,$7ea253a
07e9bd06 :  6100 7f88                  bsr $7ea3c90
07e9bd0a :  6100 089a                  bsr $7e9c5a6
07e9bd0e :  23c0 07ea 266a             move.l d0,$7ea266a
07e9bd14 :  6700 024c                  beq $7e9bf62
07e9bd18 :  203c 0000 2800             move.l #$2800,d0
Stck: 07E9BD00 07BA246C 00000001 00F95C92 00000FA0 4D656761 20536F75 6E644372
Stck: 61636B65 72000000 07BF5E28 00000B48 02090909 05050500 00001111 114E4E4E
----> 07E9BCFC - "pwtest"	Hunk 0001, Offset 00001D0C
----> 07E9BD00 - "pwtest"	Hunk 0001, Offset 00001D10
----> 07BA246C - "pwtest"	Hunk 0000, Offset 0000000C
----> 00F95C92 - "ROM - dos 40.3 (1.4.93)"	Hunk 0000, Offset 000005AE

Building from Source

This project is mainly made to be build on Linux machines. However, with a few modifications it can also be built on AmigaOS and other operating systems.

Requirements:

Set the AMIGA_NDK env variable to the location of the unpacked NDK3.2 directory on your build machine. Also set AMIGA_INCLUDES to the location of 3rd party include files, where the disassembler.library includes can be found.

Then just invoke make to build the project. The compiled project can be found in the build directory.

make release will compile a release version in the release directory.

Today's standard encoding is UTF-8. Unfortunately AmigaOS does not support this encoding, so the files in this project have different encodings depending on their purpose. The assembler files must use plain ASCII encoding, so they can be edited on Linux and Amiga without encoding problems. For special characters in strings, always use escape sequences. Do not use special characters in comments. make check will test if these files contain illegal characters. All purely Amiga-related files (like AmigaGuide files) are expected to be ISO-8859-1 encoded. Then again, README.md (and other files related to the open source release) are UTF-8 encoded. If you are in doubt, use plain ASCII.

Contribution and Releases

The source code of this project can be found at the official GitHub page.

If you found a bug or have a feature request, feel free to open an issue or send a pull request.

Official binaries are available on the AmiNet.

Please keep the "PatchWork" package name reserved for official releases. If you want to release a fork, use a different package name. But please consider contributing to the reference repository instead. This is better than having an unknown number of different versions circulating around.

License

PatchWork is distributed under GPLv3 (Gnu Public License).

patchwork's People

Contributors

shred avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

patchwork's Issues

Possibility to "pause" PatchWork without stopping/restarting it

Hi again!
Now that I found that Cubic IDE generates all these "hits" for RectFill() (and other programs in other libraries, like MiamiDX for CreateIORequest()), I'd like to pause PatchWork :-) Right now, I start PatchWork along with other debug-related programs, like MuForce, MungWall, Sashimi... I could certainly add something in ToolsDaemon but I wonder, wouldn't be cool if PatchWork had an ARexx port that would listen to some command like "RUN"/"STOP" or "PAUSE"?
Maybe it's a sledgehammer to crush a nut? If not, I could maybe try to implement that a send you a pull request?
Cheers!

Allow excluding some of the checks?

Hi!
I'm using PatchWork on my development Amiga and I noticed a lot of "hit" with Miami Airport (ioReplyPort not initialized) and graphics.library (RectFill max must be >= min). They kind of "clutter" my console and there's nothing much I can do about them, so I wonder if PatchWork could have an option to silence some checks?
Thanks for this great tool!

MuForce hit with TextEdit/SetPointer

@Hagbard-Celin reported this MuForce hit via email:

 SetPointer(0x04A253D4,0x00000000,13292,337,201,63)
Severity 0: hot spot is outside of the sprite
PC=7774049B TCB=04A258A8 ("TextEdit")
Data: 049F33EC 00F80151 01FC00C9 0016003F 004E0071 40074014 6E20126F 04A870A4
Addr: 04A253D4 00000000 00000000 0000042F A56004AD 88A0040B 040A0000 000004AC
Stck: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Stck: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
*MuForce Hit
BYTE READ from 047A72BF                        PC: 04784724
USP : 04776980 SR: 0000  (U0)(-)(-)  TCB: 04774EA8
Data: 00010006 00000074 00000001 00000000 00008003 00000001 00000002 00000000
Addr: 047972B8 04778EE0 04771DB0 00000000 0479E8B8 00000000 04771DFC 040022A4
Stck: 00000000 00000002 00000000 04784404 FFFFFFFF FFFFFFFF 00000000 00000000
Stck: 00000000 00000000 011DDB8F 00000000 00000000 04771DD0 04771E68 04771DFC
----> 04784724 - "sc:c/se"  Hunk 0000 Offset 00000BC4
----> 04784404 - "sc:c/se"  Hunk 0000 Offset 000008A4
04784702 :  6100 1f8c                  bsr $4786690
04784706 :  7800                       moveq.l #$0,d4
04784708 :  3800                       move.w d0,d4
0478470a :  2004                       move.l d4,d0
0478470c :  5280                       addq.l #$1,d0
0478470e :  6604                       bne.s $4784714
04784710 :  6100 0c0a                  bsr $478531c
04784714 :  0c84 0000 0100             cmpi.l #$100,d4
0478471a :  6d1a                       blt.s $4784736
0478471c :  2004                       move.l d4,d0
0478471e :  d080                       add.l d0,d0
04784720 :  41ec 8a00                  lea.l -$7600(a4),a0
04784724 : *0830 0003 0801             btst #$3,$1(a0,d0.l)
0478472a :  670a                       beq.s $4784736
0478472c :  206c 731e                  movea.l $731e(a4),a0
04784730 :  6100 1564                  bsr $4785c96
04784734 :  7a00                       moveq.l #$0,d5
04784736 :  6100 3258                  bsr $4787990
0478473a :  4a80                       tst.l d0
0478473c :  6704                       beq.s $4784742
0478473e :  6100 0bdc                  bsr $478531c
04784742 :  7200                       moveq.l #$0,d1
Name: "sc:c/se"  Hunk 0000 Offset 00000BC4

*MuForce Hit
BYTE READ from 047A72BF                        PC: 04784724
USP : 04776980 SR: 0000  (U0)(-)(-)  TCB: 04774EA8
Data: 00010006 00000074 00000001 00000000 00008003 00000001 00000002 00000000
Addr: 047972B8 04778EE0 04771DB0 00000000 0479E8B8 00000000 04771DFC 040022A4
Stck: 00000000 00000002 00000000 04784404 FFFFFFFF FFFFFFFF 00000000 00000000
Stck: 00000000 00000000 011DDB8F 00000000 00000000 04771DD0 04771E68 04771DFC

Addendum:

*MuForce Hit
BYTE READ from 30010405                        PC: 041E9A2C
USP : 04737AB0 SR: 0000  (U0)(F)(-)  TCB: 046E06B8
Data: 30010405 0000000F 00000001 0000FFFF 0009EC73 FFFFFFFF 00000000 00000000
Addr: 041BB682 041BB682 042A2DD4 30010406 041BB6B2 04737BA4 041E4B40 040022A4
Stck: 0000FFFF 0009EC73 00000000 04737BF0 0000C0FF 04737BD4 041BB682 042A2DD4
Stck: 041E4B40 00257300 54200750 042A2DD4 041BB683 041E4B40 042A2DD4 041E4B40
----> 041E9A2C - "LIBS:locale.library"  Hunk 0000 Offset 0000482C
----> 041BB682 - "PatchWork"  Hunk 0000 Offset 0000367A
----> 041BB683 - "PatchWork"  Hunk 0000 Offset 0000367B
041e9a0c :  2a6f 00d8                  movea.l $d8(a7),a5
041e9a10 :  601a                       bra.s $41e9a2c
041e9a12 :  7000                       moveq.l #$0,d0
041e9a14 :  102f 0024                  move.b $24(a7),d0
041e9a18 :  2f0a                       move.l a2,-(a7)
041e9a1a :  2240                       movea.l d0,a1
041e9a1c :  204d                       movea.l a5,a0
041e9a1e :  2c6e 005c                  movea.l $5c(a6),a6
041e9a22 :  4eae ff9a                  jsr -$66(a6)
041e9a26 :  245f                       movea.l (a7)+,a2
041e9a28 :  2c6f 0034                  movea.l $34(a7),a6
041e9a2c : *101b                       move.b (a3)+,d0
041e9a2e :  1f40 0024                  move.b d0,$24(a7)
041e9a32 :  66de                       bne.s $41e9a12
041e9a34 :  2c6f 0034                  movea.l $34(a7),a6
041e9a38 :  6000 00fe                  bra $41e9b38
041e9a3c :  7073                       moveq.l #$73,d0
041e9a3e :  b02f 0026                  cmp.b $26(a7),d0
041e9a42 :  2c6f 0034                  movea.l $34(a7),a6
041e9a46 :  6610                       bne.s $41e9a58
041e9a48 :  200b                       move.l a3,d0
041e9a4a :  670c                       beq.s $41e9a58
Name: "TextEdit"

 SetPointer(0x047362E4,0x00000000,29204,330,201,92)
Severity 0: hot spot is outside of the sprite
PC=17240469 TCB=046E06B8 ("TextEdit")
Data: 046D7214 00E1014A 01FC00C9 001B005C 004E0071 40074014 6E20126F 047CE294
Addr: 047362E4 00000000 00000000 0000042F 8DD00483 1E18040B 040A0000 00000483
Stck: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Stck: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

MuForce hit with GoldEd/SetPointer

@Hagbard-Celin reported this MuForce hit via email:

*MuForce Hit
LONG READ from 120F000A                        PC: 041B8794
USP : 0472E878 SR: 0018  (U0)(F)(-)  TCB: 0471EBA0
Data: 041BB7FF 000000FF 00000001 0000FFFF 00000066 00000000 0472E890 000012FF
Addr: 041BB682 120F0000 041BB6C4 047FC1C0 041BB6B2 0471637C 04000884 040022A4
Stck: 00000000 00000000 00004D04 0000001E 000002CF 00000043 00000000 041BB74D
Stck: 00000000 00000000 00000001 0000FFFF 00000066 0000000F 0000000F 0000127F
----> 041B8794 - "PatchWork"  Hunk 0000 Offset 0000078C
----> 041BB74D - "PatchWork"  Hunk 0000 Offset 00003745
041b8774 :  4241                       clr.w d1
041b8776 :  4841                       swap.l d1
041b8778 :  0800 0003                  btst #$3,d0
041b877c :  6706                       beq.s $41b8784
041b877e :  c2bc 0000 00ff             and.l #$ff,d1
041b8784 :  0800 0004                  btst #$4,d0
041b8788 :  6702                       beq.s $41b878c
041b878a :  e589                       lsl.l #$2,d1
041b878c :  2f01                       move.l d1,-(a7)
041b878e :  60b8                       bra.s $41b8748
041b8790 :  226d 0038                  movea.l $38(a5),a1
041b8794 : *2f29 000a                  move.l $a(a1),-(a7)
041b8798 :  224f                       movea.l a7,a1
041b879a :  4eb9 041b c464             jsr $41bc464
041b87a0 :  2e46                       movea.l d6,a7
041b87a2 :  2f05                       move.l d5,-(a7)
041b87a4 :  41fa 0124                  lea.l $41b88ca(pc),a0
041b87a8 :  224f                       movea.l a7,a1
041b87aa :  4eb9 041b c464             jsr $41bc464
041b87b0 :  588f                       addq.l #$4,a7
041b87b2 :  4cdf 0102                  movem.l (a7)+,d1/a0
Name: "Background CLI"  CLI: "golded:golded"

 SetPointer(0x00000000,0x00000000,19716,30,719,67)
Severity 0: hot spot is outside of the sprite
PC=651C03FF TCB=0471EBA0 ("Background CLI")
Data: 046C4D04 0066001E 033302CF 00410043 033302CF 033302CF 2820327F 00000000
Addr: 00000000 00000000 00000000 0000042F A5600491 9250040B 120F0000 00000471
Stck: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Stck: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

*MuForce Hit
BYTE READ from 2B4000B4                        PC: 041EABB4
USP : 04A27D28 SR: 0000  (U0)(F)(-)  TCB: 04A258A8
Data: 2B4000B4 0000000F 00000001 0000FFFF 000F1A89 FFFFFFFF 00000000 00000000
Addr: 041BB682 041BB682 042A3564 2B4000B5 041BB6B2 04A27E1C 041E5CC8 040022A4
Stck: 0000FFFF 000F1A89 00000000 04A27E68 0000C0FF 04A27E4C 041BB682 042A3564
Stck: 041E5CC8 00257300 541F9E21 042A3564 041BB683 041E5CC8 042A3564 041E5CC8
----> 041EABB4 - "LIBS:locale.library"  Hunk 0000 Offset 0000482C
----> 041BB682 - "PatchWork"  Hunk 0000 Offset 0000367A
----> 041BB683 - "PatchWork"  Hunk 0000 Offset 0000367B
041eab94 :  2a6f 00d8                  movea.l $d8(a7),a5
041eab98 :  601a                       bra.s $41eabb4
041eab9a :  7000                       moveq.l #$0,d0
041eab9c :  102f 0024                  move.b $24(a7),d0
041eaba0 :  2f0a                       move.l a2,-(a7)
041eaba2 :  2240                       movea.l d0,a1
041eaba4 :  204d                       movea.l a5,a0
041eaba6 :  2c6e 005c                  movea.l $5c(a6),a6
041eabaa :  4eae ff9a                  jsr -$66(a6)
041eabae :  245f                       movea.l (a7)+,a2
041eabb0 :  2c6f 0034                  movea.l $34(a7),a6
041eabb4 : *101b                       move.b (a3)+,d0
041eabb6 :  1f40 0024                  move.b d0,$24(a7)
041eabba :  66de                       bne.s $41eab9a
041eabbc :  2c6f 0034                  movea.l $34(a7),a6
041eabc0 :  6000 00fe                  bra $41eacc0
041eabc4 :  7073                       moveq.l #$73,d0
041eabc6 :  b02f 0026                  cmp.b $26(a7),d0
041eabca :  2c6f 0034                  movea.l $34(a7),a6
041eabce :  6610                       bne.s $41eabe0
041eabd0 :  200b                       move.l a3,d0
041eabd2 :  670c                       beq.s $41eabe0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.