99strace

command
v0.0.0-...-beb9c29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2018 License: BSD-3-Clause Imports: 4 Imported by: 0

README

Table of Contents

  1. Usage
  2. Installation
  3. Changelog
  4. Sample

99strace

Command 99strace traces system calls of programs produced by the 99c compiler.

The trace is written to stderr.

Usage
99strace a.out [arguments]
Installation

To install or update 99strace

 $ go get [-u] -tags virtual.strace github.com/cznic/99c/99strace

Online documentation: godoc.org/github.com/cznic/99c/99strace

Changelog

2017-10-09: Initial public release.

Sample
$ cd ../examples/strace/
$ ls *
data.txt  main.c
$ cat main.c 
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>

#define BUFSIZE 1<<16

int main(int argc, char **argv) {
	char *buf = malloc(BUFSIZE);
	if (!buf) {
		return 1;
	}

	for (int i = 1; i < argc; i++) {
		int fd = open(argv[i], O_RDWR);
		if (fd < 0) {
			return 1;
		}

		ssize_t n;
		while ((n = read(fd, buf, BUFSIZE)) > 0) {
			write(0, buf, n);
		}
	}
	free(buf);
}
$ cat data.txt 
Lorem ipsum.
$ 99c main.c && ./a.out data.txt
Lorem ipsum.
$ 99strace a.out data.txt
malloc(0x10000) 0x7f83a9400020
open("data.txt", O_RDWR, 0) 5 errno 0
read(5, 0x7f83a9400020, 65536) 13 errno 0
Lorem ipsum.
write(0, 0x7f83a9400020, 13) 13 errno 0
read(5, 0x7f83a9400020, 65536) 0 errno 0
freep(0x7f83a9400020)
$ 

Documentation

Overview

Command 99strace traces system calls of programs produced by the 99c compiler.

The trace is written to stderr.

Usage

To trace a.out

99strace a.out [arguments]

Installation

To install or update 99strace

$ go get [-u] -tags virtual.strace github.com/cznic/99c/99strace

Online documentation: godoc.org/github.com/cznic/99c/99strace(http://godoc.org/github.com/cznic/99c/99strace)

Changelog

2017-10-09: Initial public release.

Sample

Example session

$ cd ../examples/strace/
$ ls *
data.txt  main.c
$ cat main.c
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>

#define BUFSIZE 1<<16

int main(int argc, char **argv) {
	char *buf = malloc(BUFSIZE);
	if (!buf) {
		return 1;
	}

	for (int i = 1; i < argc; i++) {
		int fd = open(argv[i], O_RDWR);
		if (fd < 0) {
			return 1;
		}

		ssize_t n;
		while ((n = read(fd, buf, BUFSIZE)) > 0) {
			write(0, buf, n);
		}
	}
	free(buf);
}
$ cat data.txt
Lorem ipsum.
$ 99c main.c && ./a.out data.txt
Lorem ipsum.
$ 99strace a.out data.txt
malloc(0x10000) 0x7f83a9400020
open("data.txt", O_RDWR, 0) 5 errno 0
read(5, 0x7f83a9400020, 65536) 13 errno 0
Lorem ipsum.
write(0, 0x7f83a9400020, 13) 13 errno 0
read(5, 0x7f83a9400020, 65536) 0 errno 0
freep(0x7f83a9400020)
$

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL