]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: applet: instrument appctx_wakeup() to log the caller's location
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Sep 2022 12:45:55 +0000 (14:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Sep 2022 12:30:38 +0000 (14:30 +0200)
appctx_wakeup() relies on task_wakeup(), but since it calls it from a
function, the calling place is always appctx_wakeup() itself, which is
not very useful.

Let's turn it to a macro so that we can log the location of the caller
instead. As an example, the cli_io_handler() which used to be seen as
this:

  (gdb) p *appctx->t.debug.caller[0]
  $10 = {
    func = 0x9ffb78 <__func__.37996> "appctx_wakeup",
    file = 0x9b336a "include/haproxy/applet.h",
    line = 110,
    what = 1 '\001',
    arg8 = 0 '\000',
    arg32 = 0
  }

Now shows the more useful:

  (gdb) p *appctx->t.debug.caller[0]
  $6 = {
    func = 0x9ffe80 <__func__.38641> "sc_app_chk_snd_applet",
    file = 0xa00320 "src/stconn.c",
    line = 996,
    what = 6 '\006',
    arg8 = 0 '\000',
    arg32 = 0
  }

include/haproxy/applet.h

index 6eb79267034e1b28abe544429005537ea7473b4d..4d32165d62392a85333d56b756f45fe6475437cc 100644 (file)
@@ -104,11 +104,11 @@ static inline void appctx_free(struct appctx *appctx)
        }
 }
 
-/* wakes up an applet when conditions have changed */
-static inline void appctx_wakeup(struct appctx *appctx)
-{
-       task_wakeup(appctx->t, TASK_WOKEN_OTHER);
-}
+/* wakes up an applet when conditions have changed. We're using a macro here in
+ * order to retrieve the caller's place.
+ */
+#define appctx_wakeup(ctx) \
+       _task_wakeup((ctx)->t, TASK_WOKEN_OTHER, MK_CALLER(WAKEUP_TYPE_APPCTX_WAKEUP, 0, 0))
 
 /* returns the stream connector the appctx is attached to, via the sedesc */
 static inline struct stconn *appctx_sc(const struct appctx *appctx)