Exemplo n.º 1
0
#ifndef PT_ORIG_R3
#define PT_ORIG_R3 34
#endif /* !PT_ORIG_R3 */

#define ORIG_ACCUM	(sizeof(unsigned long) * PT_R0)
#define ACCUM		(sizeof(unsigned long) * PT_R3)
#define ACCUM_FLAGS	(sizeof(unsigned long) * PT_CCR)
#define SO_MASK		0x10000000

#define ARG_OFFSET(i)	(((i) == 0)				\
		? (sizeof(unsigned long) * PT_ORIG_R3)		\
		: (sizeof(unsigned long) * ((i) + PT_R3)))

pink_bitness_t
pink_bitness_get(PINK_GCC_ATTR((unused)) pid_t pid)
{
#if defined(POWERPC)
	return PINK_BITNESS_32;
#elif defined(POWERPC64)
	return PINK_BITNESS_64;
#else
#error unsupported architecture
#endif
}

inline
unsigned short
pink_bitness_wordsize(PINK_GCC_ATTR((unused)) pink_bitness_t bitness)
{
#if defined(POWERPC)
Exemplo n.º 2
0
typedef struct {
	PyObject_HEAD
	pink_socket_address_t addr;
} Address;

static char pinkpy_socket_has_socketcall_doc[] = ""
	"Returns C{True} if the socket calls - like connect, bind, sendto etc. - are\n"
	"implemented as subcalls of the socketcall(2) system call, C{False} otherwise.\n"
	"\n"
	"@note: Availability: Linux\n"
	"\n"
	"@param bitness: The bitness of the traced child\n"
	"(Optional, defaults to C{pinktrace.bitness.DEFAULT_BITNESS})\n"
	"@raise ValueError: Raised if the given bitness is either unsupported or invalid\n";
static PyObject *
pinkpy_socket_has_socketcall(PINK_GCC_ATTR((unused)) PyObject *self,
#if !PINK_OS_LINUX
	PINK_GCC_ATTR((unused))
#endif
	PyObject *args)
{
#if PINK_OS_LINUX
	pink_bitness_t bit;

	bit = PINKTRACE_BITNESS_DEFAULT;
	if (!PyArg_ParseTuple(args, "|I", &bit))
		return NULL;

	if (!check_bitness(bit))
		return NULL;
pink_bitness_wordsize(pink_bitness_t bitness)
{
	assert(bitness == PINK_BITNESS_32 || bitness == PINK_BITNESS_64);

	switch (bitness) {
	case PINK_BITNESS_32:
		return 4;
	case PINK_BITNESS_64:
		return 8;
	default:
		abort();
	}
}

bool
pink_util_get_syscall(pid_t pid, PINK_GCC_ATTR((unused)) pink_bitness_t bitness, long *res)
{
	return pink_util_peek(pid, ORIG_ACCUM, res);
}

bool
pink_util_set_syscall(pid_t pid, PINK_GCC_ATTR((unused)) pink_bitness_t bitness, long scno)
{
	return pink_util_poke(pid, ORIG_ACCUM, scno);
}

bool
pink_util_get_return(pid_t pid, long *res)
{
	assert(res != NULL);