read string from server array error!
fang zhengshu
fangzhsh07 at gmail.com
Fri Jul 10 05:59:50 CEST 2009
2009/7/10 fang zhengshu <fangzhsh07 at gmail.com>
>
>
> 2009/7/8 fang zhengshu <fangzhsh07 at gmail.com>
>
>>
>>
>> 2009/7/6 fang zhengshu <fangzhsh07 at gmail.com>
>>
>>> hi all,
>>> when I write a function in the IDL file, there is a problem:want to write
>>> a different-length string to a array and then read parts of the array to
>>> another string like:
>>>
>>> interface test{
>>> int write([string]char* str, int len);
>>> int read([out,prealloc_client, size_is(size),
>>> prealloc_server]char str[], int size);
>>> };
>>>
>> I modify the idl file as the following:
> int write([in,string]char *str, int len)
> int read([out, prealloc_client]char *str, int len)
> there no error when compile it,but
>
>>
>>> I have defined a fixed size array in the server like array[256].
>>> In the write() function I write a different length string to the array,
>>> then I want to read parts or all of the array in the read() function, the
>>> process will be like the following:
>>>
>>> string[len] str[size]
>>> | ^
>>> | |
>>> --------->array[256] -----------|
>>>
>>>
>>> but when I put the function above and compile it, there are some error
>>> happen. I have change the size_is() with length_is() or max_is(), but there
>>> still error when I compile it. I know if I define a fix array str[256] the
>>> code can be work, but I just want to use a unfixed length array to get the
>>> string.
>>> could someone please give me some advice?if I describe the problem
>>> clearly, please let me know.
>>>
>>> thank you!
>>>
>>> I don't know whether I describe what I want to do clearly,so I put the
>> simple code below:
>>
>> read-client
>> write-client
>> #define STR_TO 30
>> #define STR_FROM 30
>> ...
>> ...
>> char str_to[SRR_TO];
>> char str_from[STR_FROM];
>> ...
>> ...
>> read(str_to, STR_TO);
>> write(str_from, STR_FROM);
>> ...
>> ...
>>
>> server
>> #define SIZE 256
>> ...
>> char string[SIZE];
>> ...
>> int write(char
>> *str_from, int str_from)
>> {
>> //write str_from size chars of str_from array to the
>> string array which is in server
>> }
>> int read(char *str_to,
>> int str_to)
>> {
>> //read str_to size chars from the string array which is in
>> server to str_to
>> }
>>
>> Then I define write functions as the above in a .idl file,but when I
>> compile it,there will be the following error:
>> terminate called after throwing an instance of 'std::out_of_range'
>> what(): CBEMsgBuffer::IsEarlier
>> make[1]: *** [test-server.c] Aborted
>> make[1]: *** [test-server.c] Deleting file `test-sys.h'
>> make[1]: *** [test-server.c] Deleting file `test-client.h'
>> make[1]: *** [test-server.c] Deleting file `test-client.c'
>> make: *** [/home/l4/tudos/build/pkg/
>> fifo/idl/OBJ-x86-l4v2] Error 2
>>
>> must we use the format as the dice manual below?:
>> int read([out, prealloc_client, size_is(len)] char **str, [out,in]int
>> *len)
>> and when I modify the function as
>> int read([out, prealloc_client, prealloc_server, size_is(len)] char *str,
>> [out,in]int *len)
>> there is no error when compile it,but there will be another error called
>> :fpage
>> could you give me some advice for the read function?
>> thank you.
>> --
>> fang,
>>
> when I run the test in qemu, the error come out:
> fifo | L4RM: [PF] read at 0x00002000, ip 01800aa1, src B.02
> fifo | [B.0] l4rm/lib/src/pagefault.c:81:__unknown_pf():
> fifo | unhandled page fault
>
> the execute code of fifo binary is :
> ...
> /home/l4/tudos/build/pkg/fifo/idl/OBJ-x86-l4v2/fifo-server.c:259
> l4_msgdope_t _dice_size_dope;
> l4_msgdope_t _dice_send_dope;
> l4_umword_t _word[2];
> } _word;
> } fifo_fifo_read_msg_buffer_t;
> l4_umword_t _dice_str_size = (str) ? (_dice_strlen(str)+1) : 0;
> 1800a8b: 85 db test %ebx,%ebx
> 1800a8d: 0f 84 f9 00 00 00 je 1800b8c <fifo_dispatch+0x21c>
> 1800a93: 80 3b 00 cmpb $0x0,(%ebx)
> 1800a96: 0f 84 11 01 00 00 je 1800bad <fifo_dispatch+0x23d>
> 1800a9c: 31 c0 xor %eax,%eax
> 1800a9e: 66 90 xchg %ax,%ax
> 1800aa0: 40 inc %eax
> 1800aa1: 80 3c 18 00 cmpb $0x0,(%eax,%ebx,1)
> 1800aa5: 75 f9 jne 1800aa0 <fifo_dispatch+0x130>
> 1800aa7: 8d 58 01 lea 0x1(%eax),%ebx
> ...
>
> the fifo-server.c:259 code is:
>
> inline
> void
> fifo_read_marshal (CORBA_Object _dice_corba_obj,
> int _dice_return /* out */,
> l4_msgtag_t *_dice_tag,
> char* str /* out */,
> fifo_msg_buffer_t *_dice_msg_buffer,
> CORBA_Server_Environment *_dice_corba_env)
> {
>
> ...
> l4_umword_t _dice_str_size = (str) ? (_dice_strlen(str)+1) : 0;
> ...
>
>
> so anyone can give me some advice?
>
> thank you!
> --
> fang,
>
thank you for people's help:)
I have handle the problem that can't read data from server.
I modify the read function in the idl file:
int read([in, out, size_is(len), max_is(256)] char str[], [in, out]
int *len);
and in the client-read side, malloc a array with 256
size(malloc(sizeof(char)*256)]),then there is no error in the read_component
function and I can read the data from the server side which define a static
array.
--
fang,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://os.inf.tu-dresden.de/pipermail/l4-hackers/attachments/20090710/fef88942/attachment.htm>
More information about the l4-hackers
mailing list