Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
0da95926
Commit
0da95926
authored
Apr 24, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a workspace dump utility function
parent
ed418ea0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
vmod.vcc
lib/libvmod_vtc/vmod.vcc
+12
-0
vmod_vtc.c
lib/libvmod_vtc/vmod_vtc.c
+56
-0
No files found.
lib/libvmod_vtc/vmod.vcc
View file @
0da95926
...
...
@@ -119,6 +119,18 @@ $Function VOID workspace_overflow(ENUM { client, backend, session, thread })
Mark a workspace as overflowed.
$Function BLOB workspace_dump(
ENUM { client, backend, session, thread },
ENUM { s, f, r },
BYTES off=0,
BYTES len=64)
Return data from a workspace's ``s``, ``f``, or ``r`` pointer as a
blob. Data is copied onto the primary workspace to avoid it being
subsequently overwritten.
The maximum *len* is 1KB.
$Function INT typesize(STRING)
Returns the size in bytes of a collection of C-datatypes:
...
...
lib/libvmod_vtc/vmod_vtc.c
View file @
0da95926
...
...
@@ -209,6 +209,62 @@ VTC_WS_OP(VOID, , overflow, WS_MarkOverflow(ws))
VTC_WS_OP
(
BOOL
,
(
0
),
overflowed
,
return
(
WS_Overflowed
(
ws
)))
#undef VTC_WS_OP
VCL_BLOB
v_matchproto_
(
td_vtc_workspace_dump
)
vmod_workspace_dump
(
VRT_CTX
,
VCL_ENUM
which
,
VCL_ENUM
where
,
VCL_BYTES
off
,
VCL_BYTES
len
)
{
struct
ws
*
ws
;
const
size_t
maxlen
=
1024
;
unsigned
char
buf
[
maxlen
];
const
char
*
p
;
unsigned
l
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
ws
=
vtc_ws_find
(
ctx
,
which
);
if
(
ws
==
NULL
)
return
(
NULL
);
WS_Assert
(
ws
);
if
(
len
>
maxlen
)
{
VRT_fail
(
ctx
,
"workspace_dump: max length is %zd"
,
maxlen
);
return
(
NULL
);
}
if
(
where
==
VENUM
(
s
))
p
=
ws
->
s
;
else
if
(
where
==
VENUM
(
f
))
p
=
ws
->
f
;
else
if
(
where
==
VENUM
(
r
))
p
=
ws
->
r
;
else
INCOMPL
();
if
(
p
==
NULL
)
{
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"workspace_dump: NULL"
);
return
(
NULL
);
}
p
+=
off
;
if
(
p
>=
ws
->
e
)
{
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"workspace_dump: off limit"
);
return
(
NULL
);
}
l
=
pdiff
(
p
,
ws
->
e
);
if
(
len
<
l
)
l
=
len
;
assert
(
l
<
maxlen
);
memcpy
(
buf
,
p
,
l
);
p
=
WS_Copy
(
ctx
->
ws
,
buf
,
l
);
if
(
p
==
NULL
)
{
VRT_fail
(
ctx
,
"workspace_dump: copy failed"
);
return
(
NULL
);
}
return
(
VRT_blob
(
ctx
,
"workspace_dump"
,
p
,
l
,
0xd000d000
));
}
/*--------------------------------------------------------------------*/
VCL_INT
v_matchproto_
(
td_vtc_typesize
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment