Hi Elena,
actually I found an even better way as described below, which is to
just check for the ">" sign in the debug-string. Attached is a patch
that handles it, and it allows for a syntax like this:
export HDF5_DEBUG=">trace.log trace"
This writes the API trace to the file "trace.log" .
The code should be portable, maybe the PATH_MAX definition needs some
more include or define on some platform.
Werner
On 24.07.2017 22:29, Elena Pourmal wrote:
All,
Will be more than happy to accept a patch for this request.
Elena
On Jul 24, 2017, at 9:53 AM, Werner Benger <wer...@cct.lsu.edu
<mailto:wer...@cct.lsu.edu>> wrote:
When compiled with the H5_DEBUG_API define, HDF5 allows tracing of
its API calls (
https://support.hdfgroup.org/HDF5/doc/H5.user/Debugging.html ).
To redirect this call into its own logfile instead of the standard
output or standard error, HDF5 uses the fdopen() function to make use
of an already opened file description, the actual opening operation
is left to the Unix shell, as in
||
|HDF5_DEBUG="55 trace" a.out 55>trace-output.log|
||
However, this mechanism doesn't seem to work under msys bash / mingw.
I could trace it down to a simple program:
#include <stdio.h>
main()
{
FILE*F = fdopen(55, "w");
perror("out 55");
fprintf(F, "hello\n");
return 0;
}
Then running it in the shell with
./a.exe 55>more.txt
This works well under Linux, even in the Windows Linux Subsystem, but
not in the msys bash:
$ ./a.exe 55> more.txt
out 55: Bad file descriptor
and neither in window's cmd.exe, where it seems only the first 10
numbers are allowed (
https://technet.microsoft.com/en-us/library/bb490982.aspx ):
> ./a.exe 5> more.txt
out 5: Bad file descriptor
Did anyone else get this mechanism to work under windows? If not,
maybe the HDF5 trace function should be modified to allow for a
filename instead of just a numerical file descriptor. The function in
charge is H5_debug_mask() in H5.c , and instead of calling fdopen()
on digits found in the HDF5_DEBUG environment variable, it could
check for something like a dot contained in the string, and if so
interpret it as filename to be opened instead (assuming that debug
package names never will contain a dot, and all logfiles must have a
file extension when opening via this mechanism).
Any thoughts?
Werner
--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org <mailto:Hdf-forum@lists.hdfgroup.org>
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5
--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362
--- C:/Users/Wrk/AppData/Local/Temp/H5.c-rev1678.svn000.tmp.c Fr. Jul 7
13:08:17 2017
+++ C:/msys64/home/Wrk/vish/fish/fiber/FiberHDF5/hdf5-1.10.1/src/H5.c Mo. Jul
24 23:18:11 2017
@@ -646,0 +647,3 @@ H5_debug_mask(const char *s)
+ else {
+ perror("trace stream open failed!");
+ }
@@ -649 +652,31 @@ H5_debug_mask(const char *s)
- } else {
+ } else if ( *s == '>') // MODIFIED WB 24.7.2017
+ {
+ char TraceFileName[ PATH_MAX ];
+ int t = 0;
+ s++;
+ while(*s && *s != ' ' && t<PATH_MAX)
+ TraceFileName[t++] = *s++;
+ TraceFileName[t] = '\0';
+ if (t>0)
+ {
+ H5_debug_open_stream_t *open_stream;
+ if((stream = HDfopen(TraceFileName, "w")) != NULL) {
+ (void)HDsetvbuf(stream, NULL, _IOLBF,
(size_t)0);
+
+ if(NULL == (open_stream =
(H5_debug_open_stream_t *)H5MM_malloc(sizeof(H5_debug_open_stream_t)))) {
+ (void)HDfclose(stream);
+ return;
+ } /* end if */
+ open_stream->stream = stream;
+ open_stream->next = H5_debug_g.open_stream;
+ H5_debug_g.open_stream = open_stream;
+
+ fprintf(stderr, "HDF5 API Tracing written to
[%s]\n", TraceFileName);
+
+ } /* end if */
+ else
+ perror(TraceFileName);
+ }
+ s++;
+ }
+ else {
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5