mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-02 18:22:04 +00: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 */
|
||||
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;
|
||||
|
||||
fprintf(stderr, "htx:%p [ size=%u - data=%u - used=%u - wrap=%s - extra=%llu]\n",
|
||||
htx, htx->size, htx->data, htx_nbblks(htx),
|
||||
(!htx->head_addr) ? "NO" : "YES",
|
||||
(unsigned long long)htx->extra);
|
||||
fprintf(stderr, "\tfirst=%d - head=%d - tail=%d - tail_addr=%d - head_addr=%d, end_addr=%d\n",
|
||||
htx->first, htx->head, htx->tail, htx->tail_addr, htx->head_addr, htx->end_addr);
|
||||
chunk_appendf(chunk, " htx=%p(size=%u,data=%u,used=%u,wrap=%s,flags=0x%08x,extra=%llu,"
|
||||
"first=%d,head=%d,tail=%d,tail_addr=%d,head_addr=%d,end_addr=%d)",
|
||||
htx, htx->size, htx->data, htx_nbblks(htx), (!htx->head_addr) ? "NO" : "YES",
|
||||
htx->flags, (unsigned long long)htx->extra, 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)) {
|
||||
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) {
|
||||
sl = htx_get_blk_ptr(htx, blk);
|
||||
fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s %.*s %.*s\n",
|
||||
pos, htx_blk_type_str(type), sz, blk->addr,
|
||||
HTX_SL_P1_LEN(sl), HTX_SL_P1_PTR(sl),
|
||||
HTX_SL_P2_LEN(sl), HTX_SL_P2_PTR(sl),
|
||||
HTX_SL_P3_LEN(sl), HTX_SL_P3_PTR(sl));
|
||||
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,
|
||||
HTX_SL_P1_LEN(sl), HTX_SL_P1_PTR(sl),
|
||||
HTX_SL_P2_LEN(sl), HTX_SL_P2_PTR(sl),
|
||||
HTX_SL_P3_LEN(sl), HTX_SL_P3_PTR(sl));
|
||||
}
|
||||
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",
|
||||
pos, htx_blk_type_str(type), sz, blk->addr,
|
||||
(int)n.len, n.ptr,
|
||||
(int)v.len, v.ptr);
|
||||
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,
|
||||
(int)n.len, n.ptr,
|
||||
(int)v.len, v.ptr);
|
||||
else
|
||||
fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u%s\n",
|
||||
pos, htx_blk_type_str(type), sz, blk->addr,
|
||||
(!v.len ? "\t<empty>" : ""));
|
||||
chunk_appendf(chunk, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u%s\n",
|
||||
pos, htx_blk_type_str(type), sz, blk->addr,
|
||||
(!v.len ? "\t<empty>" : ""));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#endif /* _COMMON_HTX_H */
|
||||
|
Loading…
Reference in New Issue
Block a user