Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing of the build.log fails when a command has \"\ #62

Closed
sylvestre opened this issue Sep 7, 2015 · 2 comments
Closed

Parsing of the build.log fails when a command has \"\ #62

sylvestre opened this issue Sep 7, 2015 · 2 comments
Assignees
Labels
Milestone

Comments

@sylvestre
Copy link
Contributor

For example, the program that I am trying to build has this define:
-DDEFAULT_ICU_PLUGINS="/usr/local/lib/icu"\

Codechecker will fail this:
[ERROR] - The compile database is not valid.
[ERROR] - Invalid \escape: line 29848 column 786 (char 10574627)

@sylvestre sylvestre changed the title Parsing of the build.log fails when a command has \" Parsing of the build.log fails when a command has \"\ Sep 8, 2015
@igalex igalex added this to the week43 - 2015 milestone Oct 19, 2015
igalex pushed a commit to igalex/codechecker that referenced this issue Oct 22, 2015
- Remove incorrect space escaping from ldlogger
- Add quotation marks around arguments with spaces
- Use shlex for splitting command line arguments

Fixes Ericsson#62
@sylvestre
Copy link
Contributor Author

@igalex Doesn't seem fix to me.
With this line:

        "command": "gcc -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/local/include -I/usr/include/x86_64-linux-gnu -I/usr/include -E -MM -DU_ATTRIBUTE_DEPRECATED= -DU_COMMON_IMPLEMENTATION -DU_USING_ICU_NAMESPACE=0 -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 -DUCONFIG_NO_LEGACY_CONVERSION -DUCONFIG_NO_TRANSLITERATION -DUCONFIG_NO_REGULAR_EXPRESSIONS -DUCONFIG_NO_BREAK_ITERATION -DU_CHARSET_IS_UTF8 -I/home/sylvestre/dev/mozilla/ff/mozilla-inbound/intl/icu/source/common -I/home/sylvestre/dev/mozilla/ff/mozilla-inbound/intl/icu/source/i18n -ffunction-sections -fdata-sections -D_REENTRANT -DU_HAVE_ELF_H=1 -DU_HAVE_ATOMIC=1 -I/home/sylvestre/dev/mozilla/ff/mozilla-inbound/intl/icu/source/common -DDEFAULT_ICU_PLUGINS=\"/usr/local/lib/icu\"\  /home/sylvestre/dev/mozilla/ff/mozilla-inbound/intl/icu/source/common/icudataver.c",

codechecker is failing with:

  File "/home/sylvestre/dev/mozilla/codechecker/codechecker_package/CodeChecker/cc_lib/python2.7/codechecker_lib/log_parser.py", line 78, in parse_log
    actions = parse_compile_commands_json(logfile)
  File "/home/sylvestre/dev/mozilla/codechecker/codechecker_package/CodeChecker/cc_lib/python2.7/codechecker_lib/log_parser.py", line 26, in parse_compile_commands_json
    data = json.load(logfile)
  File "/usr/lib/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Invalid \escape: line 3202 column 782 (char 466173)

[ERROR] - Invalid \escape: line 3202 column 782 (char 466173)
`̀``

@joaobortotcadore
Copy link

joaobortotcadore commented Jan 4, 2023

I have the same problem when I load the compile_commands.json generated by espressif/idf:v4.4.1. And I suspect it's because of those escape backslashes (\)

ESP-IDF adds these \\\:
-DMBEDTLS_CONFIG_FILE=\\\"mbedtls/esp_config.h\\\"

Expanded section:
"command": "/opt/esp/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\\\"mbedtls/esp_config.h\\\" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -I/opt/esp/idf/comp>

I haven't tried it yet, but if single quotes solve the problem, with SED you could replace the \\\ by '

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants