Make getlog commands less flakey

getlog {kill,none}
getlog what
getlog list
getlog err,wrn[,...]
This commit is contained in:
Douglas Clowes
2015-03-13 15:16:31 +11:00
parent d751146090
commit b9954651d5
4 changed files with 70 additions and 8 deletions

View File

@@ -140,14 +140,20 @@ int OutCodeFromText(const char *text, OutCode *outcode)
}
static unsigned int find_code_bits(const char *p1, const char *p2) {
/* must be outcode, try find it */
/* may be outcode, try find it */
int i;
const char *pShort;
const char *pLong;
size_t len = p2 - p1;
if (len == 3 && strncasecmp(p1, "all", 3))
return ~0;
if (len == 3 && strncasecmp(p1, "all", 3) == 0)
return (1 << iNoCodes) - 1;
for (i = 0; i < iNoCodes; ++i) {
if (pCode[i] != NULL && strlen(pCode[i]) == len) {
if (strncasecmp(p1, pCode[i], len) == 0) {
pShort = OutCodeToTxt(i);
if (pShort && strncasecmp(p1, pShort, len) == 0)
return 1 << i;
pLong = OutCodeToText(i);
if (pLong && strlen(pLong) == len) {
if (strncasecmp(p1, pLong, len) == 0) {
return 1 << i;
}
}
@@ -159,7 +165,7 @@ char *AddSICSLogHook(pSICSLogHook func, const char *pCodes, void *pData)
{
unsigned int code_bits = 0;
if (strcasecmp("all", pCodes) == 0)
code_bits = ~0;
code_bits = (1 << iNoCodes) - 1;
else {
const char *p1, *p2;
p1 = pCodes;
@@ -221,6 +227,23 @@ char *RemSICSLogHook(void *pData)
return NULL;
}
/* Return bitmask of any and all hooks with this pData */
unsigned int GetSICSLogHook(void *pData)
{
pCaptureEntry pCurrent, pTemp;
unsigned int code_bits = 0;
/* find first */
pCurrent = pCapture;
while (pCurrent != NULL) {
if (pData == pCurrent->pData) {
code_bits |= pCurrent->code_bits;
}
pCurrent = pCurrent->pNext;
}
return code_bits;
}
/*--------------------------------------------------------------------------*/
static int HasLineFeed(char *pText)