mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 00:27:08 +02:00
MINOR: htx: Adapt htx_dump() to be used from traces
This function now dumps info about the HTX message into a buffer, passed as argument. In addition, it is possible to only dump meta information, without the message content.
This commit is contained in:
parent
af542635f7
commit
27aa65ecfb
@ -805,16 +805,19 @@ static inline const char *htx_blk_type_str(enum htx_blk_type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* For debugging purpose */
|
/* For debugging purpose */
|
||||||
static inline void htx_dump(struct htx *htx)
|
static inline void htx_dump(struct buffer *chunk, const struct htx *htx, int full)
|
||||||
{
|
{
|
||||||
int32_t pos;
|
int32_t pos;
|
||||||
|
|
||||||
fprintf(stderr, "htx:%p [ size=%u - data=%u - used=%u - wrap=%s - extra=%llu]\n",
|
chunk_appendf(chunk, " htx=%p(size=%u,data=%u,used=%u,wrap=%s,flags=0x%08x,extra=%llu,"
|
||||||
htx, htx->size, htx->data, htx_nbblks(htx),
|
"first=%d,head=%d,tail=%d,tail_addr=%d,head_addr=%d,end_addr=%d)",
|
||||||
(!htx->head_addr) ? "NO" : "YES",
|
htx, htx->size, htx->data, htx_nbblks(htx), (!htx->head_addr) ? "NO" : "YES",
|
||||||
(unsigned long long)htx->extra);
|
htx->flags, (unsigned long long)htx->extra, htx->first, htx->head, htx->tail,
|
||||||
fprintf(stderr, "\tfirst=%d - head=%d - tail=%d - tail_addr=%d - head_addr=%d, end_addr=%d\n",
|
htx->tail_addr, htx->head_addr, htx->end_addr);
|
||||||
htx->first, htx->head, htx->tail, htx->tail_addr, htx->head_addr, htx->end_addr);
|
|
||||||
|
if (!full || !htx_nbblks(htx))
|
||||||
|
return;
|
||||||
|
chunk_memcat(chunk, "\n", 1);
|
||||||
|
|
||||||
for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) {
|
for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) {
|
||||||
struct htx_sl *sl;
|
struct htx_sl *sl;
|
||||||
@ -828,23 +831,22 @@ static inline void htx_dump(struct htx *htx)
|
|||||||
|
|
||||||
if (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL) {
|
if (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL) {
|
||||||
sl = htx_get_blk_ptr(htx, blk);
|
sl = htx_get_blk_ptr(htx, blk);
|
||||||
fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s %.*s %.*s\n",
|
chunk_appendf(chunk, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s %.*s %.*s\n",
|
||||||
pos, htx_blk_type_str(type), sz, blk->addr,
|
pos, htx_blk_type_str(type), sz, blk->addr,
|
||||||
HTX_SL_P1_LEN(sl), HTX_SL_P1_PTR(sl),
|
HTX_SL_P1_LEN(sl), HTX_SL_P1_PTR(sl),
|
||||||
HTX_SL_P2_LEN(sl), HTX_SL_P2_PTR(sl),
|
HTX_SL_P2_LEN(sl), HTX_SL_P2_PTR(sl),
|
||||||
HTX_SL_P3_LEN(sl), HTX_SL_P3_PTR(sl));
|
HTX_SL_P3_LEN(sl), HTX_SL_P3_PTR(sl));
|
||||||
}
|
}
|
||||||
else if (type == HTX_BLK_HDR || type == HTX_BLK_TLR)
|
else if (type == HTX_BLK_HDR || type == HTX_BLK_TLR)
|
||||||
fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s: %.*s\n",
|
chunk_appendf(chunk, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s: %.*s\n",
|
||||||
pos, htx_blk_type_str(type), sz, blk->addr,
|
pos, htx_blk_type_str(type), sz, blk->addr,
|
||||||
(int)n.len, n.ptr,
|
(int)n.len, n.ptr,
|
||||||
(int)v.len, v.ptr);
|
(int)v.len, v.ptr);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u%s\n",
|
chunk_appendf(chunk, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u%s\n",
|
||||||
pos, htx_blk_type_str(type), sz, blk->addr,
|
pos, htx_blk_type_str(type), sz, blk->addr,
|
||||||
(!v.len ? "\t<empty>" : ""));
|
(!v.len ? "\t<empty>" : ""));
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _COMMON_HTX_H */
|
#endif /* _COMMON_HTX_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user