Skip to content

Commit f9444c9

Browse files
authored
github.com/pinpoint-apm/go-aop-agent@dev_fix-asm-missing (#17)
* refactor(exclude-image): exclude image fold * DO not inlucde iamge * asm use soft-link * no download * update go v1.0.1
1 parent d3f8806 commit f9444c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

30 files changed

+12811
-12801
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ jobs:
3232
- name: compile test mux apps
3333
run: |
3434
cd testapps/mux
35-
GOOS=linux GOARCH=amd64 go mod download
35+
GOOS=linux GOARCH=amd64 go mod tidy
3636
GOOS=linux GOARCH=amd64 go build -o testapp
3737
- name: compile test echo apps
3838
run: |
3939
cd testapps/echo
40-
GOOS=linux GOARCH=amd64 go mod download
40+
GOOS=linux GOARCH=amd64 go mod tidy
4141
GOOS=linux GOARCH=amd64 go build -o testapp
4242
4343
go13:
@@ -71,10 +71,10 @@ jobs:
7171
- name: compile test mux apps
7272
run: |
7373
cd testapps/mux
74-
GOOS=linux GOARCH=amd64 go mod download
74+
GOOS=linux GOARCH=amd64 go mod tidy
7575
GOOS=linux GOARCH=amd64 go build -o testapp
7676
- name: compile test echo apps
7777
run: |
7878
cd testapps/echo
79-
GOOS=linux GOARCH=amd64 go mod download
79+
GOOS=linux GOARCH=amd64 go mod tidy
8080
GOOS=linux GOARCH=amd64 go build -o testapp

aop/Args.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

aop/Args.c

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
* Copyright 2021 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "Args.h"
17+
#include <stdio.h>
18+
#include <assert.h>
19+
ArgsT mk_imm_arg(Imm x){
20+
ArgsT args = {.type =E_IMM};
21+
args.value.imm=x;
22+
// assert(x!=1);
23+
return args;
24+
}
25+
26+
ArgsT mk_rel_arg(Rel x){
27+
ArgsT args = {.type =E_REL};
28+
args.value.rel=x;
29+
return args;
30+
}
31+
32+
ArgsT mk_reg_arg(Reg x){
33+
ArgsT args = {.type =E_REG};
34+
args.value.reg=x;
35+
return args;
36+
}
37+
38+
ArgsT mk_nil_arg(void){
39+
ArgsT args = {.type =E_NIL};
40+
return args;
41+
}
42+
43+
ArgsT mk_mem_arg(Mem x){
44+
ArgsT args = {.type =E_MEM};
45+
args.value.mem=x;
46+
return args;
47+
}
48+
49+
Imm* get_imm_arg(ArgsT* args)
50+
{
51+
if(args->type == E_IMM){
52+
return &args->value.imm;
53+
}
54+
return NULL;
55+
}
56+
57+
Reg* get_reg_arg(ArgsT* args)
58+
{
59+
if(args->type == E_REG){
60+
return &args->value.reg;
61+
}
62+
return NULL;
63+
}
64+
65+
Mem* get_mem_arg(ArgsT* args)
66+
{
67+
if(args->type == E_MEM){
68+
return &args->value.mem;
69+
}
70+
return NULL;
71+
}
72+
73+
Rel* get_rel_arg(ArgsT* args)
74+
{
75+
if(args->type == E_REL){
76+
return &args->value.rel;
77+
}
78+
return NULL;
79+
}
80+
81+
void args_str(ArgsT* args,char* buf ,int size)
82+
{
83+
switch(args->type){
84+
case E_IMM:
85+
snprintf(buf,size,"%lx",args->value.imm);
86+
break;
87+
case E_MEM:
88+
{
89+
Mem* m = get_mem_arg(args);
90+
if(m == NULL) return ;
91+
char scaleBuf[32]={0};
92+
char dispBuf[32]={0};
93+
const char*baseStr = "" ,*plus="" ,*index = "",*scale = "";
94+
if (m->Base !=0){
95+
baseStr = reg_name(m->Base);
96+
}
97+
98+
if(m->Scale !=0 ){
99+
if (m->Base !=0){
100+
plus ="+";
101+
}
102+
if(m->Scale >1){
103+
snprintf(scaleBuf,32,"%u",m->Scale);
104+
scale = scaleBuf;
105+
}
106+
index = reg_name(m->Index);
107+
108+
}
109+
110+
if( m->Disp !=0 || (m->Base == 0 && m->Scale == 0)) {
111+
snprintf(dispBuf,32,"+0x%lx",m->Disp);
112+
}
113+
snprintf(buf,size,"[%s%s%s%s%s]",baseStr,plus,scale,index,dispBuf);
114+
break;
115+
}
116+
case E_REG:
117+
{
118+
snprintf(buf,size,"%s",reg_name(args->value.reg));
119+
break;
120+
}
121+
case E_REL:
122+
{
123+
snprintf(buf,size,"+%d",args->value.rel);
124+
break;
125+
}
126+
case E_NIL:
127+
snprintf(buf,size,"nil");
128+
break;
129+
}
130+
}
131+
132+
133+
ArgsT fixedArg[113] ={
134+
[xArg1]= {.type=E_IMM, .value.imm=1},
135+
[xArg3]= {.type=E_IMM, .value.imm=3},
136+
[xArgAL]= {.type=E_REG, .value.reg = AL},
137+
[xArgAX]= {.type=E_REG, .value.reg =AX},
138+
[xArgDX]= {.type=E_REG, .value.reg =DX},
139+
[xArgEAX]= {.type=E_REG, .value.reg =EAX},
140+
[xArgEDX]= {.type=E_REG, .value.reg =EDX},
141+
[xArgRAX]= {.type=E_REG, .value.reg =RAX},
142+
[xArgRDX]= {.type=E_REG, .value.reg =RDX},
143+
[xArgCL]= {.type=E_REG, .value.reg =CL},
144+
[xArgCS]= {.type=E_REG, .value.reg =CS},
145+
[xArgDS]= {.type=E_REG, .value.reg =DS},
146+
[xArgES]= {.type=E_REG, .value.reg =ES},
147+
[xArgFS]= {.type=E_REG, .value.reg =FS},
148+
[xArgGS]= {.type=E_REG, .value.reg =GS},
149+
[xArgSS]= {.type=E_REG, .value.reg =SS},
150+
[xArgST]= {.type=E_REG, .value.reg =F0},
151+
[xArgXMM0]= {.type=E_REG, .value.reg =X0},
152+
};

aop/Args.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

aop/Args.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2021 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#pragma once
17+
#include "table.h"
18+
19+
typedef enum {
20+
E_NIL=0,E_MEM,E_IMM,E_REG,E_REL
21+
}E_ARGS_TYPE;
22+
typedef struct
23+
{
24+
E_ARGS_TYPE type;
25+
union
26+
{
27+
Mem mem;
28+
Imm imm;
29+
Reg reg;
30+
Rel rel;
31+
} value;
32+
}ArgsT;
33+
34+
ArgsT mk_imm_arg(Imm x);
35+
ArgsT mk_mem_arg(Mem x);
36+
ArgsT mk_reg_arg(Reg x);
37+
ArgsT mk_nil_arg(void);
38+
ArgsT mk_rel_arg(Rel x);
39+
40+
41+
Imm* get_imm_arg(ArgsT* args);
42+
Mem* get_mem_arg(ArgsT* args);
43+
Reg* get_reg_arg(ArgsT* args);
44+
Rel* get_rel_arg(ArgsT* args);
45+
46+
#define IS_IMM(x) (x.type == E_IMM)
47+
#define IS_MEM(x) (x.type == E_MEM)
48+
#define IS_NIL(x) (x.type == E_NIL)
49+
#define IS_REG(x) (x.type == E_REG)
50+
#define IS_REL(x) (x.type == E_REL)
51+
52+
void args_str(ArgsT*,char* buf ,int size);
53+
extern ArgsT fixedArg[113];

aop/Inst.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

aop/Inst.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
/*
3+
* Copyright 2021 NAVER Corp.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#include "Inst.h"
18+
#include <stdio.h>
19+
#include <string.h>
20+
21+
#define SUFFIX_STR ", "
22+
23+
void inst_str(Inst* inst,char* buf,int buf_size)
24+
{
25+
int i = 0;
26+
if(buf == NULL || inst == NULL || buf_size <=0){
27+
return ;
28+
}
29+
//parse prefix
30+
char *pbuf = buf;
31+
int done = 0;
32+
for (i = 0; i < PREFIX_SIZE; i++) {
33+
Prefix p =inst->Prefix[i];
34+
if(p == 0){
35+
break;
36+
}
37+
38+
if ( (p&PrefixImplicit) !=0){
39+
continue;
40+
}
41+
done = snprintf(pbuf,buf_size,"%hu",p);
42+
if(done<buf_size){
43+
buf_size -= done;
44+
pbuf += done;
45+
}else{
46+
return;
47+
}
48+
}
49+
//parse op
50+
done = snprintf(pbuf,buf_size,"%s ",op_name(inst->Op));
51+
if(done>= buf_size){
52+
return;
53+
}
54+
55+
pbuf+=done;
56+
buf_size -=done;
57+
//parse args
58+
for (i = 0; i < ARGS_SIZE ; i++) {
59+
if( IS_NIL(inst->Args[i])){
60+
break;
61+
}
62+
char argsBuf[128]={0};
63+
args_str(&inst->Args[i],argsBuf,sizeof(argsBuf));
64+
done = snprintf(pbuf,buf_size,"%s"SUFFIX_STR,argsBuf);
65+
66+
if(done>= buf_size || buf_size <=0 ){
67+
return;
68+
}
69+
pbuf+=done;
70+
buf_size -= done;
71+
}
72+
73+
//rollback suffix_str
74+
*(pbuf - strlen(SUFFIX_STR))= '\0';
75+
}

aop/Inst.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

aop/Inst.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2021 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#pragma once
17+
#include "Args.h"
18+
#include "table.h"
19+
20+
// the same as x86asm Inst
21+
#define PREFIX_SIZE 14
22+
#define ARGS_SIZE 4
23+
typedef uint32_t OpcodeType;
24+
#define OPCODE_1(Opcode) ((Opcode>>24))
25+
#define OPCODE_2(Opcode) (((Opcode>>16)&0xFF))
26+
typedef struct
27+
{
28+
uint16_t Prefix[PREFIX_SIZE];
29+
uint32_t Op;
30+
uint32_t Opcode;
31+
ArgsT Args[ARGS_SIZE];
32+
int Mode;
33+
int AddrSize;
34+
int DataSize;
35+
int MemBytes;
36+
int Len;
37+
int PCRel;
38+
int PCRelOff;
39+
}Inst;
40+
41+
void inst_str(Inst* inst,char* buf,int buf_size);
42+

aop/goX86asm.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)