OSDN Git Service

* java/io/natFileDescriptorPosix.cc (open): Add O_CREAT in
[pf3gnuchains/gcc-fork.git] / libjava / include / name-finder.h
1 // name-finder.h - Convert addresses to names
2
3 /* Copyright (C) 2000  Red Hat Inc
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 /**
12  * @author Andrew Haley <aph@cygnus.com>
13  * @date Jan 6  2000
14  */
15
16 #include <gcj/cni.h>
17 #include <jvm.h>
18
19 #include <sys/types.h>
20 #include <sys/wait.h>
21
22 #include <string.h>
23 #include <stdio.h>
24
25 #ifdef HAVE_UNISTD_H
26 #include <unistd.h>
27 #endif
28
29 /* _Jv_name_finder is a class wrapper around a mechanism that can
30    convert addresses of methods to their names and the names of files
31    in which they appear. */
32
33 class _Jv_name_finder
34 {
35 public:  
36   _Jv_name_finder (char *executable);
37   ~_Jv_name_finder ()
38     {
39 #if defined (HAVE_PIPE) && defined (HAVE_FORK)
40       close (f_pipe[1]);
41       fclose (b_pipe_fd);
42
43       int wstat;
44       // We don't care about errors here.
45       waitpid (pid, &wstat, 0);
46 #endif
47     }
48
49 /* Given a pointer to a function or method, try to convert it into a
50    name and the appropriate line and source file.  The caller passes
51    the code pointer in p.
52
53    Returns false if the lookup fails.  Even if this happens, the field
54    hex will have been correctly filled in with the pointer. 
55
56    The other fields are method_name and file_name, which lookup will
57    attempt to fill appropriately.  If the lookup has failed, these
58    fields contain garbage.*/
59   bool lookup (void *p);
60
61   char method_name[1024];
62   char file_name[1024];
63   char hex[sizeof (void *) * 2 + 5];
64
65 private:
66   void toHex (void *p);
67 #if defined (HAVE_PIPE) && defined (HAVE_FORK)
68   pid_t pid;
69   int f_pipe[2], b_pipe[2];
70   FILE *b_pipe_fd;
71   int error;
72 #endif
73 };