syscall_emul.cc (5543:3af77710f397) syscall_emul.cc (5748:f28f020f3006)
1/*
2 * Copyright (c) 2003-2005 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;

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

102SyscallReturn
103getpagesizeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
104{
105 return (int)VMPageSize;
106}
107
108
109SyscallReturn
1/*
2 * Copyright (c) 2003-2005 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;

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

102SyscallReturn
103getpagesizeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
104{
105 return (int)VMPageSize;
106}
107
108
109SyscallReturn
110obreakFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
110brkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
111{
111{
112 Addr junk;
113
114 // change brk addr to first arg
115 Addr new_brk = tc->getSyscallArg(0);
112 // change brk addr to first arg
113 Addr new_brk = tc->getSyscallArg(0);
116 if (new_brk != 0) {
114
115 // in Linux at least, brk(0) returns the current break value
116 // (note that the syscall and the glibc function have different behavior)
117 if (new_brk == 0)
118 return p->brk_point;
119
120 if (new_brk > p->brk_point) {
121 // might need to allocate some new pages
117 for (ChunkGenerator gen(p->brk_point, new_brk - p->brk_point,
118 VMPageSize); !gen.done(); gen.next()) {
122 for (ChunkGenerator gen(p->brk_point, new_brk - p->brk_point,
123 VMPageSize); !gen.done(); gen.next()) {
119 if (!p->pTable->translate(gen.addr(), junk))
124 if (!p->pTable->translate(gen.addr()))
120 p->pTable->allocate(roundDown(gen.addr(), VMPageSize),
121 VMPageSize);
122 }
125 p->pTable->allocate(roundDown(gen.addr(), VMPageSize),
126 VMPageSize);
127 }
123 p->brk_point = new_brk;
124 }
128 }
129
130 p->brk_point = new_brk;
125 DPRINTF(SyscallVerbose, "Break Point changed to: %#X\n", p->brk_point);
126 return p->brk_point;
127}
128
129
130SyscallReturn
131closeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
132{

--- 499 unchanged lines hidden ---
131 DPRINTF(SyscallVerbose, "Break Point changed to: %#X\n", p->brk_point);
132 return p->brk_point;
133}
134
135
136SyscallReturn
137closeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
138{

--- 499 unchanged lines hidden ---