shared memory segment can't be removed after call shmdt() - c++

i called shmdt() successfully, but shared memory segment can't be removed..
this is my code:
#include <sys/types.h>
#include <sys/shm.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
key_t key = ftok(".", 'T');
if (key == -1) {
fprintf(stderr, "get key failed, error: %s\n", strerror(errno));
exit(1);
}
int shmid = shmget(key, sizeof(int) * 10, IPC_CREAT);
if (shmid == -1) {
fprintf(stderr, "get shmid failed, error: %s\n", strerror(errno));
exit(1);
}
void* shmaddr = shmat(shmid, NULL, 0);
if (shmaddr == (void*)-1) {
fprintf(stderr, "get shmaddr failed, error: %s\n", strerror(errno));
exit(1);
}
if (shmdt(shmaddr) == -1) {
fprintf(stderr, "detach failed, error: %s\n", strerror(errno));
exit(1);
}
return 0;
}
after that, i execute ipcs -m
# ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 1179648 root 0 4 0
0x00000000 1212417 root 0 4 0
0x00000000 1245186 root 0 4 0
0x00000000 1277955 root 0 4 0
0x00000000 1310724 root 0 4 0
0x00000000 1343493 root 0 4 0
0x00000000 1376262 root 0 4 0
0x00000000 1409031 root 0 4 0
0x00000000 1441800 root 0 4 0
0x00000000 1474569 root 0 4 0
0x54010004 1671178 root 0 40 0
0x00000000 1540107 root 0 4 0

shmdt() detaches the shared memory segment located at the address
specified by shmaddr from the address space of the calling process.
The to-be-detached segment must be currently attached with shmaddr
equal to the value returned by the attaching shmat() call.
shmdt only detaches the calling process from attached memory. It will not remove the shared memory created by the process.
For more information please read the man page of the respective system calls.

Related

Readfile API not reading anything while reading we are getting buffer as empty

Here is some details
Note:- All command are working fine with OSCALL function in compiler VC12
with complier VC14
exe name is RemDicomNodes.exe
CMD command prompt:-
RemDicomNodes 5 6 1 2 3 10 8 9
RemDicomNodes.exe 1 A
RemDicomNodes 2 B B 0 localhost 1 "BE" 104 3 1 7 7 60 0 "" 2 0 0 0 0 "" 3 0 0 0 0 "" 0 6 1 2 3 10 8 9 0 0 0 0 NoConversion 0 0 0 0 1 0 0 1 BE 0 0 0 IPv4 0 0 10 0 1 0
Above all commands are working fine and showing proper output on CMD command prompt
With OSCAll function:-
RemDicomNodes 5 6 1 2 3 10 8 9
#(Working fine i am getting output in variable "outputbuffer" which i am using inside readfile API)
RemDicomNodes.exe 1 A
#(Working fine i am getting output in variable "outputbuffer" which i am using inside readfile API)
RemDicomNodes.exe 2 B B 0 localhost 1 """BE"""" " 104 3 1 7 7 60 0 " """""" " 2 0 0 0 0 " """""" " 3 0 0 0 0 " """"""" 0 6 1 2 3 10 8 9 0 0 0 0 NoConversion 0 0 0 0 1 0 0 0 AE 0 0 0 IPv4 0 0 10 0 1 0"
#Problem(that any arguments we are send but it is not working, i am not getting output in variable "outputbuffer" which i am using inside readfile API it is not printing anything )
This is the function which i am using to run my exe
BOOL MagicWatchComProc::OSCall(CString i_cmd, CString& a_output, DWORD& a_exitCode, long i_timeOut)
{
STARTUPINFO aStartupInfo;
PROCESS_INFORMATION aProcessInfo;
HANDLE hReadHandle = NULL;
HANDLE hWriteHandle = NULL;
HANDLE hErrorHandle = NULL;
DWORD dwBytesRead = 0;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
//time_t l_timeOut = 300000; //5 min.
//reset output string
a_output = "";
DEBUG_TRACE(_T("OSCall: launching ") + i_cmd);
if (!i_cmd)
{
DEBUG_TRACE(_T("OSCall: Error: empty command\n"));
return false;
}
//reset errors
SetLastError(0);
// Initialize process startup structure
FillMemory(&aStartupInfo, sizeof(aStartupInfo), 0);
//GetStartupInfo(&aStartupInfo);
aStartupInfo.cb = sizeof(aStartupInfo);
aStartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
aStartupInfo.wShowWindow = SW_HIDE;
// Create pipe that will transfer the process output to our buffer
if(!CreatePipe(&hReadHandle, &hWriteHandle, &sa, 0))
{
DEBUG_TRACE(_T("OSCall: Error: Pipe creation\n"));
return false;
}
// Set process' stdout to our pipe
aStartupInfo.hStdOutput = hWriteHandle;
// We are going to duplicate our pipe's write handle
// and pass it as stderr to create process. The idea
// is that some processes have been known to close
// stderr which would also close stdout if we passed
// the same handle. Therefore we make a copy of stdout's
// pipe handle.
if (!DuplicateHandle( GetCurrentProcess(), hWriteHandle, GetCurrentProcess(), &hErrorHandle, 0, TRUE, DUPLICATE_SAME_ACCESS ))
{
CloseHandle(hReadHandle);
CloseHandle(hWriteHandle);
DEBUG_TRACE(_T("OSCall: Error: duplicate handle\n"));
return false;
}
aStartupInfo.hStdError = hErrorHandle;
// Check input parameter
TCHAR l_inputCommand[2048];
_tcscpy(l_inputCommand, i_cmd);
// Create process of service program
if(!CreateProcess( NULL, l_inputCommand, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &aStartupInfo, &aProcessInfo ))
{
CloseHandle(hReadHandle);
CloseHandle(hWriteHandle);
CloseHandle(hErrorHandle);
DEBUG_TRACE(_T("OSCall: Error: could not create process\n"));
return false;
}
// The process is alive now and has inherited the environment, now
// we can release the critical section
// Close the write end of our pipe (both copies)
// so it will die when the child process terminates
CloseHandle(hWriteHandle);
CloseHandle(hErrorHandle);
// We close the handle of the process in order to prevent memory leaks when
// the process terminates.
//CloseHandle(aProcessInfo.hThread);
// Allocate memory for output buffer
DWORD dwAvailableOutput = 16;
CHAR outputbuffer[18];
//CString strPipeName;
//DWORD dwSize = 0;
//GetNamedPipeHandleState( hReadHandle, NULL, NULL, NULL, NULL, strPipeName.GetBuffer(1), dwSize );
//WaitNamedPipe( strPipeName, 100 );
// -> Read output from CGI program
time_t l_time;
time_t l_startTime;
time(&l_startTime);
do
{
time(&l_time);
if( (l_time - l_startTime) > i_timeOut)
{
SetLastError(WAIT_TIMEOUT);
break;
}
if( ReadFile( hReadHandle, outputbuffer, dwAvailableOutput, &dwBytesRead, NULL ) )
{
outputbuffer[dwBytesRead] = 0; // null terminate
a_output += outputbuffer;
}
}
//We are done
while ( GetLastError() != ERROR_BROKEN_PIPE );
//reset ERROR_BROKEN_PIPE error
if(GetLastError() == ERROR_BROKEN_PIPE)
SetLastError(0);
//DEBUG_TRACE(_T("OSCall: command output: ") + a_output);
//CloseHandle(hErrorHandle);
CloseHandle(hReadHandle);
if( !GetLastError() )
{
return true;
}
else
{
DEBUG_TRACE(_T("OSCall: Error: cmd command failed. Error code: ")+ i2cs(GetLastError()) +_T("; ExitCode: ")+ i2cs(a_exitCode) +_T("."));
return false;
}
}
int main()
{
DWORD dwExitCode = 0;
long l_timeOut = 60000; //ms = 10 min
BOOL bRet = FALSE;
CString strInstallLmutil(_T("cmd.exe /C "));
CString strLmutilInstallFile(_T("remdicomnodes.exe"));
CString strPathLmutilInstall;
strPathLmutilInstall.Format(_T("%s\\bin\\%s"),strtemp,strLmutilInstallFile);
strInstallOption = _T("");
strInstallOption = _T(" 2 B B 0 localhost 1 \"""BE""\"" " 104 3 1 7 7 60 0 " "\"""\"" " 2 0 0 0 0 " "\"""\"" " 3 0 0 0 0 " "\"""\""" 0 6 1 2 3 10 8 9 0 0 0 0 NoConversion 0 0 0 0 1 0 0 0 AE 0 0 0 IPv4 0 0 10 0 1 0");
bRet = OSCall ( cmd, l_commandOutput, dwExitCode, l_timeOut);
SAM_TRACE1("OSCall: bRet value: :%d ",bRet);
if( bRet == FALSE )
{
SAM_TRACE0("remdicomnodes.exe execution failed \n");
}
return 0;
}

"setrlimit()" is not affecting the running process

I am trying the simulate the Error Scenario of a Process in Linux that Heap is not enough to allocate the memory in a C++ Linux Application.
But Eventhough I use the "setrlimit" to reduce the Heap Memory available to the Process, still the heap memory is getting allocated successfully.
struct rlimit the_limit = { 1, 1 };
if (-1 == setrlimit(RLIMIT_DATA, &the_limit)) {
perror("setrlimit failed");
}
try
{
char *n = new char[5600];
if (n==NULL)
{
cout <<"\nAllocation Failure\n";
}
}
catch (std::bad_alloc& ba)
{
std::cerr << "bad_alloc caught: " << ba.what() << '\n';
}
Most C++ standard libs including the one supplied with g++ start off with some heap memory preallocated.
5600 is a small request and as such, on my Linux system it gets satisfied from the preallocated memory as evidenced
from an strace:
Modified example:
#include <stdio.h>
#include <sys/resource.h>
int main()
{
struct rlimit the_limit = { 1, 1 };
if (-1 == setrlimit(RLIMIT_DATA, &the_limit)) { perror("setrlimit failed"); }
puts("ALLOC");
#if __cplusplus
try { char *n = new char[5600]; } catch (...) { perror("alloc failure"); }
#else
{ char *n = malloc(1); if(!n) perror("alloc failure"); }
#endif
}
End of example's strace:
...
write(1, "ALLOC\n", 6ALLOC
) = 6
exit_group(0) = ?
Either increasing the request size, e.g. in my case to at least 1<<16, or switching to plain C, causes the allocation request to be served from the OS, and then the limit does apply:
End of strace with an 1<<16 allocation request:
write(1, "ALLOC\n", 6ALLOC
) = 6
brk(0x561bcc5d4000) = 0x561bcc5b2000
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
dup(2) = 3
fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 14), ...}) = 0
write(3, "alloc failure: Cannot allocate m"..., 38alloc failure: Cannot allocate memory
) = 38
close(3) = 0
exit_group(0) = ?
Note that generic allocator implementations generally use sbrk and/or
mmap to get memory directly from the OS, and as you can glean from the setrlimit manpage, RLIMIT_DATA will only apply to a mmap-backed allocation iff you're on a Linux >= 4.7.

segmentation fault of massive sockets operation

This issue have bothered me for weeks and I could not find any solution on the web. So I have to create a new question to you gurus.
I was trying to read/write on massive number of sockets, please see test code below. It behave normally when the sockets number is below 1500. When the number of sockets is beyond 1500, the program will crash unexpectedly. I know that I should use command ulimit -n 32768 to increase the open files number limit. But the program still can not behave correctly.
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdint.h>
#include <netdb.h>
#include <errno.h>
#include <malloc.h>
#include <string.h>
int main(int argc, char* argv[])
{
if (argc!=2)
{
printf("usage: test <number of sockets>\n");
return -1;
}
int socketsNum=atoi(argv[1]);
if (socketsNum<=0)
{
printf("error: invalid sockets number\n");
return -1;
}
int *socketHandles=(int*)malloc(sizeof(int)*socketsNum);
if (socketHandles==NULL)
{
printf("error: failed to alloc socket handle memory\n");
return -1;
}
for (int i=0;i<socketsNum;i++)
{
socketHandles[i]=-1;
}
printf("creating %d sockets ...\n",socketsNum);
int createdSocketsNum=0;
for (int i=0;i<socketsNum;i++)
{
int socketHandle=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if (socketHandle==-1)
{
int lastError=errno;
printf("warning: socket() failed: index: %d, error: %d\n",i+1,lastError);
continue;
}
sockaddr_in sockAddr; // 0.0.0.0:0
memset(&sockAddr,0,sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
sockAddr.sin_port = htons(0);
if (bind( socketHandle, (sockaddr*) &sockAddr, sizeof(sockAddr)) == -1)
{
int lastError=errno;
printf("warning: bind() failed: index: %d, error: %d\n",i+1,lastError);
close(socketHandle);
continue;
}
socketHandles[i]=socketHandle;
createdSocketsNum++;
}
printf("created %d sockets.\n",createdSocketsNum);
//test reading;
printf("testing reading ...\n");
int readableNumber=0;
int unreadableNumber=0;
int readingSkippedNumber=0;
for (int i=0;i<socketsNum;i++)
{
int socketHandle=socketHandles[i];
if (socketHandle==-1)
{
readingSkippedNumber++;
continue;
}
fd_set rset;
FD_ZERO(&rset);
FD_SET(socketHandle, &rset);
struct timeval timeout = {0, 0};
int retCode=select(socketHandle + 1, &rset, NULL, NULL, &timeout);
if (retCode==-1)
{
int lastError=errno;
printf("warning: select() failed: index: %d, error: %d\n",i+1,lastError);
}
else if (retCode==0)
{
unreadableNumber++;
}
else
{
readableNumber++;
}
}
printf("readable: %d, unreadable: %d, skipped: %d, total: %d\n",readableNumber,unreadableNumber,readingSkippedNumber,socketsNum);
//test writing
printf("testing writing ...\n");
int writableNumber=0;
int unwritableNumber=0;
int writingSkippedNumber=0;
for (int i=0;i<socketsNum;i++)
{
int socketHandle=socketHandles[i];
if (socketHandle==-1)
{
writingSkippedNumber++;
continue;
}
fd_set wset;
FD_ZERO(&wset);
FD_SET(socketHandle, &wset);
struct timeval timeout = {0, 0};
int retCode=select(socketHandle + 1, NULL, &wset, NULL, &timeout);
if (retCode==-1)
{
int lastError=errno;
printf("warning: select() failed: index: %d, error: %d\n",i+1,lastError);
}
else if (retCode==0)
{
unwritableNumber++;
}
else
{
writableNumber++;
}
}
printf("writable: %d, unwritable: %d, skipped: %d, total: %d\n",writableNumber,unwritableNumber,writingSkippedNumber,socketsNum);
printf("closing ...\n");
for (int i=0;i<socketsNum;i++)
{
int socketHandle=socketHandles[i];
if (socketHandle==-1)
{
continue;
}
close(socketHandle);
}
free(socketHandles);
printf("completed!\n");
return 0;
}
Compile:
g++ TestSockets.cpp -ldl -g -ggdb -o TestSockets
Config:
ulimit -n 32768
Some typical results:
Good result of ./TestSockets 1500:
creating 1500 sockets ...
created 1500 sockets.
testing reading ...
readable: 0, unreadable: 1500, skipped: 0, total: 1500
testing writing ...
writable: 1372, unwritable: 128, skipped: 0, total: 1500
closing ...
completed!
Bad result of ./TestSockets 1900:
creating 1900 sockets ...
created 1900 sockets.
testing reading ...
warning: select() failed: index: 1797, error: 9
...(more lines trimmed)
warning: select() failed: index: 1820, error: 9
warning: select() failed: index: 1821, error: 22
readable: 0, unreadable: 1878, skipped: 0, total: 1900
testing writing ...
warning: select() failed: index: 1641, error: 9
...(more lines trimmed)
warning: select() failed: index: 1660, error: 9
warning: select() failed: index: 1661, error: 22
writable: 1751, unwritable: 128, skipped: 0, total: 1900
closing ...
completed!
Comment: because 1900>1751+128, it seems that the stack was damaged.
Bad result of ./TestSockets 2000:
creating 2000 sockets ...
created 2000 sockets.
testing reading ...
Segmentation fault
More Investigation:
According to gdb information. It seems that the stack memory was damaged during running:
creating 2000 sockets ...
created 2000 sockets.
testing reading ...
Program received signal SIGSEGV, Segmentation fault.
0x08048b79 in main (argc=2, argv=0xffffd3b4) at TestSockets.cpp:78
78 int socketHandle=socketHandles[i];
(gdb) print socketHandles
$1 = (int *) 0x0
(gdb) info local
socketHandle = 0
rset = {fds_bits = {0 <repeats 32 times>}}
timeout = {tv_sec = 0, tv_usec = 0}
retCode = 0
i = 1601
socketsNum = 2000
unreadableNumber = 1601
unwritableNumber = 134514249
socketHandles = 0x0
createdSocketsNum = 2000
readableNumber = 0
readingSkippedNumber = 0
writableNumber = -136436764
writingSkippedNumber = 0
(gdb) info stack
#0 0x08048b79 in main (argc=2, argv=0xffffd3b4) at TestSockets.cpp:78
An fd_set is limited by the maximum value of the file descriptor (not the number of file descriptors set at the same time). Usually it's 1024.
Thus, if your socket value is greater than 1023, you cannot use select on it at all.
Redefining FD_SETSIZE is not supported on operating systems I know. You might be able to successfully redefine fd_set in your program, but select will only work up to FD_SETSIZE.
I have solved this headache problem. The fd_set on windows and Linux are totally different. On Linux if socket handle VALUE is bigger than FD_SETSIZE, there will be overrun issue on Linux version FD_SET macro. I make a workaround to alloc enough buffer for fd_set on Linux. such as,
char rsetBuffer[10240];
memset(rsetBuffer,0,10240);
fd_set& rset=(fd_set&)rsetBuffer;
FD_ZERO(&rset);
FD_SET(socketHandle, &rset);
p.s. Definition of fd_set struct and FD_SET macro on windows and Linux:
on windows:
typedef struct fd_set {
u_int fd_count; /* how many are SET? */
SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
} fd_set;
#define FD_SET(fd, set) do { \
u_int __i; \
for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
if (((fd_set FAR *)(set))->fd_array[__i] == (fd)) { \
break; \
} \
} \
if (__i == ((fd_set FAR *)(set))->fd_count) { \
if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
((fd_set FAR *)(set))->fd_array[__i] = (fd); \
((fd_set FAR *)(set))->fd_count++; \
} \
} \
} while(0)
on Linux:
/* fd_set for select and pselect. */
typedef struct
{
/* XPG4.2 requires this member name. Otherwise avoid the name
from the global namespace. */
#ifdef __USE_XOPEN
__fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
# define __FDS_BITS(set) ((set)->fds_bits)
#else
__fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
# define __FDS_BITS(set) ((set)->__fds_bits)
#endif
} fd_set;
#define __FD_SET(d, set) \
((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))
#define __FD_CLR(d, set) \
((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))
#define __FD_ISSET(d, set) \
((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)

Why does TTYUSB0 port settings change my stdout settings as well

I have an embedded Atmel ARM926 board that I created a usb serial ko to get data from an FTDI as USBtty0. This board also has a serial port DBGU which is used as the console terminal that normally runs at 230kb. When I config the USBtty0 port to the required 115kb, DBGU apparently changes to 115kb as well.
if( m_fdELMdev = open(m_ELMdevice, O_RDWR | O_NOCTTY )< 0)
{//error
}
else
{
// Configure the port
tcgetattr(m_fdELMdev, &dev_settings);
dev_settings.c_cflag |= B115200;
cfmakeraw(&dev_settings);
}
Can someone please tell me what I might be doing wrong?
This is snippet of my devices.tab
/dev/tty c 640 0 0 4 0 0 1 4
/dev/tty c 640 0 0 5 0 - - -
/dev/ttyGS c 640 0 0 252 0 - - -
/dev/ttyS c 640 0 0 4 64 0 1 3
/dev/watchdog c 640 0 0 10 130 - - -
/dev/zero c 640 0 0 1 5 - - -
/dev/ttyACM0 c 640 0 0 166 0 - - -
/dev/ttyUSB0 c 640 0 0 188 0 - - -
Also, I occasionally see some 'Interrupted System Calls' from select. How do I need to handle these? Do I retry the select until I get some data? Then what if I never get any data?
enter code here
do
{
iret = select(m_fdELMdev + 1, &fdrefid, NULL, NULL, &porttime);
switch(iret)
{
case READ_TIMEOUT:
ierr = -1;
break;
case READ_ERROR:
g_dbg->debug("CACS_Elm327::Select error:%s (%d)\n",strerror(errno), errno);
ierr = -1;
break;
default:
iret = read(m_fdELMdev, data, ilen);
g_dbg->debug("CACS_Elm327::Readport_ELM:read %s %d\n", data, iret );
break;
}
}while((ierr == 0) && (iret<ilen) );

Retrieving system calls with Ptrace, stopping after first one

I am trying to retrieve all of the numbers of system calls and eventually the names of the system calls called by a give program using ptrace. I am on a 64 bit system so I am using the ORIG_RAX * 8 to find system calls using ptrace. I currently can only retrieve the first system call, output of a sample run is below. Any ideas?
Thanks!
Output:
griffinm#well $ g++ mystrace.cc
~/cs153/assn2
griffinm#well $ a.out ls
Please wait
The child made a system call 59
a.out mystrace.cc mystrace.cc~
Number of machine instructions : 252376
~/cs153/assn2
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#define ORIG_RAX 120
int main( int argc, char* argv[])
{
long long counter = 0; /* machine instruction counter */
int wait_val; /* child's return value */
int pid;
long orig_eax; /* child's process id */
puts("Please wait");
switch (pid = fork()) {
case -1:
perror("fork");
break;
case 0:
ptrace(PTRACE_TRACEME, 0, 0, 0);
execvp(argv[1], NULL);
break;
default:
wait(&wait_val);
orig_eax = ptrace(PTRACE_PEEKUSER,
pid, ORIG_RAX,
NULL);
printf("The child made a "
"system call %ld\n", orig_eax);
while (wait_val == 1407 ) {
counter++;
if (ptrace(PTRACE_SINGLESTEP, pid, 0, 0) != 0)
perror("ptrace");
wait(&wait_val);
}
}
printf("Number of machine instructions : %lld\n", counter);
return 0;
}
Update Default Case:
Default:
wait(&wait_val);
while (wait_val == 1407 ) {
counter++;
if (ptrace(PTRACE_SYSCALL, pid, 0, 0) != 0)
perror("ptrace");
orig_eax = ptrace(PTRACE_PEEKUSER,
pid, 8*ORIG_RAX,
NULL);
cout<<orig_eax<<endl;
wait(&wait_val);
}
}
Edit:
Output:
griffinm#well $ a.out pwd
Please wait
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
/home/csmajs/griffinm/cs153/assn2
-1
-1
-1
-1
-1
-1
I think the 8*Orig_RAX is the problem, the machine is 64 bit like I said. Any ideas?
You probably want to use PTRACE_SYSCALL instead of PTRACE_SINGLESTEP to run the child up to the next system call rather than just a single instruction. Then you can use the PTRACE_PEEKUSER again to see what syscall it is.