citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

gl_runtime.h (2396B)


      1 //
      2 // Copyright (c) 2017 Kyle Milz <kyle.milz@gmail.com>
      3 //
      4 // Permission to use, copy, modify, and distribute this software for any
      5 // purpose with or without fee is hereby granted, provided that the above
      6 // copyright notice and this permission notice appear in all copies.
      7 //
      8 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      9 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     10 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     11 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     12 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     13 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     14 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     15 //
     16 #include <sys/types.h>
     17 
     18 #include <dirent.h>		// DIR, opendir, readdir
     19 #include <string>		// std::string
     20 #include <unordered_set>	// std::unordered_set
     21 #include <vector>		// std::vector
     22 
     23 #include "gl_buffer.h"		// citrun::gl_buffer
     24 #include "gl_font.h"		// citrun::gl_font
     25 #include "mem.h"		// citrun::mem
     26 #ifdef _WIN32
     27 #include "mem_win32.h"
     28 #else
     29 #include "mem_unix.h"		// citrun::mem_unix
     30 #endif
     31 
     32 
     33 namespace citrun {
     34 
     35 //
     36 // Owns a few pages of shared memory and a gl buffer.
     37 //
     38 class gl_transunit {
     39 private:
     40 	struct citrun_node	*m_node;
     41 	uint64_t		*m_data;
     42 	std::vector<uint64_t>	 m_data_buffer;
     43 	citrun::gl_buffer	 m_glbuffer;
     44 
     45 public:
     46 	gl_transunit(citrun::mem &, citrun::gl_font &, glyphy_point_t &);
     47 
     48 	std::string		 comp_file_path() const;
     49 	unsigned int		 num_lines() const;
     50 	void			 save_executions();
     51 	void			 display();
     52 	glyphy_extents_t	 get_extents();
     53 };
     54 
     55 //
     56 // Owns an executing/executed instrumented processes shared memory file and
     57 // gl_buffer.
     58 //
     59 class gl_procfile {
     60 private:
     61 	struct citrun_header	*m_header;
     62 	citrun::gl_buffer	 m_glbuffer;
     63 #ifdef _WIN32
     64 	MemWin32		 m_mem;
     65 #else
     66 	citrun::mem_unix	 m_mem;
     67 #endif
     68 
     69 public:
     70 	gl_procfile(std::string const&, citrun::gl_font &, double const&);
     71 
     72 	const citrun::gl_transunit *find_tu(std::string const &) const;
     73 	bool			 is_alive() const;
     74 	void			 display();
     75 	glyphy_extents_t	 get_extents();
     76 
     77 	std::vector<citrun::gl_transunit> m_tus;
     78 };
     79 
     80 class process_dir {
     81 private:
     82 	const char			*m_procdir;
     83 	DIR				*m_dirp;
     84 	std::unordered_set<std::string>	 m_known_files;
     85 
     86 public:
     87 	process_dir();
     88 	std::vector<std::string>	 scan();
     89 };
     90 
     91 } // namespace citrun