VirtualBox

Ignore:
Timestamp:
Oct 7, 2010 10:54:44 PM (14 years ago)
Author:
vboxsync
Message:

tstDisasm-2: made it accept linux panic byte code sequences w/ highlighting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp

    r28800 r32992  
    584584 *
    585585 * @returns VBox status code.
    586  * @param   argv0       Program name (for errors and warnings).
    587  * @param   enmCpuMode  The cpu mode to disassemble in.
    588  * @param   uAddress    The address we're starting to disassemble at.
    589  * @param   pbFile      Where to start disassemble.
    590  * @param   cbFile      How much to disassemble.
    591  * @param   enmStyle    The assembly output style.
    592  * @param   fListing    Whether to print in a listing like mode.
    593  * @param   enmUndefOp  How to deal with undefined opcodes.
     586 * @param   argv0           Program name (for errors and warnings).
     587 * @param   enmCpuMode      The cpu mode to disassemble in.
     588 * @param   uAddress        The address we're starting to disassemble at.
     589 * @param   uHighlightAddr  The address of the instruction that should be
     590 *                          highlighted.  Pass UINT64_MAX to keep quiet.
     591 * @param   pbFile          Where to start disassemble.
     592 * @param   cbFile          How much to disassemble.
     593 * @param   enmStyle        The assembly output style.
     594 * @param   fListing        Whether to print in a listing like mode.
     595 * @param   enmUndefOp      How to deal with undefined opcodes.
    594596 */
    595 static int MyDisasmBlock(const char *argv0, DISCPUMODE enmCpuMode, uint64_t uAddress, uint8_t *pbFile, size_t cbFile,
     597static int MyDisasmBlock(const char *argv0, DISCPUMODE enmCpuMode, uint64_t uAddress,
     598                         uint64_t uHighlightAddr, uint8_t *pbFile, size_t cbFile,
    596599                         ASMSTYLE enmStyle, bool fListing, UNDEFOPHANDLING enmUndefOp)
    597600{
     
    717720        }
    718721
     722        /* Highlight this instruction? */
     723        if (uHighlightAddr - State.uAddress < State.cbInstr)
     724            RTPrintf("; ^^^^^^^^^^^^^^^^^^^^^\n");
    719725
    720726        /* next */
     
    804810    /* options */
    805811    uint64_t uAddress = 0;
     812    uint64_t uHighlightAddr = UINT64_MAX;
    806813    ASMSTYLE enmStyle = kAsmStyle_Default;
    807814    UNDEFOPHANDLING enmUndefOp = kUndefOp_Fail;
     
    933940        for ( ; iArg < argc; iArg++)
    934941        {
     942            char ch2;
    935943            const char *psz = argv[iArg];
    936944            while (*psz)
    937945            {
    938946                /** @todo this stuff belongs in IPRT, same stuff as mac address reading. Could be reused for IPv6 with a different item size.*/
    939                 /* skip white space */
    940                 while (RT_C_IS_SPACE(*psz))
     947                /* skip white space, and for the benfit of linux panics '<' and '>'. */
     948                while (RT_C_IS_SPACE(ch2 = *psz) || ch2 == '<' || ch2 == '>')
     949                {
     950                    if (ch2 == '<')
     951                        uHighlightAddr = uAddress + cb;
    941952                    psz++;
    942                 if (!*psz)
     953                }
     954                if (!ch2)
    943955                    break;
    944956
     
    947959                if (iNum == -1)
    948960                    return 1;
    949                 if (!RT_C_IS_SPACE(*psz) && *psz)
     961                if (!RT_C_IS_SPACE(ch2 = *psz) && ch2 != '\0' && ch2 != '>')
    950962                {
    951963                    int iDigit = HexDigitToNum(*psz++);
     
    972984         * Disassemble it.
    973985         */
    974         rc = MyDisasmBlock(argv0, enmCpuMode, uAddress, pb, cb, enmStyle, fListing, enmUndefOp);
     986        rc = MyDisasmBlock(argv0, enmCpuMode, uAddress, uHighlightAddr, pb, cb, enmStyle, fListing, enmUndefOp);
    975987    }
    976988    else
     
    9961008             * Disassemble it.
    9971009             */
    998             rc = MyDisasmBlock(argv0, enmCpuMode, uAddress, (uint8_t *)pvFile, cbFile, enmStyle, fListing, enmUndefOp);
     1010            rc = MyDisasmBlock(argv0, enmCpuMode, uAddress, uHighlightAddr, (uint8_t *)pvFile, cbFile, enmStyle, fListing, enmUndefOp);
    9991011            if (RT_FAILURE(rc))
    10001012                break;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette