Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] return values of socket_recvmsg

Posted by Sam Ding 
Sam Ding
[PHP-DEV] return values of socket_recvmsg
January 25, 2018 11:20PM
The test case ext/sockets/tests/socket_recvmsg.php has following output
on x86_64:

=======
....
1 Array
2 (
3 [name] => Array
4 (
5 [family] => 10
6 [addr] => ::1
7 [port] => 7001
8 [flowinfo] => 0
9 [scope_id] => 0
10 )
11
12 [control] => Array
13 (
14 [0] => Array
15 (
16 [level] => 41
17 [type] => 50
18 [data] => Array
19 (
20 [addr] => ::1
21 [ifindex] => 1
22 )
23 )
24 )
....
=======
This is output by c
function:"socket_recvmsg"(/home/work/php/php/ext/sockets/sendrecvmsg.c:214),
which returns a struct "executor_globals.current_execute_data".

The struct is defined as :

(gdb) ptype executor_globals.current_execute_data
type = struct _zend_execute_data {
const zend_op *opline;
zend_execute_data *call;
zval *return_value;
zend_function *func;
zval This;
zend_execute_data *prev_execute_data;
zend_array *symbol_table;
void **run_time_cache;
zval *literals;
} *

Where do the above output values (line 18-21) store in the struct
_zend_execute_data ?


Thanks,

Sam
Kalle Sommer Nielsen
Re: [PHP-DEV] return values of socket_recvmsg
January 26, 2018 08:00AM
Hi Sam

2018-01-25 23:11 GMT+01:00 Sam Ding <[email protected]>:
>
> The test case ext/sockets/tests/socket_recvmsg.php has following output
> on x86_64:
>
> =======
> ...
> 1 Array
> 2 (
> 3 [name] => Array
> 4 (
> 5 [family] => 10
> 6 [addr] => ::1
> 7 [port] => 7001
> 8 [flowinfo] => 0
> 9 [scope_id] => 0
> 10 )
> 11
> 12 [control] => Array
> 13 (
> 14 [0] => Array
> 15 (
> 16 [level] => 41
> 17 [type] => 50
> 18 [data] => Array
> 19 (
> 20 [addr] => ::1
> 21 [ifindex] => 1
> 22 )
> 23 )
> 24 )
> ...
> =======
> This is output by c
> function:"socket_recvmsg"(/home/work/php/php/ext/sockets/sendrecvmsg.c:214),

You can find the implementation of socket_recvmsg() in the ext/sockets
directory here:
http://git.php.net/?p=php-src.git;a=blob;f=ext/sockets/sendrecvmsg.c;h=7b9c4e8ad357b73b514dc5feb8dc8d9ca215126b;hb=HEAD#l210



--
regards,

Kalle Sommer Nielsen
kalle@php.net

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sam Ding
Re: [PHP-DEV] return values of socket_recvmsg
January 26, 2018 03:40PM
Thank Kalle,

I knew the implementaion of socket_recvmsg(), but want to know the return
data structure.
The test on Big_endian (s390x) got a little different return result than on
x86_64, try to dig out
where the problem is.

Thanks,

Sam


kalle.php@gmail.com wrote on 01/26/2018 01:58:23 AM:

> From: Kalle Sommer Nielsen <[email protected]>
> To: Sam Ding <[email protected]>
> Cc: PHP internals <[email protected]>
> Date: 01/26/2018 01:58 AM
> Subject: Re: [PHP-DEV] return values of socket_recvmsg
> Sent by: kalle.php@gmail.com
>
> Hi Sam
>
> 2018-01-25 23:11 GMT+01:00 Sam Ding <[email protected]>:
> >
> > The test case ext/sockets/tests/socket_recvmsg.php has following
output
> > on x86_64:
> >
> > =======
> > ...
> > 1 Array
> > 2 (
> > 3 [name] => Array
> > 4 (
> > 5 [family] => 10
> > 6 [addr] => ::1
> > 7 [port] => 7001
> > 8 [flowinfo] => 0
> > 9 [scope_id] => 0
> > 10 )
> > 11
> > 12 [control] => Array
> > 13 (
> > 14 [0] => Array
> > 15 (
> > 16 [level] => 41
> > 17 [type] => 50
> > 18 [data] => Array
> > 19 (
> > 20 [addr] => ::1
> > 21 [ifindex] => 1
> > 22 )
> > 23 )
> > 24 )
> > ...
> > =======
> > This is output by c
> >
function:"socket_recvmsg"(/home/work/php/php/ext/sockets/sendrecvmsg.c:214),

>
> You can find the implementation of socket_recvmsg() in the ext/sockets
> directory here:
> https://urldefense.proofpoint.com/v2/url?
>
u=http-3A__git.php.net_-3Fp-3Dphp-2Dsrc.git-3Ba-3Dblob-3Bf-3Dext_sockets_sendrecvmsg.c-3Bh-3D7b9c4e8ad357b73b514dc5feb8dc8d9ca215126b-3Bhb-3DHEAD-23l210&d=DwIBaQ&c=jf_iaSHvJObTbx-

> siA1ZOg&r=CBZ1IFMUPf-s4Wt-
>
elABGKFWisr3DNfFfWYNaKkXXUE&m=f8KTE9WyceLmQxKXG77FBkDIVqCnJ54BBnXEQuSQCo4&s=GOFChuk86IBBBORDL3I50gHrzmF4kTmYkq1qCeMufBQ&e=

>
>
>
> --
> regards,
>
> Kalle Sommer Nielsen
> kalle@php.net
>
Sam Ding
Re: [PHP-DEV] return values of socket_recvmsg
January 26, 2018 08:40PM
The return data in PHP is "$data" which is an array with 4 elements,
does it match to "zmsg" inside of c function
"socket_recvmsg"(/home/work/php/php/ext/sockets/sendrecvmsg.c:214)?

Here zmsg is struct with:

(gdb) ptype zmsg
type = struct _zval_struct {
zend_value value;
union {
struct {...} v;
uint32_t type_info;
} u1;
union {
uint32_t next;
uint32_t cache_slot;
uint32_t lineno;
uint32_t num_args;
uint32_t fe_pos;
uint32_t fe_iter_idx;
uint32_t access_flags;
uint32_t property_guard;
uint32_t extra;
} u2;
} *

How do these two variables match between php and C?

Thanks,

Sam

Sam Ding/Toronto/IBM wrote on 01/26/2018 09:36:00 AM:

> From: Sam Ding/Toronto/IBM
> To: Kalle Sommer Nielsen <[email protected]>
> Cc: PHP internals <[email protected]>, kalle.php@gmail.com
> Date: 01/26/2018 09:36 AM
> Subject: Re: [PHP-DEV] return values of socket_recvmsg
>
> Thank Kalle,
>
> I knew the implementaion of socket_recvmsg(), but want to know the
> return data structure.
> The test on Big_endian (s390x) got a little different return result
> than on x86_64, try to dig out
> where the problem is.
>
> Thanks,
>
> Sam
>
>
> kalle.php@gmail.com wrote on 01/26/2018 01:58:23 AM:
>
> > From: Kalle Sommer Nielsen <[email protected]>
> > To: Sam Ding <[email protected]>
> > Cc: PHP internals <[email protected]>
> > Date: 01/26/2018 01:58 AM
> > Subject: Re: [PHP-DEV] return values of socket_recvmsg
> > Sent by: kalle.php@gmail.com
> >
> > Hi Sam
> >
> > 2018-01-25 23:11 GMT+01:00 Sam Ding <[email protected]>:
> > >
> > > The test case ext/sockets/tests/socket_recvmsg.php has following
output
> > > on x86_64:
> > >
> > > =======
> > > ...
> > > 1 Array
> > > 2 (
> > > 3 [name] => Array
> > > 4 (
> > > 5 [family] => 10
> > > 6 [addr] => ::1
> > > 7 [port] => 7001
> > > 8 [flowinfo] => 0
> > > 9 [scope_id] => 0
> > > 10 )
> > > 11
> > > 12 [control] => Array
> > > 13 (
> > > 14 [0] => Array
> > > 15 (
> > > 16 [level] => 41
> > > 17 [type] => 50
> > > 18 [data] => Array
> > > 19 (
> > > 20 [addr] => ::1
> > > 21 [ifindex] => 1
> > > 22 )
> > > 23 )
> > > 24 )
> > > ...
> > > =======
> > > This is output by c
> > > function:"socket_recvmsg"(/home/work/php/php/ext/sockets/
> sendrecvmsg.c:214),
> >
> > You can find the implementation of socket_recvmsg() in the ext/sockets
> > directory here:
> > https://urldefense.proofpoint.com/v2/url?
> >
>
u=http-3A__git.php.net_-3Fp-3Dphp-2Dsrc.git-3Ba-3Dblob-3Bf-3Dext_sockets_sendrecvmsg.c-3Bh-3D7b9c4e8ad357b73b514dc5feb8dc8d9ca215126b-3Bhb-3DHEAD-23l210&d=DwIBaQ&c=jf_iaSHvJObTbx-

> > siA1ZOg&r=CBZ1IFMUPf-s4Wt-
> >
>
elABGKFWisr3DNfFfWYNaKkXXUE&m=f8KTE9WyceLmQxKXG77FBkDIVqCnJ54BBnXEQuSQCo4&s=GOFChuk86IBBBORDL3I50gHrzmF4kTmYkq1qCeMufBQ&e=

> >
> >
> >
> > --
> > regards,
> >
> > Kalle Sommer Nielsen
> > kalle@php.net
> >
Sorry, only registered users may post in this forum.

Click here to login