-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Using the example file func_calls.py from pycparser, with the only modification of instantiating a GnuCParser:
def show_func_calls(filename, funcname):
gnu_parser = GnuCParser()
ast = parse_file(filename, use_cpp=False, parser=gnu_parser)
v = FuncCallVisitor(funcname)
v.visit(ast)
Basic "asm" expressions are parsed correctly, such as
asm ("foo" ::: "bar");
or
__asm__ ("foo" ::: "bar", "bar");
However, any asm expression with i/o operands will fail with the error: AttributeError: 'Constant' object has no attribute 'name'.
This is the test file I'm using:
#include <stdio.h>
void main(void)
{
// Sample: asm volatile("" ::: "memory")
// => WORKS
asm ("foo" ::: "bar");
// Sample: __asm__ __volatile__("sub pc, pc, -4" ::: "memory", "cc")
// => WORKS
__asm__ ("foo" ::: "bar", "bar");
// Sample: __asm__ ("brev\t%0" : "+r" (__value) : : "cc")
// => ERROR
__asm__ ("foo" : "bar" (5) : : "bar");
// Sample: __asm__ __volatile__ ("ssrf\t%0" : : "i" (OFFSET))
// => ERROR
__asm__ ("foo" : : "bar" (5));
// Sample: __asm__ ("max\t%0, %1, %2" : "=r" (__value) : "r" (__arg_a), "r" (__arg_b))
// => ERROR
__asm__ ("foo" : "bar" (5) : "bar" (6), "baz" (7));
}
The samples are lines of code taken from a real application, I don't have much knowledge about the syntax of these GCC extension but these lines compile and work correctly with GCC 4.4.7 so I assume they are valid variations of the asm function.
Metadata
Metadata
Assignees
Labels
No labels