Re: GSoC Project | Basic Support for Trace Compass

2019-06-28 Thread Sebastian Huber

On 27/06/2019 19:18, Ravindra Kumar Meena wrote:

 > Okay. Raw file contents have this structure. It means raw file
will only
 > contain event and data in binary format. How should I get it's
 > corresponding ns and cpu values.

1. Instead of the socket() and connect() you open the file
descriptor with open().

2. Instead of using recv() to read from the file descriptor you use
read().  See below.


Wow!!. The file descriptor is a very nice concept. I learned about it 
during my 3rd year of graduation but I never thought I would ever apply 
it :)


https://www.geeksforgeeks.org/input-output-system-calls-c-create-open-close-read-write/

The 2nd task is complete. Have made a push on my GitHub rtems-tools 
workplace

https://github.com/rmeena840/rtems-tools/commit/362a6fc94886f298d207021ce5f2dad48783c0da

Have a look

I tried the command on my machine it's working fine with the raw data 
created today. The babeltrace is able to print all values.


I used "./build/misc/rtems-record --input raw_data | head" command 
generating ctf events from raw data


As I said a couple of time before. Please fix the compiler warnings:

../misc/record/record-main.c:57:23: warning: character constant too long 
for its type

   { "input", 1, NULL, 'input' },
   ^~~
../misc/record/record-main.c: In function ‘main’:
../misc/record/record-main.c:308:12: warning: character constant too 
long for its type

   case 'input':
^~~

I am a bit surprised that this code compiles at all.

There is a bug (from me) in the while loop.

 ssize_t n;

 n = ( input_file_flag ) ? read(fd, buf, 10) : recv( fd, buf, 
sizeof( buf ), 0 );

-if ( n >= 0 ) {
+if ( n > 0 ) {
   rtems_record_client_run( &ctx, buf, (size_t) n );
 } else {
   break;

Could you please give me permission to push to your repository. I would 
like to add a record item stream from a QorIQ T4240.


lttng seems to create one event stream file per processor. This is your 
next task.


1. Open a event stream file for each processor.

2. Write the events of a processor (CPU) to the corresponding file.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] score: Add and use _Thread_Get_unmapped_priority().

2019-06-28 Thread Chris Johns
On 28/6/19 4:32 pm, Sebastian Huber wrote:
> Add and use _Thread_Get_unmapped_real_priority().

+1

Thanks.
Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Attempt to get rid of -qrtems

2019-06-28 Thread Sebastian Huber

On 28/06/2019 01:37, Chris Johns wrote:

On 27/6/19 10:08 pm, Sebastian Huber wrote:

I would like to get rid of the -qrtems command for normal RTEMS applications.

I do not think you can remove -qrtems as it will break all existing configure
scripts. The default needs to be stubs.


Ok, this was just some side-effect of an attempt to get rid of the 
bsp_specs. What about the attached patch.


You can add startfiles via the linker command file. Is it possible to 
add also endfiles? I didn't find anything in the GNU ld documentation 
about this.



--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>From b17b2b3532277c2c4a5efce74ff842524fb1f383 Mon Sep 17 00:00:00 2001
From: Sebastian Huber 
Date: Fri, 28 Jun 2019 09:56:22 +0200
Subject: [PATCH] RTEMS: Use stub crt0.o only if not -qrtems

---
 gcc/config/rtems.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/rtems.h b/gcc/config/rtems.h
index 71ae2fd3575..6c4fbd7946c 100644
--- a/gcc/config/rtems.h
+++ b/gcc/config/rtems.h
@@ -27,7 +27,7 @@
  * needed by autoconf scripts using this compiler.
  */
 #undef STARTFILE_SPEC
-#define STARTFILE_SPEC "crt0.o%s"
+#define STARTFILE_SPEC "%{!qrtems: crt0.o}%s"
 
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC   ""
-- 
2.16.4

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: GSoC Project | Basic Support for Trace Compass

2019-06-28 Thread Ravindra Kumar Meena
>
> As I said a couple of time before. Please fix the compiler warnings:
>
> ../misc/record/record-main.c:57:23: warning: character constant too long
> for its type
> { "input", 1, NULL, 'input' },
> ^~~
> ../misc/record/record-main.c: In function ‘main’:
> ../misc/record/record-main.c:308:12: warning: character constant too
> long for its type
> case 'input':
>  ^~~
>
> I am a bit surprised that this code compiles at all.
>
> There is a bug (from me) in the while loop.
>
>   ssize_t n;
>
>   n = ( input_file_flag ) ? read(fd, buf, 10) : recv( fd, buf,
> sizeof( buf ), 0 );
> -if ( n >= 0 ) {
> +if ( n > 0 ) {
> rtems_record_client_run( &ctx, buf, (size_t) n );
>   } else {
> break;
>
Okay. Made some changes
https://github.com/rmeena840/rtems-tools/commit/e454fec2ba42cc51bc85a53af2990645be162d77


>
> Could you please give me permission to push to your repository. I would
> like to add a record item stream from a QorIQ T4240.
>
Did you get the invite? My GitHub handle is rmeena840.

>
> lttng seems to create one event stream file per processor. This is your
> next task.
>
> 1. Open a event stream file for each processor.
>
The stream file which has ctf event element?

>
> 2. Write the events of a processor (CPU) to the corresponding file.
>
Sorry, I didn't get this task?



-- 
*Ravindra Kumar Meena*,
B. Tech. Computer Science and Engineering,
Indian Institute of Technology (Indian School of Mines)
, Dhanbad
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH] Record-client program to read from a file for --input= flag

2019-06-28 Thread Ravindra Meena
---
 misc/record/record-main.c | 35 ---
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/misc/record/record-main.c b/misc/record/record-main.c
index b4591e3..14023e2 100644
--- a/misc/record/record-main.c
+++ b/misc/record/record-main.c
@@ -39,6 +39,8 @@
 #include 
 #include 
 #include 
+#include 
+#include
 
 #include 
 #include 
@@ -52,6 +54,7 @@ static const struct option longopts[] = {
   { "host", 1, NULL, 'H' },
   { "port", 1, NULL, 'p' },
   { "items", 1, NULL, 'i' },
+  { "input", 1, NULL, 'f' },
   { NULL, 0, NULL, 0 }
 };
 
@@ -111,32 +114,35 @@ RB_GENERATE_INTERNAL( active, client_item, active_node, 
item_cmp, static inline
 static void usage( char **argv )
 {
   printf(
-"%s [--host=HOST] [--port=PORT] [--items=ITEMS]\n"
+"%s [--host=HOST] [--port=PORT] [--items=ITEMS] [--input=INPUT]\n"
 "\n"
 "Mandatory arguments to long options are mandatory for short options 
too.\n"
-"  -h, --help print this help text\n"
-"  -H, --host=HOSTthe host IPv4 address of the record server\n"
-"  -p, --port=PORTthe TCP port of the record server\n"
-"  -i, --items=ITEMS  the maximum count of active record items\n",
+"  -h,  --help print this help text\n"
+"  -H,  --host=HOSTthe host IPv4 address of the record 
server\n"
+"  -p,  --port=PORTthe TCP port of the record server\n"
+"  -i,  --items=ITEMS  the maximum count of active record items\n"
+"  -input,  --input=INPUT  the file input\n",
 argv[ 0 ]
   );
 }
 
-static int connect_client( const char *host, uint16_t port )
+static int connect_client( const char *host, uint16_t port, const char 
*input_file  ,bool input_file_flag )
 {
   struct sockaddr_in in_addr;
   int fd;
   int rv;
 
-  fd = socket( PF_INET, SOCK_STREAM, 0 );
+  fd = ( input_file_flag ) ? open( input_file, O_RDONLY ) : socket( PF_INET, 
SOCK_STREAM, 0 );
   assert( fd >= 0 );
 
   memset( &in_addr, 0, sizeof( in_addr ) );
   in_addr.sin_family = AF_INET;
   in_addr.sin_port = htons( port );
   in_addr.sin_addr.s_addr = inet_addr( host );
+  if( !input_file_flag ){
   rv = connect( fd, (struct sockaddr *) &in_addr, sizeof( in_addr ) );
   assert( rv == 0 );
+  }
 
   return fd;
 }
@@ -268,6 +274,8 @@ int main( int argc, char **argv )
   client_item *items;
   const char *host;
   uint16_t port;
+  const char *input_file;
+  bool input_file_flag = false;
   int fd;
   int rv;
   int opt;
@@ -280,7 +288,7 @@ int main( int argc, char **argv )
   n = RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT * 1024 * 1024;
 
   while (
-( opt = getopt_long( argc, argv, "hH:p:i:", &longopts[0], &longindex ) )
+( opt = getopt_long( argc, argv, "hH:p:i:f", &longopts[0], &longindex ) )
   != -1
   ) {
 switch ( opt ) {
@@ -297,6 +305,11 @@ int main( int argc, char **argv )
   case 'i':
 n = (size_t) strtoul( optarg, NULL, 10 );
 break;
+  case 'f':
+input_file = optarg;
+assert( input_file != NULL );
+input_file_flag = true;
+break;
   default:
 exit( EXIT_FAILURE );
 break;
@@ -320,15 +333,15 @@ int main( int argc, char **argv )
 SLIST_INSERT_HEAD( &cctx.free_items, &items[ i ], free_node );
   }
 
-  fd = connect_client( host, port );
+  fd = connect_client( host, port , input_file, input_file_flag );
   rtems_record_client_init( &ctx, handler, &cctx );
 
   while ( true ) {
 int buf[ 8192 ];
 ssize_t n;
 
-n = recv( fd, buf, sizeof( buf ), 0 );
-if ( n >= 0 ) {
+n = ( input_file_flag ) ? read(fd, buf, 10) : recv( fd, buf, sizeof( buf 
), 0 );
+if ( n > 0 ) {
   rtems_record_client_run( &ctx, buf, (size_t) n );
 } else {
   break;
-- 
2.7.4

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: GSoC Project | Basic Support for Trace Compass

2019-06-28 Thread Sebastian Huber



On 28/06/2019 12:12, Ravindra Kumar Meena wrote:
[...]




Could you please give me permission to push to your repository. I would
like to add a record item stream from a QorIQ T4240.

Did you get the invite? My GitHub handle is rmeena840.


Thanks, this worked. I pushed two commits.




lttng seems to create one event stream file per processor. This is your
next task.

1. Open a event stream file for each processor.

The stream file which has ctf event element?


2. Write the events of a processor (CPU) to the corresponding file.

Sorry, I didn't get this task?


Currently you write the events of all cpus into a single event stream file:

typedef struct ctf_event {
  uint64_t ns;
  uint32_t cpu;
  rtems_record_event   event;
  uint64_t data;
} ctf_event;

static void print_item( FILE *f, const client_item *item )
{
  ctf_event ctf_item;

  ctf_item.ns = item->ns;
  ctf_item.cpu= item->cpu;
  ctf_item.event = item->event;
  ctf_item.data = item->data;

  fwrite( &ctf_item, sizeof( ctf_item ), 1, f );
}

Change this to write the items into separate event stream files per cpu, 
e.g.


typedef struct ctf_event {
  uint64_t ns;
  rtems_record_event   event;
  uint64_t data;
} ctf_event;

static void print_item( FILE **f, const client_item *item )
{
  ctf_event ctf_item;

  ctf_item.ns = item->ns;
  ctf_item.event = item->event;
  ctf_item.data = item->data;

  fwrite( &ctf_item, sizeof( ctf_item ), 1, f[ item->cpu ] );
}

Your event stream needs a packet header which indicates the cpu.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Coverity Scan Configuration?

2019-06-28 Thread Sebastian Huber

On 27/06/2019 23:31, Gedare Bloom wrote:
I have an interest and plan to work on this area soon. I made myself a 
note to look into the options, and whether any of the rules can be used 
out of the box for open source in https://devel.rtems.org/ticket/3710


Ok, so currently nobody knows which rules are configured and if they can 
be changed. Maybe we should ask this on Stack Overflow.


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Error: undefined reference to ndbm functions

2019-06-28 Thread Vaibhav Gupta
Hello,
.
Status:

   1. I have ported ndbm in newlib. When compiled newlib-cygwin, function
   symbols were generated. Created patch.
   2. Applied the patch to RSB and rebuild toolchain. Generated ndbm.h in
   5/sparc-rtems5/include directory.

Blocker:

   1. I made a raw program which calls dbm_open, dbm_close, dbm_store,
   dbm_fetch.
   2. When  I run 'make -j 2', in erc32 directory, it shows undefined
   reference to those functions.

https://github.com/VARoDeK/rtems/compare/test_ndbm_presence_02
.
home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
psxinttypes01/psxinttypes01-init.o: in function `Init':
/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:231:
undefined reference to `dbm_open'
/home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:232:
undefined reference to `dbm_store'
/home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:236:
undefined reference to `dbm_fetch'
/home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
/home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:239:
undefined reference to `dbm_close'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:7679: psxinttypes01.exe] Error 1
make[5]: Leaving directory
'/home/varodek/development/rtems/kernel/erc32/sparc-rtems5/c/erc32/testsuites/psxtests'
make[4]: *** [Makefile:663: psxtests] Error 2
make[4]: *** Waiting for unfinished jobs
.
.
.
Maybe I have compiled it incorrectly, please verify.

   1. ndbm port: https://github.com/VARoDeK/newlib/compare/port_ndbm
   2. RSB patch:
   https://github.com/VARoDeK/rsb/compare/newlib_ndbm_rsb_patch_01

Vaibhav Gupta
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Error: undefined reference to ndbm functions

2019-06-28 Thread Joel Sherrill
You need to add the library to the gcc command that links the program. If
the libndbm is in the library search path, add -lndbm.

I don't recall the exact Makefile variable to set for this to show up. Look
at the paranoia sample. It should be doing this with -lm.

--joel

On Fri, Jun 28, 2019, 8:12 AM Vaibhav Gupta 
wrote:

> Hello,
> .
> Status:
>
>1. I have ported ndbm in newlib. When compiled newlib-cygwin, function
>symbols were generated. Created patch.
>2. Applied the patch to RSB and rebuild toolchain. Generated ndbm.h in
>5/sparc-rtems5/include directory.
>
> Blocker:
>
>1. I made a raw program which calls dbm_open, dbm_close, dbm_store,
>dbm_fetch.
>2. When  I run 'make -j 2', in erc32 directory, it shows undefined
>reference to those functions.
>
> https://github.com/VARoDeK/rtems/compare/test_ndbm_presence_02
> .
> home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
> psxinttypes01/psxinttypes01-init.o: in function `Init':
> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:231:
> undefined reference to `dbm_open'
> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:232:
> undefined reference to `dbm_store'
> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:236:
> undefined reference to `dbm_fetch'
> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:239:
> undefined reference to `dbm_close'
> collect2: error: ld returned 1 exit status
> make[5]: *** [Makefile:7679: psxinttypes01.exe] Error 1
> make[5]: Leaving directory
> '/home/varodek/development/rtems/kernel/erc32/sparc-rtems5/c/erc32/testsuites/psxtests'
> make[4]: *** [Makefile:663: psxtests] Error 2
> make[4]: *** Waiting for unfinished jobs
> .
> .
> .
> Maybe I have compiled it incorrectly, please verify.
>
>1. ndbm port: https://github.com/VARoDeK/newlib/compare/port_ndbm
>2. RSB patch:
>https://github.com/VARoDeK/rsb/compare/newlib_ndbm_rsb_patch_01
>
> Vaibhav Gupta
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Error: undefined reference to ndbm functions

2019-06-28 Thread Vaibhav Gupta
On Fri, Jun 28, 2019, 5:57 PM Joel Sherrill  wrote:

> You need to add the library to the gcc command that links the program. If
> the libndbm is in the library search path, add -lndbm.
>
> I don't recall the exact Makefile variable to set for this to show up.
> Look at the paranoia sample. It should be doing this with -lm.
>
> --joel
>
Okay, I will try this!

>
> On Fri, Jun 28, 2019, 8:12 AM Vaibhav Gupta 
> wrote:
>
>> Hello,
>> .
>> Status:
>>
>>1. I have ported ndbm in newlib. When compiled newlib-cygwin,
>>function symbols were generated. Created patch.
>>2. Applied the patch to RSB and rebuild toolchain. Generated ndbm.h
>>in 5/sparc-rtems5/include directory.
>>
>> Blocker:
>>
>>1. I made a raw program which calls dbm_open, dbm_close, dbm_store,
>>dbm_fetch.
>>2. When  I run 'make -j 2', in erc32 directory, it shows undefined
>>reference to those functions.
>>
>> https://github.com/VARoDeK/rtems/compare/test_ndbm_presence_02
>> .
>> home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>> psxinttypes01/psxinttypes01-init.o: in function `Init':
>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:231:
>> undefined reference to `dbm_open'
>> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:232:
>> undefined reference to `dbm_store'
>> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:236:
>> undefined reference to `dbm_fetch'
>> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:239:
>> undefined reference to `dbm_close'
>> collect2: error: ld returned 1 exit status
>> make[5]: *** [Makefile:7679: psxinttypes01.exe] Error 1
>> make[5]: Leaving directory
>> '/home/varodek/development/rtems/kernel/erc32/sparc-rtems5/c/erc32/testsuites/psxtests'
>> make[4]: *** [Makefile:663: psxtests] Error 2
>> make[4]: *** Waiting for unfinished jobs
>> .
>> .
>> .
>> Maybe I have compiled it incorrectly, please verify.
>>
>>1. ndbm port: https://github.com/VARoDeK/newlib/compare/port_ndbm
>>2. RSB patch:
>>https://github.com/VARoDeK/rsb/compare/newlib_ndbm_rsb_patch_01
>>
>> Vaibhav Gupta
>>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Error: undefined reference to ndbm functions

2019-06-28 Thread Joel Sherrill
On Fri, Jun 28, 2019, 8:40 AM Vaibhav Gupta 
wrote:

>
>
> On Fri, Jun 28, 2019, 5:57 PM Joel Sherrill  wrote:
>
>> You need to add the library to the gcc command that links the program. If
>> the libndbm is in the library search path, add -lndbm.
>>
>> I don't recall the exact Makefile variable to set for this to show up.
>> Look at the paranoia sample. It should be doing this with -lm.
>>
>> --joel
>>
> Okay, I will try this!
>

The following web page is a pretty good description of building a library
using a native GCC and linking it into a program. It includes some of the
theory going on so this might help you.

https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html

Guys.. this comes up periodically, even though this is really basic tool
usage to me, is this something we should provide some guidance on?

--joel

>
>> On Fri, Jun 28, 2019, 8:12 AM Vaibhav Gupta 
>> wrote:
>>
>>> Hello,
>>> .
>>> Status:
>>>
>>>1. I have ported ndbm in newlib. When compiled newlib-cygwin,
>>>function symbols were generated. Created patch.
>>>2. Applied the patch to RSB and rebuild toolchain. Generated ndbm.h
>>>in 5/sparc-rtems5/include directory.
>>>
>>> Blocker:
>>>
>>>1. I made a raw program which calls dbm_open, dbm_close, dbm_store,
>>>dbm_fetch.
>>>2. When  I run 'make -j 2', in erc32 directory, it shows undefined
>>>reference to those functions.
>>>
>>> https://github.com/VARoDeK/rtems/compare/test_ndbm_presence_02
>>> .
>>> home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>>> psxinttypes01/psxinttypes01-init.o: in function `Init':
>>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:231:
>>> undefined reference to `dbm_open'
>>> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:232:
>>> undefined reference to `dbm_store'
>>> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:236:
>>> undefined reference to `dbm_fetch'
>>> /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
>>> /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:239:
>>> undefined reference to `dbm_close'
>>> collect2: error: ld returned 1 exit status
>>> make[5]: *** [Makefile:7679: psxinttypes01.exe] Error 1
>>> make[5]: Leaving directory
>>> '/home/varodek/development/rtems/kernel/erc32/sparc-rtems5/c/erc32/testsuites/psxtests'
>>> make[4]: *** [Makefile:663: psxtests] Error 2
>>> make[4]: *** Waiting for unfinished jobs
>>> .
>>> .
>>> .
>>> Maybe I have compiled it incorrectly, please verify.
>>>
>>>1. ndbm port: https://github.com/VARoDeK/newlib/compare/port_ndbm
>>>2. RSB patch:
>>>https://github.com/VARoDeK/rsb/compare/newlib_ndbm_rsb_patch_01
>>>
>>> Vaibhav Gupta
>>>
>>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Error: undefined reference to ndbm functions

2019-06-28 Thread Vaibhav Gupta
On Fri, Jun 28, 2019, 6:19 PM Joel Sherrill  wrote:

>
>
> On Fri, Jun 28, 2019, 8:40 AM Vaibhav Gupta 
> wrote:
>
>>
>>
>> On Fri, Jun 28, 2019, 5:57 PM Joel Sherrill  wrote:
>>
>>> You need to add the library to the gcc command that links the program.
>>> If the libndbm is in the library search path, add -lndbm.
>>>
>>> I don't recall the exact Makefile variable to set for this to show up.
>>> Look at the paranoia sample. It should be doing this with -lm.
>>>
>>> --joel
>>>
>> Okay, I will try this!
>>
>
> The following web page is a pretty good description of building a library
> using a native GCC and linking it into a program. It includes some of the
> theory going on so this might help you.
>
> https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html
>
> Guys.. this comes up periodically, even though this is really basic tool
> usage to me, is this something we should provide some guidance on?
>
Actually, i tried this before, but I cannot find libndbm in my development
directory. I guess it is not generated.
.
One thing I can do is, the newlib-cygwin i compiled while porting ndbm, it
generated ndbm library. I can use that.

>
> --joel
>
>>
>>> On Fri, Jun 28, 2019, 8:12 AM Vaibhav Gupta 
>>> wrote:
>>>
 Hello,
 .
 Status:

1. I have ported ndbm in newlib. When compiled newlib-cygwin,
function symbols were generated. Created patch.
2. Applied the patch to RSB and rebuild toolchain. Generated ndbm.h
in 5/sparc-rtems5/include directory.

 Blocker:

1. I made a raw program which calls dbm_open, dbm_close, dbm_store,
dbm_fetch.
2. When  I run 'make -j 2', in erc32 directory, it shows undefined
reference to those functions.

 https://github.com/VARoDeK/rtems/compare/test_ndbm_presence_02
 .
 home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
 psxinttypes01/psxinttypes01-init.o: in function `Init':
 /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:231:
 undefined reference to `dbm_open'
 /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
 /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:232:
 undefined reference to `dbm_store'
 /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
 /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:236:
 undefined reference to `dbm_fetch'
 /home/varodek/development/rtems/5/lib/gcc/sparc-rtems5/7.4.1/../../../../sparc-rtems5/bin/ld:
 /home/varodek/development/rtems/kernel/rtems/c/src/../../testsuites/psxtests/psxinttypes01/init.c:239:
 undefined reference to `dbm_close'
 collect2: error: ld returned 1 exit status
 make[5]: *** [Makefile:7679: psxinttypes01.exe] Error 1
 make[5]: Leaving directory
 '/home/varodek/development/rtems/kernel/erc32/sparc-rtems5/c/erc32/testsuites/psxtests'
 make[4]: *** [Makefile:663: psxtests] Error 2
 make[4]: *** Waiting for unfinished jobs
 .
 .
 .
 Maybe I have compiled it incorrectly, please verify.

1. ndbm port: https://github.com/VARoDeK/newlib/compare/port_ndbm
2. RSB patch:
https://github.com/VARoDeK/rsb/compare/newlib_ndbm_rsb_patch_01

 Vaibhav Gupta

>>>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] Record-client program to read from a file for --input= flag

2019-06-28 Thread Gedare Bloom
On Fri, Jun 28, 2019 at 5:02 AM Ravindra Meena  wrote:
>
> ---
>  misc/record/record-main.c | 35 ---
>  1 file changed, 24 insertions(+), 11 deletions(-)
>
> diff --git a/misc/record/record-main.c b/misc/record/record-main.c
> index b4591e3..14023e2 100644
> --- a/misc/record/record-main.c
> +++ b/misc/record/record-main.c
> @@ -39,6 +39,8 @@
>  #include 
>  #include 
>  #include 
> +#include
> +#include
>
add space before <

when writing code, aim to be consistent with surrounding code, and
with coding style rules

>  #include 
>  #include 
> @@ -52,6 +54,7 @@ static const struct option longopts[] = {
>{ "host", 1, NULL, 'H' },
>{ "port", 1, NULL, 'p' },
>{ "items", 1, NULL, 'i' },
> +  { "input", 1, NULL, 'f' },

I know you were asked to add --input, however, since 'i' is already
used, it might be sensible to use --file= and 'f'?

>{ NULL, 0, NULL, 0 }
>  };
>
> @@ -111,32 +114,35 @@ RB_GENERATE_INTERNAL( active, client_item, active_node, 
> item_cmp, static inline
>  static void usage( char **argv )
>  {
>printf(
> -"%s [--host=HOST] [--port=PORT] [--items=ITEMS]\n"
> +"%s [--host=HOST] [--port=PORT] [--items=ITEMS] [--input=INPUT]\n"
>  "\n"
>  "Mandatory arguments to long options are mandatory for short options 
> too.\n"
> -"  -h, --help print this help text\n"
> -"  -H, --host=HOSTthe host IPv4 address of the record 
> server\n"
> -"  -p, --port=PORTthe TCP port of the record server\n"
> -"  -i, --items=ITEMS  the maximum count of active record 
> items\n",
> +"  -h,  --help print this help text\n"
> +"  -H,  --host=HOSTthe host IPv4 address of the record 
> server\n"
> +"  -p,  --port=PORTthe TCP port of the record server\n"
> +"  -i,  --items=ITEMS  the maximum count of active record 
> items\n"
Why is this reformatting the existing strings?

> +"  -input,  --input=INPUT  the file input\n",
>  argv[ 0 ]
>);
>  }
>
> -static int connect_client( const char *host, uint16_t port )
> +static int connect_client( const char *host, uint16_t port, const char 
> *input_file  ,bool input_file_flag )

This is > 80 characters.
https://devel.rtems.org/wiki/Developer/Coding/Conventions#Formatting

The space should go after the comma, not before it, following
input_file parameter name.

Depending what variant C this is, bool may not be a defined type.

Regarding input_file_flag, if it is 'false', then what is the value of
'input_file'? If it is 'true', is the value of 'input_file' possibly
the same as when the flag is 'false'? If there is a distinct
difference between 'input_value', can you just check for that
difference instead of the flag?  Think about it for a bit.

I don't think it makes sense to expand this function to add the file
processing. You're trying to make this function do too much.

>  {
>struct sockaddr_in in_addr;
>int fd;
>int rv;
>
> -  fd = socket( PF_INET, SOCK_STREAM, 0 );
> +  fd = ( input_file_flag ) ? open( input_file, O_RDONLY ) : socket( PF_INET, 
> SOCK_STREAM, 0 );
This is also > 80 characters

>assert( fd >= 0 );
>
>memset( &in_addr, 0, sizeof( in_addr ) );
>in_addr.sin_family = AF_INET;
>in_addr.sin_port = htons( port );
>in_addr.sin_addr.s_addr = inet_addr( host );
> +  if( !input_file_flag ){
>rv = connect( fd, (struct sockaddr *) &in_addr, sizeof( in_addr ) );
>assert( rv == 0 );
> +  }
This code is superfluous when there is not an input file.

>
>return fd;
>  }
> @@ -268,6 +274,8 @@ int main( int argc, char **argv )
>client_item *items;
>const char *host;
>uint16_t port;
> +  const char *input_file;
> +  bool input_file_flag = false;
>int fd;
>int rv;
>int opt;
> @@ -280,7 +288,7 @@ int main( int argc, char **argv )
>n = RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT * 1024 * 1024;
>
>while (
> -( opt = getopt_long( argc, argv, "hH:p:i:", &longopts[0], &longindex ) )
> +( opt = getopt_long( argc, argv, "hH:p:i:f", &longopts[0], &longindex ) )
>!= -1
>) {
>  switch ( opt ) {
> @@ -297,6 +305,11 @@ int main( int argc, char **argv )
>case 'i':
>  n = (size_t) strtoul( optarg, NULL, 10 );
>  break;
> +  case 'f':
> +input_file = optarg;
> +assert( input_file != NULL );
> +input_file_flag = true;
another hint for you: (input_file != NULL) == input_file_flag.

> +break;
>default:
>  exit( EXIT_FAILURE );
>  break;
> @@ -320,15 +333,15 @@ int main( int argc, char **argv )
>  SLIST_INSERT_HEAD( &cctx.free_items, &items[ i ], free_node );
>}
>
> -  fd = connect_client( host, port );
> +  fd = connect_client( host, port , input_file, input_file_flag );
You should split this here, based on whether it is host/port
connection or opening a file.

>rtems_record_client_init( &ctx, handler, &cctx );
>
>

Re: [PATCH] Record-client program to read from a file for --input= flag

2019-06-28 Thread Gedare Bloom
On Fri, Jun 28, 2019 at 10:15 AM Gedare Bloom  wrote:
>
> On Fri, Jun 28, 2019 at 5:02 AM Ravindra Meena  wrote:
> >
> > ---
> >  misc/record/record-main.c | 35 ---
> >  1 file changed, 24 insertions(+), 11 deletions(-)
> >
> > diff --git a/misc/record/record-main.c b/misc/record/record-main.c
> > index b4591e3..14023e2 100644
> > --- a/misc/record/record-main.c
> > +++ b/misc/record/record-main.c
> > @@ -39,6 +39,8 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include
> > +#include
> >
> add space before <
>
> when writing code, aim to be consistent with surrounding code, and
> with coding style rules
>
> >  #include 
> >  #include 
> > @@ -52,6 +54,7 @@ static const struct option longopts[] = {
> >{ "host", 1, NULL, 'H' },
> >{ "port", 1, NULL, 'p' },
> >{ "items", 1, NULL, 'i' },
> > +  { "input", 1, NULL, 'f' },
>
> I know you were asked to add --input, however, since 'i' is already
> used, it might be sensible to use --file= and 'f'?
>
> >{ NULL, 0, NULL, 0 }
> >  };
> >
> > @@ -111,32 +114,35 @@ RB_GENERATE_INTERNAL( active, client_item, 
> > active_node, item_cmp, static inline
> >  static void usage( char **argv )
> >  {
> >printf(
> > -"%s [--host=HOST] [--port=PORT] [--items=ITEMS]\n"
> > +"%s [--host=HOST] [--port=PORT] [--items=ITEMS] [--input=INPUT]\n"
> >  "\n"
> >  "Mandatory arguments to long options are mandatory for short options 
> > too.\n"
> > -"  -h, --help print this help text\n"
> > -"  -H, --host=HOSTthe host IPv4 address of the record 
> > server\n"
> > -"  -p, --port=PORTthe TCP port of the record server\n"
> > -"  -i, --items=ITEMS  the maximum count of active record 
> > items\n",
> > +"  -h,  --help print this help text\n"
> > +"  -H,  --host=HOSTthe host IPv4 address of the record 
> > server\n"
> > +"  -p,  --port=PORTthe TCP port of the record server\n"
> > +"  -i,  --items=ITEMS  the maximum count of active record 
> > items\n"
> Why is this reformatting the existing strings?
>
> > +"  -input,  --input=INPUT  the file input\n",
> >  argv[ 0 ]
> >);
> >  }
> >
> > -static int connect_client( const char *host, uint16_t port )
> > +static int connect_client( const char *host, uint16_t port, const char 
> > *input_file  ,bool input_file_flag )
>
> This is > 80 characters.
> https://devel.rtems.org/wiki/Developer/Coding/Conventions#Formatting
>
I guess this is not RTEMS code, so you should refer to your mentor
what would be the coding standard in use.

> The space should go after the comma, not before it, following
> input_file parameter name.
>
> Depending what variant C this is, bool may not be a defined type.
>
> Regarding input_file_flag, if it is 'false', then what is the value of
> 'input_file'? If it is 'true', is the value of 'input_file' possibly
> the same as when the flag is 'false'? If there is a distinct
> difference between 'input_value', can you just check for that
> difference instead of the flag?  Think about it for a bit.
>
> I don't think it makes sense to expand this function to add the file
> processing. You're trying to make this function do too much.
>
> >  {
> >struct sockaddr_in in_addr;
> >int fd;
> >int rv;
> >
> > -  fd = socket( PF_INET, SOCK_STREAM, 0 );
> > +  fd = ( input_file_flag ) ? open( input_file, O_RDONLY ) : socket( 
> > PF_INET, SOCK_STREAM, 0 );
> This is also > 80 characters
>
> >assert( fd >= 0 );
> >
> >memset( &in_addr, 0, sizeof( in_addr ) );
> >in_addr.sin_family = AF_INET;
> >in_addr.sin_port = htons( port );
> >in_addr.sin_addr.s_addr = inet_addr( host );
> > +  if( !input_file_flag ){
> >rv = connect( fd, (struct sockaddr *) &in_addr, sizeof( in_addr ) );
> >assert( rv == 0 );
> > +  }
> This code is superfluous when there is not an input file.
>
> >
> >return fd;
> >  }
> > @@ -268,6 +274,8 @@ int main( int argc, char **argv )
> >client_item *items;
> >const char *host;
> >uint16_t port;
> > +  const char *input_file;
> > +  bool input_file_flag = false;
> >int fd;
> >int rv;
> >int opt;
> > @@ -280,7 +288,7 @@ int main( int argc, char **argv )
> >n = RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT * 1024 * 1024;
> >
> >while (
> > -( opt = getopt_long( argc, argv, "hH:p:i:", &longopts[0], &longindex ) 
> > )
> > +( opt = getopt_long( argc, argv, "hH:p:i:f", &longopts[0], &longindex 
> > ) )
> >!= -1
> >) {
> >  switch ( opt ) {
> > @@ -297,6 +305,11 @@ int main( int argc, char **argv )
> >case 'i':
> >  n = (size_t) strtoul( optarg, NULL, 10 );
> >  break;
> > +  case 'f':
> > +input_file = optarg;
> > +assert( input_file != NULL );
> > +input_file_flag = true;
> another hint for you: (input_file != NULL) == input_file_flag.
>
> > +break;
> >default:
> > 

Re: Error: undefined reference to ndbm functions

2019-06-28 Thread Gedare Bloom
On Fri, Jun 28, 2019 at 7:20 AM Vaibhav Gupta  wrote:
>
>
>
> On Fri, Jun 28, 2019, 6:19 PM Joel Sherrill  wrote:
>>
>>
>>
>> On Fri, Jun 28, 2019, 8:40 AM Vaibhav Gupta  wrote:
>>>
>>>
>>>
>>> On Fri, Jun 28, 2019, 5:57 PM Joel Sherrill  wrote:

 You need to add the library to the gcc command that links the program. If 
 the libndbm is in the library search path, add -lndbm.

 I don't recall the exact Makefile variable to set for this to show up. 
 Look at the paranoia sample. It should be doing this with -lm.

 --joel
>>>
>>> Okay, I will try this!
>>
>>
>> The following web page is a pretty good description of building a library 
>> using a native GCC and linking it into a program. It includes some of the 
>> theory going on so this might help you.
>>
>> https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html
>>
>> Guys.. this comes up periodically, even though this is really basic tool 
>> usage to me, is this something we should provide some guidance on?
>
> Actually, i tried this before, but I cannot find libndbm in my development 
> directory. I guess it is not generated.
> .
> One thing I can do is, the newlib-cygwin i compiled while porting ndbm, it 
> generated ndbm library. I can use that.

Yes, the library should be 'bundled' with the updated compiler
toolchain. You need to be sure you are using this toolchain. Is it
what you installed to /home/varodek/development/rtems/5 ?

Gedare
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] Record-client program to read from a file for --input= flag

2019-06-28 Thread Sebastian Huber



- Am 28. Jun 2019 um 18:20 schrieb Gedare Bloom ged...@rtems.org:

> On Fri, Jun 28, 2019 at 10:15 AM Gedare Bloom  wrote:
>>
>> On Fri, Jun 28, 2019 at 5:02 AM Ravindra Meena  wrote:
>> >
>> > ---
>> >  misc/record/record-main.c | 35 ---
>> >  1 file changed, 24 insertions(+), 11 deletions(-)
>> >
>> > diff --git a/misc/record/record-main.c b/misc/record/record-main.c
>> > index b4591e3..14023e2 100644
>> > --- a/misc/record/record-main.c
>> > +++ b/misc/record/record-main.c
>> > @@ -39,6 +39,8 @@
>> >  #include 
>> >  #include 
>> >  #include 
>> > +#include
>> > +#include
>> >
>> add space before <
>>
>> when writing code, aim to be consistent with surrounding code, and
>> with coding style rules
>>
>> >  #include 
>> >  #include 
>> > @@ -52,6 +54,7 @@ static const struct option longopts[] = {
>> >{ "host", 1, NULL, 'H' },
>> >{ "port", 1, NULL, 'p' },
>> >{ "items", 1, NULL, 'i' },
>> > +  { "input", 1, NULL, 'f' },
>>
>> I know you were asked to add --input, however, since 'i' is already
>> used, it might be sensible to use --file= and 'f'?
>>
>> >{ NULL, 0, NULL, 0 }
>> >  };
>> >
>> > @@ -111,32 +114,35 @@ RB_GENERATE_INTERNAL( active, client_item, 
>> > active_node,
>> > item_cmp, static inline
>> >  static void usage( char **argv )
>> >  {
>> >printf(
>> > -"%s [--host=HOST] [--port=PORT] [--items=ITEMS]\n"
>> > +"%s [--host=HOST] [--port=PORT] [--items=ITEMS] [--input=INPUT]\n"
>> >  "\n"
>> >  "Mandatory arguments to long options are mandatory for short options 
>> > too.\n"
>> > -"  -h, --help print this help text\n"
>> > -"  -H, --host=HOSTthe host IPv4 address of the record 
>> > server\n"
>> > -"  -p, --port=PORTthe TCP port of the record server\n"
>> > -"  -i, --items=ITEMS  the maximum count of active record 
>> > items\n",
>> > +"  -h,  --help print this help text\n"
>> > +"  -H,  --host=HOSTthe host IPv4 address of the record
>> > server\n"
>> > +"  -p,  --port=PORTthe TCP port of the record server\n"
>> > +"  -i,  --items=ITEMS  the maximum count of active record 
>> > items\n"
>> Why is this reformatting the existing strings?
>>
>> > +"  -input,  --input=INPUT  the file input\n",
>> >  argv[ 0 ]
>> >);
>> >  }
>> >
>> > -static int connect_client( const char *host, uint16_t port )
>> > +static int connect_client( const char *host, uint16_t port, const char
>> > *input_file  ,bool input_file_flag )
>>
>> This is > 80 characters.
>> https://devel.rtems.org/wiki/Developer/Coding/Conventions#Formatting
>>
> I guess this is not RTEMS code, so you should refer to your mentor
> what would be the coding standard in use.

It used to be the RTEMS style.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel