자주 사용하는 분석 옵션은?

수정일 Fri, 16 Sep 2022 시간: 09:26 AM

목록


  • 전처리 관련 설정

1. cs_define_macro_value

Option

cs_define_macro_value

Version

All

Usage

--cs_define_macro_value=__SIGNED_INT__;signed int

--cs_define_macro_value=__A__;a

Description

Set macros with values

Example code

__SIGNED_INT__ a;

// This syntax equivalent to “signed int a;”

int __A__ = 10;

// This expression is also possible.

// This syntax equivalent to ‘int a = 10;’

int a = __UNSIGNED_INT__;

// This syntax equivalent to ‘int a = signed int;’  Error


2. cs_define_macro_name

Option

cs_define_macro_name

Version

All

Usage

--cs_define_macro_name=__STDIO_HEADER__

--cs_define_macro_name=__MY_INT__

Description

Set macros with names only

Example code

#ifndef __STDIO_HEADER__

#include <stdio.h>

#endif

// __STDIO_HEADER is defined as a macro by configuration

// Therefore, this syntax is parsed

__MY_INT__ a;

// __MY_INT__ can’t use as type because of macro with name only.  Error

int __MY_INT__;

// __MY_INT__ can’t not an identifier.  Error


3. cs_builtin_declaration

Option

cs_builtin_declaration

Version

All

Usage

--cs_builtin_declaration=void __enable_interrupt(void);

--cs_builtin_declaration=void __disable_interrupt(void);

Description

Set syntax to add in advance

Add built-in functions or types not supported by EDG

Add a variable or function declaration with no definitions or declarations

Set to make the specified function callable

Example code

int main() {

int a = 10;

int b;

__enable_interrupt(); // This function is declared as built-in function

a = a * a;

b = a * 5;

__disable_interrupt(); // This function is declared as built-in function

}


  • 키워드 무시 관련 설정

4. cs_ignore_brace

Option

cs_ignore_brace

Version

All

Usage

--cs_ignore_brace=id

Description

Syntax ignore option

Set to ignore the syntax of the specified_name { contents }

Example code

int main()

{

int a = 10;

id{  };  // it is ignored.

return a;

}

 

5. cs_ignore_braced_initialize

Option

cs_ignore_braced_initializer

Version

All

Usage

--cs_ignore_braced_initializer

Description

Syntax ignore option

Example code

 

 

6. cs_ignore_keyword_pair

Option

cs_ignore_keyword_pair

Version

All

Usage

--cs_ignore_keyword_pair=ignore_start;ignore_end

Description

Syntax ignore option

Set to ignore the contents between the specified two keywords

Example code

void ignore_until_keyword() 

ignore_start

// The contents in this section are ignored.

ignore_end

int i= s_var; 

staticAssert(SOME_MACRO == 100); 

}

 

7. cs_ignore_keyword_with_paren

Option

cs_ignore_keyword_with_paren

Version

All

Usage

--cs_ignore_keyword_with_paren=id

Description

Syntax ignore option

Set to ignore the syntax () appears after the specified name

Example code

id sum()

id();

 

8. cs_ignore_paren

Option

--cs_ignore_paren

Version

All

Usage

cs_ignore_paren=id

Description

Syntax ignore option

Set to ignore syntax of the form specified_name (contents)

Example code

id();                   // ignored

id(123123)             // ignored

int id(123123) func() {   

return 0;

}

// analyzing as

int func() {

return 0;

}

 

9. cs_ignore_single_keyword

Option

cs_ignore_single_keyword

Version

All

Usage

--cs_ignore_single_keyword=id

Description

Syntax ignore option

Set to ignore specified name

Example code

id int sum();  // id is ignored. Analyzing as ‘int sum();’

 

  • ASM 코드 관련 설정

10. cs_line_asm

Option

cs_line_asm

Version

All

Usage

--cs_line_asm=line_asm

Description

Syntax ignore option

Represents a one-line inline assembly with the specified name

Set to ignore the one-line

Example code

int singleLineAsm() 

line_asm mov ax, bx; int a;  // This line is ignored.

int a = 0; 

a = 100; 

return a; 

}

 

11. cs_asm_directive

Option

cs_asm_directive

Version

All

Usage

--cs_asm_directive=asm_start;asm_end

Description

Syntax ignore option

Recognize contents between two specified directives as assembly

Set to ignore the contents

Example code

int asmDirective() 

#asm_start

. . .

It is ignored. 

. . .

#asm_end

return 0;

}

 

12. cs_asm_function

Option

cs_asm_function

Version

All

Usage

--cs_asm_function=asm

Description

Syntax ignore option

Set to ignore function syntax declared with specified name

Example code

asm int asmMacro() 

mov ah, 0 

ret 

}

// asmMacro function is ignored

 

13. cs_asm_function_pragma

Option

cs_asm_function_pragma

Version

All

Usage

--cs_asm_function_pragma=asm

Description

Syntax ignore option

Set to ignore the function pragma directive syntax of the specified name

Example code

#pragma asm(pragmaAsmFunction)

 

14. cs_brace_asm

Option

cs_brace_asm

Version

All

Usage

--cs_brace_asm=my_asm

Description

Syntax ignore option

Set to ignore syntax of the form specified name { contents }

Example code

my_asm

{

mov ax, #10 

}   

 

15. cs_paren_asm

Option

cs_paren_asm

Version

All

Usage

--cs_paren_asm=paren_asm

Description

Syntax ignore option

Represent an inline assembly with a syntax of the form specified_name (content)

Set to ignore the syntax

Example code

void parenAsmInDecl() 

paren_asm("mov ax, bx") int x;  

// The paren_asm(…) syntax is ignored.

// This line is analyzed as ‘int x;’

x = 10;

}

 

  • 타입 사이즈 관련 설정

16. cs_int_size

Option

cs_int_size

Version

All

Usage

--cs_int_size=2

Description

Compiler-specific type support

Set int type size to specified number

Example code

 

 

17. cs_plain_bit_field

Option

cs_plain_bit_field

Version

All

Usage

--cs_plain_bit_field=unsigned

Description

Set the sign of plain bit field type

Example code

 

 

18. cs_plain_char

Option

cs_plain_char

Version

All

Usage

--cs_plain_char=unsigned

Description

Compiler-specific type support

Set the sign of plain char type

Example code

 

 

19. cs_pointer_size

Option

cs_pointer_size

Version

All

Usage

--cs_pointer_size=4

Description

Compiler-specific type support

Set pointer type size to specified number

Example code

 

 

20. cs_size_t_kind

Option

cs_size_t_kind

Version

All

Usage

--cs_size_t_kind=int

Description

Compiler-specific type support

Set the type of size_t to the specified type

Example code

 


21. cs_add_float_type

Option

cs_add_float_type

Version

All

Usage

--cs_add_float_type=my_8byteFloat;8

Description

Compiler-specific type support

Add float type with the specified name and size

Example code

void operator(my_8byteFloat param);    

 

22. cs_add_integer_type

Option

cs_add_integer_type

Version

All

Usage

--cs_add_integer_type=my_4byteInt;4

Description

Compiler-specific type support

Add integer type with the specified name and size

Example code

void operator(my_4byteInt param);

void operator2(unsigned my_4byteInt param);


23. cs_char_size

Option

cs_char_size

Version

All

Usage

--cs_char_size=2

Description

Compiler-specific type support

Set char type size to specified number

Example code

 

24. cs_long_size

Option

cs_long_size

Version

All

Usage

--cs_long_size=4

Description

Compiler-specific type support

Set long type size to specified number

Example code

 

 

25. cs_double_size

Option

cs_double_size

Version

All

Usage

--cs_double_size=16

Description

Compiler-specific type support

Set double type size to specified number

Example code

 

26. cs_float_size

Option

cs_float_size

Version

All

Usage

--cs_float_size=8

Description

Compiler-specific type support

Set float type size to specified number

Example code

 

  • 기타 설정

27. cs_replace_code

Option

cs_replace_code

Version

All

Usage

--cs_replace_code=Xint<cs_delim>int

Description

Convert to compilable code

Set to replace specified string with another specified string

Example code

Xint i = 10;

// Xint is replaced with int. Analyzing as ‘int i = 10;’

 

28. cs_replace_code_re

Option

cs_replace_code_re

Version

All

Usage

--cs_replace_code_re=immediate\s.+; <cs_delim>

Description

Convert to compilable code

Set to replace strings that match the specified regular expression with the specified string

Example code

int replace_regEx()

{

int a = 10;

int b = 20;

immediate x = 4;       // It is replaced with blank

immediate y = ‘c’;   // It is replaced with blank

return a + b;;

}

 

29. cs_replace_include_system

Option

cs_replace_include_system

Version

All

Usage

--cs_replace_include_system

Description

Convert to compilable code

Example code

 

30. cs_allow_using_unmodifiable_rvalue_as_lvalue

Option

cs_allow_using_unmodifiable_rvalue_as_lvalue

Version

All

Usage

--cs_allow_using_unmodifiable_rvalue_as_lvalue

Description

Syntax expansion option

Set to allow using unmodifiable rvalue as lvalue

Example code

void unmodifiable_rvalue()

{

(char*) 0x555555 = 0;

}

 

아티클이 유용했나요?

훌륭합니다!

피드백을 제공해 주셔서 감사합니다.

도움이 되지 못해 죄송합니다!

피드백을 제공해 주셔서 감사합니다.

아티클을 개선할 수 있는 방법을 알려주세요!

최소 하나의 이유를 선택하세요

피드백 전송

소중한 의견을 수렴하여 아티클을 개선하도록 노력하겠습니다.