GaloisInc / flexdis86

A library for disassembling x86-64 binaries.
BSD 3-Clause "New" or "Revised" License
37 stars 10 forks source link

transition from ansi-wl-pprint to prettyprinter #53

Closed Ptival closed 1 year ago

Ptival commented 1 year ago

Prep work for transitioning away from ansi-wl-pprint.

Will likely need some synchronized changes in dependencies.

Ptival commented 1 year ago

I wrote the following tiny bash script to at least check whether there are differences for the pretty-printing of instructions:

#!/usr/bin/env bash
set -euv

case $1 in
    "dump")
        echo "Dumping ${2} to dump.bytes"
        objdump -d "${2}" | grep ": " | cut -b 11-40 > dump.bytes
        ;;
    "test")
        echo "Testing dump.bytes"
        cat dump.bytes | while read line
        do
            cabal run DumpInstr $line | sed "2q;d"
        done
        ;;
esac

And I found at least one regression (new version adds a space after commas), e.g.:

image

Fixing it.

Ptival commented 1 year ago

I did a comparative test over a binary with ~5k individual instructions, and found no discrepancy after my last patch.

kquick commented 1 year ago

I did a comparative test over a binary with ~5k individual instructions, and found no discrepancy after my last patch.

Thanks! I almost prefer the spaces after the commas, but deviation like that would be better left for a different effort. This looks good to me.

RyanGlScott commented 1 year ago

I'm curious if there are any breakages that are uncovered when trying to use this change to build the macaw-x86-symbolic. (If you can get that far, there's a pretty good chance that SAW will also work.)

Ptival commented 1 year ago

All of macaw (i.e. cabal build all) seems to build with these changes.

Ptival commented 1 year ago

Alright, I'll attempt a merge of this, and I'll take responsibility if it affects anyone downstream.