tools/reorder/addrs2text.cpp
author Lukas Blakk <lsblakk@mozilla.com>
Mon, 28 Oct 2013 13:50:56 -0700
changeset 154274 4df30f97564f54374a624a8be8e45b9799bfa97b
parent 98529 f4157e8c410708d76703f19e4dfb61859bfe32d8
permissions -rw-r--r--
Tagging end of BETA24 CLOSED TREE DONTBUILD

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/*

  Converts a binary stream of address references to a text stream,
  hexadecimal, newline separated.

 */

#include <stdio.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
    unsigned int buf[1024];
    ssize_t cb;

    while ((cb = read(STDIN_FILENO, buf, sizeof buf)) > 0) {
        if (cb % sizeof buf[0])
            fprintf(stderr, "unaligned read\n");

        unsigned int *addr = buf;
        unsigned int *limit = buf + (cb / 4);

        for (; addr < limit; ++addr)
            printf("%x\n", *addr);
    }

    return 0;
}