Skip to content

Commit

Permalink
Annotations for Constant Variables and Global Variables for the decom…
Browse files Browse the repository at this point in the history
…piler (#17281)
  • Loading branch information
NirmalManoj committed Jul 26, 2020
1 parent ebab0b4 commit 679c2c2
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions .appveyor.yml
Expand Up @@ -8,6 +8,7 @@ skip_tags: true
branches:
only:
- master
- decompiler-refactoring

# Environment variables
environment:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/centos6.yml
Expand Up @@ -7,6 +7,7 @@ on:
- 'prerelease*'
- 'release-*'
- 'centos*'
- 'decompiler-refactoring'
schedule:
- cron: '0 18 * * 1,3,5' # Three-weekly at 18:00 UTC on Monday, Wednesday, and Friday

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Expand Up @@ -7,6 +7,7 @@ on:
- 'pre-release*'
- 'prerelease*'
- 'release*'
- 'decompiler-refactoring'

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/newshell-treesitter-tests.yml
Expand Up @@ -10,6 +10,7 @@ on:
- 'shlr/radare2-shell-parser/**/*'
branches:
- master
- decompiler-refactoring

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr.yaml
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- master
- decompiler-refactoring

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/static.yml
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- master
- decompiler-refactoring

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -12,6 +12,7 @@ branches:
- master
- /^release-.*$/
- /^prerelease-.*$/
- decompiler-refactoring

services:
- docker
Expand Down
12 changes: 10 additions & 2 deletions libr/core/cannotated_code.c
Expand Up @@ -30,8 +30,16 @@ R_API void r_core_annotated_code_print_json(RAnnotatedCode *code) {
break;
case R_CODE_ANNOTATION_TYPE_FUNCTION_NAME:
pj_ks (pj, "type", "function_name");
pj_ks (pj, "name", annotation->function_name.name);
pj_kn (pj, "function_offset", annotation->function_name.offset);
pj_ks (pj, "name", annotation->reference.name);
pj_kn (pj, "offset", annotation->reference.offset);
break;
case R_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE:
pj_ks (pj, "type", "global_variable");
pj_kn (pj, "offset", annotation->reference.offset);
break;
case R_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE:
pj_ks (pj, "type", "constant_variable");
pj_kn (pj, "offset", annotation->reference.offset);
break;
case R_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT:
pj_ks (pj, "type", "syntax_highlight");
Expand Down
12 changes: 9 additions & 3 deletions libr/include/r_util/r_annotated_code.h
Expand Up @@ -35,7 +35,9 @@ typedef enum r_syntax_highlight_type_t {
typedef enum r_code_annotation_type_t {
R_CODE_ANNOTATION_TYPE_OFFSET,
R_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT,
R_CODE_ANNOTATION_TYPE_FUNCTION_NAME
R_CODE_ANNOTATION_TYPE_FUNCTION_NAME,
R_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE,
R_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE
// ...
} RCodeAnnotationType;

Expand All @@ -52,10 +54,14 @@ typedef struct r_code_annotation_t {
RSyntaxHighlightType type;
} syntax_highlight;

/** Information in annotations of type R_CODE_ANNOTATION_TYPE_FUNCTION_NAME,
* R_CODE_ANNOTATION_TYPE_GLOBAL_VARIABLE, and R_CODE_ANNOTATION_TYPE_CONSTANT_VARIABLE
* will be stored in the struct name reference in this union.
*/
struct {
char *name;
ut64 offset; // offset of the function with the name specified
} function_name;
ut64 offset; // address
} reference;
};
} RCodeAnnotation;

Expand Down
2 changes: 1 addition & 1 deletion libr/util/annotated_code.c
Expand Up @@ -17,7 +17,7 @@ R_API void r_annotation_free(void *e, void *user) {
(void)user;
RCodeAnnotation *annotation = e;
if (annotation->type == R_CODE_ANNOTATION_TYPE_FUNCTION_NAME) {
free (annotation->function_name.name);
free (annotation->reference.name);
}
}

Expand Down

0 comments on commit 679c2c2

Please sign in to comment.