Vscode-cpptools: AArch inline asm: "unknown register name" clobber list

Created on 3 Oct 2019  Â·  7Comments  Â·  Source: microsoft/vscode-cpptools

Type: LanguageService

The bug

  • OS and Version:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic

$ uname -a
Linux serg-VM 4.15.0-64-generic #73-Ubuntu SMP Thu Sep 12 13:16:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • VS Code Version:
Version: 1.38.1
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:30:08.229Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-64-generic
  • C/C++ Extension Version: 0.25.1 (problem exist in v0.23.1 too)
  • No other extensions are installed
  • AArch-specific (ARM) register names aren't recognized in the clobber list of inline asm statement. Nevertheless the code successfully compiles and works.

To Reproduce

  1. Go to any C function body.
  2. Paste asm("mov w0, #0":::"r0");
  3. See error

Expected behavior
AArch-specific register names must be recognized just like x86's eax, rax and so.

Screenshots
image

Language Service Visual Studio bug

Most helpful comment

All 7 comments

Thanks for reporting this. I reported it to the VS team at https://developercommunity.visualstudio.com/content/problem/778258/cc-intellisense-shows-unknown-register-name-with-a.html .

It's possible we may also need to add support for ARM IntelliSense mode and -std=gnu11 for all the errors to disappear (we have other issues tracking those).

During WFH about half the developers I work with have been using VSCode and the other half don't use GUI IDEs. A few of us do Linux kernel module development for ARM and MIPS. There is a macro called get_user that obtains one scalar value from user space, and on ARM it expands to inline assembly referencing r0. Every file that has a get_user macro in gets tagged as a problem.

@cardiffman If you can edit the macro, you may be able to avoid the errors via surrounding the code in a

#ifndef __INTELLISENSE__
// code we don't handle correctly
#endif

@cardiffman If you can edit the macro, you may be able to avoid the errors via surrounding the code in a

#ifndef __INTELLISENSE__
// code we don't handle correctly
#endif

Interesting idea. It makes sense that you would have a macro defined to help with that.

Happens the same with ARM7:

cpptools version: 0.28.1

VSCode version:

Version: 1.45.1 (system setup)
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:27:35.169Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363
gcc --version
gcc (GCC) 4.0.1 (WinARM)
"C_Cpp.default.compilerArgs": [ "-mcpu=arm7tdmi" ]

Snippets:

// Simply declaring a variable triggers the error
register int r0 asm("r0");

Or declaring registers in the clobber section:

asm volatile (
    "mov        ip, %[p1]\n\t"
    [... some mode code ...]
    : /* output */
    : /* input */   [p1]  "r" (portdata)
    : /* clobber */ "r0", "r1", "r2", "r3", "r4", "ip" );

image

Same issue - I included "eax" just for demonstration. I would have thought that changing intelliSenseMode to "gcc-arm" would fix this. Intellisense is only recognising x86 registers.

Was this page helpful?
0 / 5 - 0 ratings