예제 #1
0
    status_t PropertyMap::Parser::parse() {
        while (!mTokenizer->isEof()) {
#if DEBUG_PARSER
            ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().string(),
                    mTokenizer->peekRemainderOfLine().string());
#endif

            mTokenizer->skipDelimiters(WHITESPACE);

            if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
                String8 keyToken = mTokenizer->nextToken(WHITESPACE_OR_PROPERTY_DELIMITER);
                if (keyToken.isEmpty()) {
                    ALOGE("%s: Expected non-empty property key.",
                          mTokenizer->getLocation().string());
                    return BAD_VALUE;
                }

                mTokenizer->skipDelimiters(WHITESPACE);

                if (mTokenizer->nextChar() != '=') {
                    ALOGE("%s: Expected '=' between property key and value.",
                          mTokenizer->getLocation().string());
                    return BAD_VALUE;
                }

                mTokenizer->skipDelimiters(WHITESPACE);

                String8 valueToken = mTokenizer->nextToken(WHITESPACE);
                if (valueToken.find("\\", 0) >= 0 || valueToken.find("\"", 0) >= 0) {
                    ALOGE("%s: Found reserved character '\\' or '\"' in property value.",
                          mTokenizer->getLocation().string());
                    return BAD_VALUE;
                }

                mTokenizer->skipDelimiters(WHITESPACE);
                if (!mTokenizer->isEol()) {
                    ALOGE("%s: Expected end of line, got '%s'.",
                          mTokenizer->getLocation().string(),
                          mTokenizer->peekRemainderOfLine().string());
                    return BAD_VALUE;
                }

                if (mMap->hasProperty(keyToken)) {
                    ALOGE("%s: Duplicate property value for key '%s'.",
                          mTokenizer->getLocation().string(), keyToken.string());
                    return BAD_VALUE;
                }

                mMap->addProperty(keyToken, valueToken);
            }

            mTokenizer->nextLine();
        }
        return NO_ERROR;
    }
예제 #2
0
/******************************************************************************
*   Splits a comma delimited string to a List of int Vector.
*   Example string: "(10000,26623),(10000,30000)"
*******************************************************************************/
bool
ParamsManager::
splitRange(String8 const& s8Input, List< Vector<int> >& rOutput)
{
    rOutput.clear();
    //
    if  ( s8Input.isEmpty() )
    {
        MY_LOGW("empty string");
        return  false;
    }
    //
    int endIndex, fromIndex = 1;
    int endIndex_input = s8Input.length()-1;
    if  ( s8Input[0] != '(' || s8Input[endIndex_input] != ')' )
    {
        MY_LOGW("Invalid range list string=%s", s8Input.string());
        return  false;
    }
    //
    do  {
        endIndex = s8Input.find("),(", fromIndex);
        if (endIndex == -1) endIndex = endIndex_input;
        //
        Vector<int> vOut;
        String8 const s8SubString(s8Input.string()+fromIndex, endIndex-fromIndex);
        if  ( splitInt(s8SubString, vOut) ) {
            rOutput.push_back(vOut);
        }
        //
        fromIndex = endIndex + 3;
    } while (endIndex != endIndex_input);
    //
    return  (rOutput.size() > 0);
}
String8 getComponentName(String8 &pkgName, String8 &componentName) {
    ssize_t idx = componentName.find(".");
    String8 retStr(pkgName);
    if (idx == 0) {
        retStr += componentName;
    } else if (idx < 0) {
        retStr += ".";
        retStr += componentName;
    } else {
        return componentName;
    }
    return retStr;
}
void ProgramCache::printLongString(const String8& shader) const {
    ssize_t index = 0;
    ssize_t lastIndex = 0;
    const char* str = shader.string();
    while ((index = shader.find("\n", index)) > -1) {
        String8 line(str, index - lastIndex);
        if (line.length() == 0) line.append("\n");
        PROGRAM_LOGD("%s", line.string());
        index++;
        str += (index - lastIndex);
        lastIndex = index;
    }
}
예제 #5
0
// Verify that the comma separated list of functions are being traced by the
// kernel.
static bool verifyKernelTraceFuncs(const char* funcs)
{
    int fd = open(k_ftraceFilterPath, O_RDONLY);
    if (fd == -1) {
        fprintf(stderr, "error opening %s: %s (%d)\n", k_ftraceFilterPath,
            strerror(errno), errno);
        return false;
    }

    char buf[4097];
    ssize_t n = read(fd, buf, 4096);
    close(fd);
    if (n == -1) {
        fprintf(stderr, "error reading %s: %s (%d)\n", k_ftraceFilterPath,
            strerror(errno), errno);
        return false;
    }

    buf[n] = '\0';
    String8 funcList = String8::format("\n%s", buf);

    // Make sure that every function listed in funcs is in the list we just
    // read from the kernel.
    bool ok = true;
    char* myFuncs = strdup(funcs);
    char* func = strtok(myFuncs, ",");
    while (func) {
        String8 fancyFunc = String8::format("\n%s\n", func);
        bool found = funcList.find(fancyFunc.string(), 0) >= 0;
        if (!found || func[0] == '\0') {
            fprintf(stderr, "error: \"%s\" is not a valid kernel function "
                "to trace.\n", func);
            ok = false;
        }
        func = strtok(NULL, ",");
    }
    free(myFuncs);

    return ok;
}
예제 #6
0
// BufferQueueCore part
// -----------------------------------------------------------------------------
void BufferQueueDebug::onConstructor(
        wp<BufferQueueCore> bq, const String8& consumerName) {
    mBq = bq;
    mPid = getpid();
    mConsumerName = consumerName;
    if (sscanf(consumerName.string(), "unnamed-%*d-%d", &mId) != 1) {
        BQ_LOGE("id info cannot be read from '%s'", consumerName.string());
    }

    if (NO_ERROR == getProcessName(mPid, mConsumerProcName)) {
        BQ_LOGI("BufferQueue core=(%d:%s)", mPid, mConsumerProcName.string());
    } else {
        BQ_LOGI("BufferQueue core=(%d:\?\?\?)", mPid);
    }

    mIsInGuiExt = (mConsumerProcName.find("guiext-server") != -1);
    mDump = new BufferQueueDump(mIsInGuiExt ?
            BufferQueueDump::TRACK_PRODUCER : BufferQueueDump::TRACK_CONSUMER, mBq.unsafe_get());

    if (mDump == NULL) {
        BQ_LOGE("new BufferQueueDump() failed in BufferQueue()");
    }
    // update dump name
    mDump->setName(consumerName);

    // check property for drawing debug line
    char value[PROPERTY_VALUE_MAX];
    property_get("debug.bq.line", value, "GOD'S IN HIS HEAVEN, ALL'S RIGHT WITH THE WORLD.");
    mLine = (-1 != consumerName.find(value));
    mLineCnt = 0;

    if (true == mLine) {
        BQ_LOGI("switch on debug line");
    }

    if (!mIsInGuiExt) {
        BufferQueueMonitor::getInstance().monitor(mBq);
    }
}