bsd-user: GPL v2 attribution update and style
Signed-off-by: Sean Bruno <sbruno@freebsd.org> Message-id: 1402246651-71099-3-git-send-email-sbruno@freebsd.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
adfc3e91e2
commit
88dae46d18
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* qemu bsd user mode definition
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#ifndef QEMU_H
|
#ifndef QEMU_H
|
||||||
#define QEMU_H
|
#define QEMU_H
|
||||||
|
|
||||||
@ -150,6 +166,16 @@ void fork_end(int child);
|
|||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
|
|
||||||
/* strace.c */
|
/* strace.c */
|
||||||
|
struct syscallname {
|
||||||
|
int nr;
|
||||||
|
const char *name;
|
||||||
|
const char *format;
|
||||||
|
void (*call)(const struct syscallname *,
|
||||||
|
abi_long, abi_long, abi_long,
|
||||||
|
abi_long, abi_long, abi_long);
|
||||||
|
void (*result)(const struct syscallname *, abi_long);
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
print_freebsd_syscall(int num,
|
print_freebsd_syscall(int num,
|
||||||
abi_long arg1, abi_long arg2, abi_long arg3,
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
||||||
|
@ -1,37 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* System call tracing and debugging
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
#include <sys/ioccom.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "qemu.h"
|
#include "qemu.h"
|
||||||
|
|
||||||
int do_strace=0;
|
int do_strace;
|
||||||
|
|
||||||
struct syscallname {
|
|
||||||
int nr;
|
|
||||||
const char *name;
|
|
||||||
const char *format;
|
|
||||||
void (*call)(const struct syscallname *,
|
|
||||||
abi_long, abi_long, abi_long,
|
|
||||||
abi_long, abi_long, abi_long);
|
|
||||||
void (*result)(const struct syscallname *, abi_long);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility functions
|
* Utility functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void print_execve(const struct syscallname *name, abi_long arg1,
|
||||||
print_execve(const struct syscallname *name,
|
abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5,
|
||||||
abi_long arg1, abi_long arg2, abi_long arg3,
|
abi_long arg6)
|
||||||
abi_long arg4, abi_long arg5, abi_long arg6)
|
|
||||||
{
|
{
|
||||||
abi_ulong arg_ptr_addr;
|
abi_ulong arg_ptr_addr;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (!(s = lock_user_string(arg1)))
|
s = lock_user_string(arg1);
|
||||||
|
if (s == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
gemu_log("%s(\"%s\",{", name->name, s);
|
gemu_log("%s(\"%s\",{", name->name, s);
|
||||||
unlock_user(s, arg1, 0);
|
unlock_user(s, arg1, 0);
|
||||||
|
|
||||||
@ -39,18 +51,19 @@ print_execve(const struct syscallname *name,
|
|||||||
abi_ulong *arg_ptr, arg_addr;
|
abi_ulong *arg_ptr, arg_addr;
|
||||||
|
|
||||||
arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
|
arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
|
||||||
if (!arg_ptr)
|
if (!arg_ptr) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
arg_addr = tswapl(*arg_ptr);
|
arg_addr = tswapl(*arg_ptr);
|
||||||
unlock_user(arg_ptr, arg_ptr_addr, 0);
|
unlock_user(arg_ptr, arg_ptr_addr, 0);
|
||||||
if (!arg_addr)
|
if (!arg_addr) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if ((s = lock_user_string(arg_addr))) {
|
if ((s = lock_user_string(arg_addr))) {
|
||||||
gemu_log("\"%s\",", s);
|
gemu_log("\"%s\",", s);
|
||||||
unlock_user(s, arg_addr, 0);
|
unlock_user(s, arg_addr, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gemu_log("NULL})");
|
gemu_log("NULL})");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,10 +71,9 @@ print_execve(const struct syscallname *name,
|
|||||||
* Variants for the return value output function
|
* Variants for the return value output function
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
|
||||||
print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
|
|
||||||
{
|
{
|
||||||
if( ret == -1 ) {
|
if (ret == -1) {
|
||||||
gemu_log(" = -1 errno=%d (%s)\n", errno, strerror(errno));
|
gemu_log(" = -1 errno=%d (%s)\n", errno, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
|
gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
|
||||||
@ -90,10 +102,9 @@ static const struct syscallname openbsd_scnames[] = {
|
|||||||
#include "openbsd/strace.list"
|
#include "openbsd/strace.list"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void print_syscall(int num, const struct syscallname *scnames,
|
||||||
print_syscall(int num, const struct syscallname *scnames, unsigned int nscnames,
|
unsigned int nscnames, abi_long arg1, abi_long arg2, abi_long arg3,
|
||||||
abi_long arg1, abi_long arg2, abi_long arg3,
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
||||||
abi_long arg4, abi_long arg5, abi_long arg6)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
|
const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
|
||||||
@ -102,36 +113,37 @@ print_syscall(int num, const struct syscallname *scnames, unsigned int nscnames,
|
|||||||
|
|
||||||
gemu_log("%d ", getpid() );
|
gemu_log("%d ", getpid() );
|
||||||
|
|
||||||
for (i = 0; i < nscnames; i++)
|
for (i = 0; i < nscnames; i++) {
|
||||||
if (scnames[i].nr == num) {
|
if (scnames[i].nr == num) {
|
||||||
if (scnames[i].call != NULL) {
|
if (scnames[i].call != NULL) {
|
||||||
scnames[i].call(&scnames[i], arg1, arg2, arg3, arg4, arg5,
|
scnames[i].call(&scnames[i], arg1, arg2, arg3, arg4, arg5,
|
||||||
arg6);
|
arg6);
|
||||||
} else {
|
} else {
|
||||||
/* XXX: this format system is broken because it uses
|
/* XXX: this format system is broken because it uses
|
||||||
host types and host pointers for strings */
|
host types and host pointers for strings */
|
||||||
if (scnames[i].format != NULL)
|
if (scnames[i].format != NULL) {
|
||||||
format = scnames[i].format;
|
format = scnames[i].format;
|
||||||
gemu_log(format, scnames[i].name, arg1, arg2, arg3, arg4,
|
}
|
||||||
arg5, arg6);
|
gemu_log(format, scnames[i].name, arg1, arg2, arg3, arg4, arg5,
|
||||||
|
arg6);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
gemu_log("Unknown syscall %d\n", num);
|
gemu_log("Unknown syscall %d\n", num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void print_syscall_ret(int num, abi_long ret,
|
||||||
print_syscall_ret(int num, abi_long ret, const struct syscallname *scnames,
|
const struct syscallname *scnames, unsigned int nscnames)
|
||||||
unsigned int nscnames)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < nscnames; i++)
|
for (i = 0; i < nscnames; i++) {
|
||||||
if (scnames[i].nr == num) {
|
if (scnames[i].nr == num) {
|
||||||
if (scnames[i].result != NULL) {
|
if (scnames[i].result != NULL) {
|
||||||
scnames[i].result(&scnames[i], ret);
|
scnames[i].result(&scnames[i], ret);
|
||||||
} else {
|
} else {
|
||||||
if( ret < 0 ) {
|
if (ret < 0) {
|
||||||
gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", -ret,
|
gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", -ret,
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
} else {
|
} else {
|
||||||
@ -140,52 +152,50 @@ print_syscall_ret(int num, abi_long ret, const struct syscallname *scnames,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The public interface to this module.
|
* The public interface to this module.
|
||||||
*/
|
*/
|
||||||
void
|
void print_freebsd_syscall(int num, abi_long arg1, abi_long arg2, abi_long arg3,
|
||||||
print_freebsd_syscall(int num,
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
||||||
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
||||||
abi_long arg4, abi_long arg5, abi_long arg6)
|
|
||||||
{
|
{
|
||||||
print_syscall(num, freebsd_scnames, ARRAY_SIZE(freebsd_scnames),
|
|
||||||
arg1, arg2, arg3, arg4, arg5, arg6);
|
print_syscall(num, freebsd_scnames, ARRAY_SIZE(freebsd_scnames), arg1, arg2,
|
||||||
|
arg3, arg4, arg5, arg6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void print_freebsd_syscall_ret(int num, abi_long ret)
|
||||||
print_freebsd_syscall_ret(int num, abi_long ret)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
print_syscall_ret(num, ret, freebsd_scnames, ARRAY_SIZE(freebsd_scnames));
|
print_syscall_ret(num, ret, freebsd_scnames, ARRAY_SIZE(freebsd_scnames));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void print_netbsd_syscall(int num, abi_long arg1, abi_long arg2, abi_long arg3,
|
||||||
print_netbsd_syscall(int num,
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
||||||
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
||||||
abi_long arg4, abi_long arg5, abi_long arg6)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
print_syscall(num, netbsd_scnames, ARRAY_SIZE(netbsd_scnames),
|
print_syscall(num, netbsd_scnames, ARRAY_SIZE(netbsd_scnames),
|
||||||
arg1, arg2, arg3, arg4, arg5, arg6);
|
arg1, arg2, arg3, arg4, arg5, arg6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void print_netbsd_syscall_ret(int num, abi_long ret)
|
||||||
print_netbsd_syscall_ret(int num, abi_long ret)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
print_syscall_ret(num, ret, netbsd_scnames, ARRAY_SIZE(netbsd_scnames));
|
print_syscall_ret(num, ret, netbsd_scnames, ARRAY_SIZE(netbsd_scnames));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void print_openbsd_syscall(int num, abi_long arg1, abi_long arg2, abi_long arg3,
|
||||||
print_openbsd_syscall(int num,
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
||||||
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
||||||
abi_long arg4, abi_long arg5, abi_long arg6)
|
|
||||||
{
|
{
|
||||||
print_syscall(num, openbsd_scnames, ARRAY_SIZE(openbsd_scnames),
|
|
||||||
arg1, arg2, arg3, arg4, arg5, arg6);
|
print_syscall(num, openbsd_scnames, ARRAY_SIZE(openbsd_scnames), arg1, arg2,
|
||||||
|
arg3, arg4, arg5, arg6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void print_openbsd_syscall_ret(int num, abi_long ret)
|
||||||
print_openbsd_syscall_ret(int num, abi_long ret)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
print_syscall_ret(num, ret, openbsd_scnames, ARRAY_SIZE(openbsd_scnames));
|
print_syscall_ret(num, ret, openbsd_scnames, ARRAY_SIZE(openbsd_scnames));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user