mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 08:35:26 +00:00
Bug 424405 - "XDR should compensate for traps set in the script it is serializing" [p=crowder@fiverocks.com (Brian Crowder) r+a1.9b5=shaver]
This commit is contained in:
parent
9afac161f1
commit
034616f462
@ -45,7 +45,6 @@
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsclist.h"
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsconfig.h"
|
||||
@ -66,19 +65,6 @@
|
||||
#include <CHUD/CHUD.h>
|
||||
#endif
|
||||
|
||||
typedef struct JSTrap {
|
||||
JSCList links;
|
||||
JSScript *script;
|
||||
jsbytecode *pc;
|
||||
JSOp op;
|
||||
JSTrapHandler handler;
|
||||
void *closure;
|
||||
} JSTrap;
|
||||
|
||||
#define DBG_LOCK(rt) JS_ACQUIRE_LOCK((rt)->debuggerLock)
|
||||
#define DBG_UNLOCK(rt) JS_RELEASE_LOCK((rt)->debuggerLock)
|
||||
#define DBG_LOCK_EVAL(rt,expr) (DBG_LOCK(rt), (expr), DBG_UNLOCK(rt))
|
||||
|
||||
/*
|
||||
* NB: FindTrap must be called with rt->debuggerLock acquired.
|
||||
*/
|
||||
@ -118,6 +104,7 @@ JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
JSRuntime *rt;
|
||||
uint32 sample;
|
||||
|
||||
JS_ASSERT((JSOp) *pc != JSOP_TRAP);
|
||||
junk = NULL;
|
||||
rt = cx->runtime;
|
||||
DBG_LOCK(rt);
|
||||
|
@ -43,11 +43,25 @@
|
||||
* JS debugger API.
|
||||
*/
|
||||
#include "jsapi.h"
|
||||
#include "jsclist.h"
|
||||
#include "jsopcode.h"
|
||||
#include "jsprvtd.h"
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct JSTrap {
|
||||
JSCList links;
|
||||
JSScript *script;
|
||||
jsbytecode *pc;
|
||||
JSOp op;
|
||||
JSTrapHandler handler;
|
||||
void *closure;
|
||||
} JSTrap;
|
||||
|
||||
#define DBG_LOCK(rt) JS_ACQUIRE_LOCK((rt)->debuggerLock)
|
||||
#define DBG_UNLOCK(rt) JS_RELEASE_LOCK((rt)->debuggerLock)
|
||||
#define DBG_LOCK_EVAL(rt,expr) (DBG_LOCK(rt), (expr), DBG_UNLOCK(rt))
|
||||
|
||||
extern void
|
||||
js_PatchOpcode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op);
|
||||
|
||||
|
@ -418,6 +418,8 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
|
||||
{
|
||||
JSContext *cx;
|
||||
JSScript *script, *oldscript;
|
||||
JSBool ok;
|
||||
jsbytecode *code;
|
||||
uint32 length, lineno, depth, magic;
|
||||
uint32 natoms, nsrcnotes, ntrynotes, nobjects, nregexps, i;
|
||||
uint32 prologLength, version;
|
||||
@ -516,9 +518,37 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
|
||||
* Control hereafter must goto error on failure, in order for the
|
||||
* DECODE case to destroy script.
|
||||
*/
|
||||
code = script->code;
|
||||
if (xdr->mode == JSXDR_ENCODE) {
|
||||
JSTrap *trap;
|
||||
JSRuntime *rt;
|
||||
|
||||
rt = cx->runtime;
|
||||
DBG_LOCK(rt);
|
||||
for (trap = (JSTrap *)rt->trapList.next;
|
||||
trap != (JSTrap *)&rt->trapList;
|
||||
trap = (JSTrap *)trap->links.next) {
|
||||
if (trap->script == script) {
|
||||
if (code == script->code) {
|
||||
code = JS_malloc(cx, length * sizeof(jsbytecode));
|
||||
if (!code)
|
||||
goto error;
|
||||
memcpy(code, script->code, length * sizeof(jsbytecode));
|
||||
}
|
||||
code[trap->pc - script->code] = trap->op;
|
||||
}
|
||||
}
|
||||
DBG_UNLOCK(rt);
|
||||
}
|
||||
|
||||
oldscript = xdr->script;
|
||||
xdr->script = script;
|
||||
if (!JS_XDRBytes(xdr, (char *)script->code, length * sizeof(jsbytecode)))
|
||||
ok = JS_XDRBytes(xdr, (char *) code, length * sizeof(jsbytecode));
|
||||
|
||||
if (code != script->code)
|
||||
JS_free(cx, code);
|
||||
|
||||
if (!ok)
|
||||
goto error;
|
||||
|
||||
if (!JS_XDRBytes(xdr, (char *)notes, nsrcnotes * sizeof(jssrcnote)) ||
|
||||
|
Loading…
Reference in New Issue
Block a user