Skip to content

Commit

Permalink
Partial fix for xdebug 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyKupershtokh committed Apr 14, 2013
1 parent af7a6ca commit be473d6
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 12 deletions.
36 changes: 24 additions & 12 deletions cgparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,22 @@ class XdebugCachegrindFsaParser:
# -2 got eof or fl, finish parsing
# -1 error, finish parsing
# 0 start
# 1 got version, expecting cmd
# 1 got version, expecting cmd or creator
# 2 got cmd, expecting part
# 3 gor part, expecting events
# 3 got part, expecting events or positions
# 4 got events, expecting fl or eof
# 5 got creator, expecting cmd
# 6 got positions, expecting events
header_fsm = {
# 0 1 2 3 4
0: [ 1, -1, -1, -1, -1], # version
1: [-1, 2, -1, -1, -1], # cmd
2: [-1, -1, 3, -1, -1], # part
3: [-1, -1, -1, 4, -1], # events
4: [-1, -1, -1, -1, -2], # fl
5: [-1, -1, -1, -1, -2], # eof
# 0 1 2 3 4 5 6 # token:
0: [ 1, -1, -1, -1, -1, -1, -1], # version
1: [-1, 2, -1, -1, -1, 2, -1], # cmd
2: [-1, -1, 3, -1, -1, -1, -1], # part
3: [-1, -1, -1, 4, -1, -1, 4], # events
4: [-1, -1, -1, -1, -2, -1, -1], # fl
5: [-1, -1, -1, -1, -2, -1, -1], # eof
6: [-1, 5, -1, -1, -1, -1, -1], # creator
7: [-1, -1, -1, 6, -1, -1, -1], # positions
}

# body states:
Expand All @@ -231,7 +235,7 @@ class XdebugCachegrindFsaParser:
# 6 got subcall num, expecting fl or cfn or eof
# 7 got summary, expecting num
body_fsm = {
# 0 1 2 3 4 5 6 7
# 0 1 2 3 4 5 6 7 # token:
0: [ 0, -1, -1, -1, -1, -1, -1, -1], # header
1: [ 1, -1, -1, 1, -1, -1, 1, -1], # fl
2: [-1, 2, -1, -1, -1, -1, -1, -1], # fn
Expand All @@ -250,6 +254,7 @@ def get_header(self):

state = 0;
line_no = 0
version = None

while True:
token = None
Expand All @@ -258,7 +263,7 @@ def get_header(self):
line_no += 1
if line == '\n':
continue
if line == 'version: 0.9.6\n':
if line[0:9] == 'version: ':
token = 0
if line[0:5] == 'cmd: ':
token = 1
Expand All @@ -268,6 +273,10 @@ def get_header(self):
token = 3
if line[0:3] == 'fl=':
token = 4
if line[0:9] == 'creator: ':
token = 6
if line[0:11] == 'positions: ':
token = 7
except StopIteration:
token = 5

Expand All @@ -282,10 +291,13 @@ def get_header(self):
elif state == -1:
raise CgParseError(line_no, line, token)

elif state == 1:
version = line[9:-1]

elif state == 2:
cmd = line[5:-1]

return RawHeader('0.9.6', cmd, '1', 'Time')
return RawHeader(version, cmd, '1', 'Time')

def get_body(self):
body = []
Expand Down
175 changes: 175 additions & 0 deletions fixtures/1.php.xdebug-2.2.1.cg
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
version: 1
creator: xdebug 2.2.1
cmd: /home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
part: 1
positions: line

events: Time

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 2

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 2

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=a->__construct
3 31
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=c
calls=1 0 0
4 2
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=c
calls=1 0 0
5 2

fl=php:internal
fn=php::usleep
20 100090

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=d
19 102
cfl=php:internal
cfn=php::usleep
calls=1 0 0
20 100090

fl=php:internal
fn=php::usleep
20 100101

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=d
19 87
cfl=php:internal
cfn=php::usleep
calls=1 0 0
20 100101

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=b->__construct
10 56
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=d
calls=1 0 0
11 100193
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=d
calls=1 0 0
12 100189

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 3

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 3

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=a->__construct
3 53
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=c
calls=1 0 0
4 3
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=c
calls=1 0 0
5 3

fl=php:internal
fn=php::usleep
20 100133

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=d
19 92
cfl=php:internal
cfn=php::usleep
calls=1 0 0
20 100133

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 4

fl=php:internal
fn=php::usleep
20 100079

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=d
19 56
cfl=php:internal
cfn=php::usleep
calls=1 0 0
20 100079

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 2

fl=php:internal
fn=php::register_shutdown_function
31 18

fl=php:internal
fn=php::register_shutdown_function
32 2

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn={main}

summary: 401180

1 255
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=a->__construct
calls=1 0 0
23 36
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=b->__construct
calls=1 0 0
24 200440
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=a->__construct
calls=1 0 0
25 60
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=d
calls=1 0 0
26 100226
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=c
calls=1 0 0
27 4
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=d
calls=1 0 0
28 100135
cfl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
cfn=c
calls=1 0 0
29 2
cfl=php:internal
cfn=php::register_shutdown_function
calls=1 0 0
31 18
cfl=php:internal
cfn=php::register_shutdown_function
calls=1 0 0
32 2

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 1

fl=/home/wicked/Alawar/xdebugtoolkit-github/fixtures/1.php
fn=c
16 0

0 comments on commit be473d6

Please sign in to comment.