Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Software debugging: using assertion ASSERT macro positioning software bug

Shulou Source: shulou.com Published: 2022-06-03 05:39:31 11月24日 Update

/ * * Author: DavidLin * Date: 2014-12-26pm * Email: linpeng1577@163.com or linpeng1577@gmail.com * world: the city of SZ In China * Ver: 000.000.001 * For: threads for rxtx! * history: editor time do * 1) LinPeng 2014-12-26 created this file! * 2) * / * assert_self.h * / # ifndef _ _ ASSERT _ SELF_H__#define _ _ ASSERT_SELF_H__#include#define ASSERT_ENABLE (1) # define xprintf printf / * xprintf can be tty print or uart print Etc * / # if ASSERT_ENABLE#define assert_error ()\ do\ {\ xprintf ("[ERROR] Assert FILE:% s: LINE% d\ n", _ _ FILE__, _ _ LINE__) \} while (0) # define ASSERT1 (para)\ do\ {\ if (! para)\ {\ assert_error ();\} while (0)\ # else / * if! ASSERT_ENABLE * / # define ASSERT1 (para)\ do\ {\ if (para)\ {\} while (0) # endif / * end of ASSERT_ENABLE * / # endif / * end of _ _ ASSERT_SELF_H__*/

Test case

/ * test case: test.c * / # include#include "assert_self.h" int main (int argc, char* argv []) {switch (argc) {case 2: ASSERT1 (atoi (argv [1])); break; default: printf ("ARG ACCEPT 1\ n"); break;} exit (0);}

Software Bug positioning, in many cases, such as the use of Assert macros, you can compress the 48-hour debugging meal into a dessert that can be eaten, each software team is re-evolving, the past experience is not always a good inheritance, this is us!

Tags: Software positioning dinner hours groups that is time dessert experience testing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Redmi Microsoft macOS