tracechild.cc (8229:78bf55f23338) tracechild.cc (11321:02e930db812d)
1/*
2 * Copyright (c) 2007 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 257 unchanged lines hidden (view full) ---

266 cargv = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
267 sprintf(obuf, "0x%016lx: argv[%d] = 0x%016lx\n",
268 sp, argCount++, cargv);
269 if (cargv)
270 if (highestInfo < cargv)
271 highestInfo = cargv;
272 os << obuf;
273 sp += 8;
1/*
2 * Copyright (c) 2007 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 257 unchanged lines hidden (view full) ---

266 cargv = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
267 sprintf(obuf, "0x%016lx: argv[%d] = 0x%016lx\n",
268 sp, argCount++, cargv);
269 if (cargv)
270 if (highestInfo < cargv)
271 highestInfo = cargv;
272 os << obuf;
273 sp += 8;
274 } while(cargv);
274 } while (cargv);
275
276 //Output the envp pointers
277 int envCount = 0;
278 uint64_t cenvp;
279 do {
280 cenvp = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
281 sprintf(obuf, "0x%016lx: envp[%d] = 0x%016lx\n",
282 sp, envCount++, cenvp);
283 os << obuf;
284 sp += 8;
275
276 //Output the envp pointers
277 int envCount = 0;
278 uint64_t cenvp;
279 do {
280 cenvp = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
281 sprintf(obuf, "0x%016lx: envp[%d] = 0x%016lx\n",
282 sp, envCount++, cenvp);
283 os << obuf;
284 sp += 8;
285 } while(cenvp);
285 } while (cenvp);
286 uint64_t auxType, auxVal;
287 do {
288 auxType = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
289 sp += 8;
290 auxVal = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
291 sp += 8;
292 sprintf(obuf, "0x%016lx: Auxiliary vector = {0x%016lx, 0x%016lx}\n",
293 sp - 16, auxType, auxVal);
294 os << obuf;
286 uint64_t auxType, auxVal;
287 do {
288 auxType = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
289 sp += 8;
290 auxVal = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
291 sp += 8;
292 sprintf(obuf, "0x%016lx: Auxiliary vector = {0x%016lx, 0x%016lx}\n",
293 sp - 16, auxType, auxVal);
294 os << obuf;
295 } while(auxType != 0 || auxVal != 0);
295 } while (auxType != 0 || auxVal != 0);
296 //Print out the argument strings, environment strings, and file name.
297 string current;
298 uint64_t buf;
299 uint64_t currentStart = sp;
300 bool clearedInitialPadding = false;
301 do {
302 buf = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
303 char * cbuf = (char *)&buf;

--- 20 unchanged lines hidden (view full) ---

324 uint64_t rip = getPC();
325 bool foundOpcode = false;
326 bool twoByteOpcode = false;
327 for (;;) {
328 uint64_t buf = ptrace(PTRACE_PEEKDATA, pid, rip, 0);
329 for (int i = 0; i < sizeof(uint64_t); i++) {
330 unsigned char byte = buf & 0xFF;
331 if (!foundOpcode) {
296 //Print out the argument strings, environment strings, and file name.
297 string current;
298 uint64_t buf;
299 uint64_t currentStart = sp;
300 bool clearedInitialPadding = false;
301 do {
302 buf = ptrace(PTRACE_PEEKDATA, pid, sp, 0);
303 char * cbuf = (char *)&buf;

--- 20 unchanged lines hidden (view full) ---

324 uint64_t rip = getPC();
325 bool foundOpcode = false;
326 bool twoByteOpcode = false;
327 for (;;) {
328 uint64_t buf = ptrace(PTRACE_PEEKDATA, pid, rip, 0);
329 for (int i = 0; i < sizeof(uint64_t); i++) {
330 unsigned char byte = buf & 0xFF;
331 if (!foundOpcode) {
332 if(!(byte == 0x66 || //operand override
332 if (!(byte == 0x66 || //operand override
333 byte == 0x67 || //address override
334 byte == 0x2E || //cs
335 byte == 0x3E || //ds
336 byte == 0x26 || //es
337 byte == 0x64 || //fs
338 byte == 0x65 || //gs
339 byte == 0x36 || //ss
340 byte == 0xF0 || //lock

--- 49 unchanged lines hidden (view full) ---

390 //Put things back to the way they started
391 ptrace(PTRACE_POKEDATA, pid, ripAfterSyscall, buf);
392 } else {
393 //Get all the way past repe and repne string instructions in one shot.
394 uint64_t newPC, origPC = getPC();
395 do {
396 ptraceSingleStep();
397 newPC = getPC();
333 byte == 0x67 || //address override
334 byte == 0x2E || //cs
335 byte == 0x3E || //ds
336 byte == 0x26 || //es
337 byte == 0x64 || //fs
338 byte == 0x65 || //gs
339 byte == 0x36 || //ss
340 byte == 0xF0 || //lock

--- 49 unchanged lines hidden (view full) ---

390 //Put things back to the way they started
391 ptrace(PTRACE_POKEDATA, pid, ripAfterSyscall, buf);
392 } else {
393 //Get all the way past repe and repne string instructions in one shot.
394 uint64_t newPC, origPC = getPC();
395 do {
396 ptraceSingleStep();
397 newPC = getPC();
398 } while(newPC == origPC);
398 } while (newPC == origPC);
399 }
400}
401
402TraceChild * genTraceChild()
403{
404 return new AMD64TraceChild;
405}
399 }
400}
401
402TraceChild * genTraceChild()
403{
404 return new AMD64TraceChild;
405}