From patchwork Thu Mar 25 13:42:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11714 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0856AC32E9 for ; Thu, 25 Mar 2021 13:42:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 82D1668D80; Thu, 25 Mar 2021 14:42:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pjze5PUN"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E03A602D5 for ; Thu, 25 Mar 2021 14:42:37 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 362268C9; Thu, 25 Mar 2021 14:42:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616679757; bh=U/GFlKH0quUlUYD8QEmuZuLLxlaij3Pq//oVy3qUhFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjze5PUNUJkttqIjQnorxSvnPntRbslCRCNP28JyrmDZagt7ULxPBL1oXU3zUdOr3 Ui71Xbz828eCVAmMqauBI3Ib8+IAeBUwTs8TnFjNnvY3Mj6tTX+6uE1dN0xbKpKVpy mrmF8yUFpqiysUtWvWj9KTnLffcuIFzOtZqQqk8A= From: Kieran Bingham To: libcamera devel Date: Thu, 25 Mar 2021 13:42:24 +0000 Message-Id: <20210325134231.1400051-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325134231.1400051-1-kieran.bingham@ideasonboard.com> References: <20210325134231.1400051-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 04/11] libcamera: request: Add a toString() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Provide a toString helper to assist in printing Request state for debug and logging contexts. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/request.h | 3 +++ src/libcamera/request.cpp | 30 +++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/include/libcamera/request.h b/include/libcamera/request.h index cd5a24741f8a..4cf5ff3f7d3b 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,8 @@ public: bool hasPendingBuffers() const { return !pending_.empty(); } + std::string toString() const; + private: LIBCAMERA_DISABLE_COPY(Request) diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index fc16b148a599..7b7ef6814686 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -261,6 +262,16 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const * otherwise */ +/** + * \fn Request::toString() + * \brief Generate a string representation of the Request internals + * + * This function facilitates debugging of Request state while it is used + * internally within libcamera. + * + * \return A string representing the current state of the request + */ + /** * \brief Complete a queued request * @@ -275,9 +286,7 @@ void Request::complete() status_ = cancelled_ ? RequestCancelled : RequestComplete; - LOG(Request, Debug) - << "Request has completed - cookie: " << cookie_ - << (cancelled_ ? " [Cancelled]" : ""); + LOG(Request, Debug) << toString(); LIBCAMERA_TRACEPOINT(request_complete, this); } @@ -310,4 +319,19 @@ bool Request::completeBuffer(FrameBuffer *buffer) return !hasPendingBuffers(); } +std::string Request::toString() const +{ + std::stringstream ss; + + /* Pending, Completed, Cancelled(X). */ + static const char *statuses = "PCX"; + + /* Example Output: Request(55:P:1/2:6523524) */ + ss << "Request (" << sequence_ << ":" << statuses[status_] << ":" + << pending_.size() << "/" << bufferMap_.size() << ":" + << cookie_ << ")"; + + return ss.str(); +} + } /* namespace libcamera */