Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150540683
D42411.1792581333.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D42411.1792581333.diff
View Options
diff --git a/sys/cam/cam_debug.h b/sys/cam/cam_debug.h
--- a/sys/cam/cam_debug.h
+++ b/sys/cam/cam_debug.h
@@ -81,49 +81,67 @@
/* Printf delay value (to prevent scrolling) */
extern uint32_t cam_debug_delay;
+/* Stupid macro to remove a layer of parens */
+#define _CAM_X(...) __VA_ARGS__
+/* No do {} while(0) around this to not nest scopes */
+#define _CAM_SB struct sbuf sbuf; \
+ char buf[100]; /* balance to not eat too much stack */ \
+ struct sbuf *sb = sbuf_new(&sbuf, buf, sizeof(buf), SBUF_FIXEDLEN); \
+ sbuf_set_drain(sb, sbuf_printf_drain, NULL);
+
/* Debugging macros. */
-#define CAM_DEBUGGED(path, flag) \
- (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
- && (cam_dpath != NULL) \
- && (xpt_path_comp(cam_dpath, path) >= 0) \
+#define CAM_DEBUGGED(path, flag) \
+ (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
+ && (cam_dpath != NULL) \
+ && (xpt_path_comp(cam_dpath, path) >= 0) \
&& (xpt_path_comp(cam_dpath, path) < 2))
-#define CAM_DEBUG(path, flag, printfargs) \
- if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
- && (cam_dpath != NULL) \
- && (xpt_path_comp(cam_dpath, path) >= 0) \
- && (xpt_path_comp(cam_dpath, path) < 2)) { \
- xpt_print_path(path); \
- printf printfargs; \
- if (cam_debug_delay != 0) \
- DELAY(cam_debug_delay); \
+#define CAM_DEBUG(path, flag, printfargs) \
+ if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
+ && (cam_dpath != NULL) \
+ && (xpt_path_comp(cam_dpath, path) >= 0) \
+ && (xpt_path_comp(cam_dpath, path) < 2)) { \
+ _CAM_SB; \
+ xpt_path_sbuf(path, sb); \
+ sbuf_printf(sb, _CAM_X printfargs); \
+ sbuf_finish(sb); \
+ sbuf_delete(sb); \
+ if (cam_debug_delay != 0) \
+ DELAY(cam_debug_delay); \
}
-#define CAM_DEBUG_DEV(dev, flag, printfargs) \
- if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
- && (cam_dpath != NULL) \
- && (xpt_path_comp_dev(cam_dpath, dev) >= 0) \
- && (xpt_path_comp_dev(cam_dpath, dev) < 2)) { \
- xpt_print_device(dev); \
- printf printfargs; \
- if (cam_debug_delay != 0) \
- DELAY(cam_debug_delay); \
+#define CAM_DEBUG_DEV(dev, flag, printfargs) \
+ if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
+ && (cam_dpath != NULL) \
+ && (xpt_path_comp_dev(cam_dpath, dev) >= 0) \
+ && (xpt_path_comp_dev(cam_dpath, dev) < 2)) { \
+ _CAM_SB; \
+ xpt_print_device(sb, dev); \
+ sbuf_printf(sb, _CAM_X printfargs); \
+ if (cam_debug_delay != 0) \
+ DELAY(cam_debug_delay); \
}
-#define CAM_DEBUG_PRINT(flag, printfargs) \
- if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
- printf("cam_debug: "); \
- printf printfargs; \
- if (cam_debug_delay != 0) \
- DELAY(cam_debug_delay); \
+#define CAM_DEBUG_PRINT(flag, printfargs) \
+ if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
+ _CAM_SB; \
+ sbuf_printf(sb, "cam_debug: "); \
+ sbuf_printf(sb, _CAM_X printfargs); \
+ sbuf_finish(sb); \
+ sbuf_delete(sb); \
+ if (cam_debug_delay != 0) \
+ DELAY(cam_debug_delay); \
}
-#define CAM_DEBUG_PATH_PRINT(flag, path, printfargs) \
- if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
- xpt_print(path, "cam_debug: "); \
- printf printfargs; \
- if (cam_debug_delay != 0) \
- DELAY(cam_debug_delay); \
+#define CAM_DEBUG_PATH_PRINT(flag, path, printfargs) \
+ if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \
+ _CAM_SB; \
+ xpt_path_sbuf(path, sb, "cam_debug: "); \
+ sbuf_printf(sb, _CAM_X printfargs); \
+ sbuf_finish(sb); \
+ sbuf_delete(sb); \
+ if (cam_debug_delay != 0) \
+ DELAY(cam_debug_delay); \
}
#else /* !_KERNEL */
diff --git a/sys/cam/cam_xpt.h b/sys/cam/cam_xpt.h
--- a/sys/cam/cam_xpt.h
+++ b/sys/cam/cam_xpt.h
@@ -33,16 +33,15 @@
#define _CAM_CAM_XPT_H 1
#ifdef _KERNEL
-#include <sys/cdefs.h>
#include <cam/cam_ccb.h>
#endif
+#include <sys/sbuf.h>
/* Forward Declarations */
union ccb;
struct cam_periph;
struct cam_ed;
struct cam_sim;
-struct sbuf;
/*
* Definition of a CAM path. Paths are created from bus, target, and lun ids
@@ -113,7 +112,7 @@
struct cam_periph *xpt_path_periph(struct cam_path *path);
device_t xpt_path_sim_device(const struct cam_path *path);
void xpt_print_path(struct cam_path *path);
-void xpt_print_device(struct cam_ed *device);
+void xpt_print_device(struct sbuf *sb, struct cam_ed *device);
void xpt_print(struct cam_path *path, const char *fmt, ...);
void xpt_async(uint32_t async_code, struct cam_path *path,
void *async_arg);
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -3713,17 +3713,18 @@
}
void
-xpt_print_device(struct cam_ed *device)
+xpt_print_device(struct sbuf *sb, struct cam_ed *device)
{
if (device == NULL)
- printf("(nopath): ");
+ sbuf_printf(sb, "(nopath): ");
else {
- printf("(noperiph:%s%d:%d:%d:%jx): ", device->sim->sim_name,
- device->sim->unit_number,
- device->sim->bus_id,
- device->target->target_id,
- (uintmax_t)device->lun_id);
+ sbuf_printf(sb, "(noperiph:%s%d:%d:%d:%jx): ",
+ device->sim->sim_name,
+ device->sim->unit_number,
+ device->sim->bus_id,
+ device->target->target_id,
+ (uintmax_t)device->lun_id);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 21, 11:15 AM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30587395
Default Alt Text
D42411.1792581333.diff (5 KB)
Attached To
Mode
D42411: cam: Make cam_debug macros atomic
Attached
Detach File
Event Timeline
Log In to Comment