Skip to content
Browse files

Started on Greybeard, which is the library for reading module metadata

  • Loading branch information...
1 parent bc7cece commit 37bd266c25969f18c294179e2d9a051c06231d7a Steve Officer committed Dec 16, 2011
Showing with 33 additions and 23 deletions.
  1. +0 −3 Dovahkiin/Communication.cpp
  2. +1 −0 Dovahkiin/ProfilerCallback.cpp
  3. +10 −1 GreyBeard/GreyBeard.cpp
  4. +7 −6 GreyBeard/GreyBeard.h
  5. +0 −2 GreyBeard/Stdafx.h
  6. +3 −1 Thuum/PipeReader.fs
  7. +12 −10 Thuum/Program.fs
View
3 Dovahkiin/Communication.cpp
@@ -43,15 +43,13 @@ Communication::~Communication() {
}
void Communication::NotifyClassLoad(ClassID class_id, mdTypeDef type_definition_token, wstring assembly_name) {
- cout << "Doing class load stuff\n";
wstringstream message;
message << L"CLASSLOAD" << DELIM << class_id << DELIM << type_definition_token << DELIM << assembly_name << "\r\n";
wstring to_send = message.str();
WriteString(to_send.data());
}
void Communication::NotifyClassUnload(ClassID class_id) {
- cout << "Doing class unload stuff\n";
wstringstream message;
message << L"CLASSUNLOAD" << DELIM << class_id << "\r\n";
wstring to_send = message.str();
@@ -66,7 +64,6 @@ void Communication::NotifyObjectAllocated(ObjectID object_id, ClassID object_typ
}
void Communication::NotifyObjectIDsChanged(ObjectID old_ids[], ObjectID new_ids[]) {
- cout << "Doing object id stuff\n";
/*
wstringstream message;
message L"CLASSLOAD" << class_id << L"|" << assembly_name << "\n";
View
1 Dovahkiin/ProfilerCallback.cpp
@@ -80,6 +80,7 @@ HRESULT ProfilerCallback::Initialize(IUnknown *pICorProfilerInfoUnk) {
);
// Later I also want to track function calls so that I can forward this information on.
+ // This allows us to track things like dispose, add input, remove input and update cycles.
m_token_cache = new TokenCache(m_profiler_info);
return S_OK;
View
11 GreyBeard/GreyBeard.cpp
@@ -1,6 +1,15 @@
// This is the main DLL file.
#include "stdafx.h"
-
#include "GreyBeard.h"
+GreyBeard::Inspector::Inspector() {
+ CoInitialize(NULL);
+ CoCreateInstance(
+ CLSID_CorMetaDataDispenser,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IMetaDataImport,
+ (LPVOID*)&m_metadata_inspector
+ );
+}
View
13 GreyBeard/GreyBeard.h
@@ -1,13 +1,14 @@
-// GreyBeard.h
-
#pragma once
+#include "windows.h"
+#include "cor.h"
using namespace System;
namespace GreyBeard {
-
- public ref class Class1
- {
- // TODO: Add your methods for this class here.
+ public ref class Inspector {
+ private:
+ IMetaDataImport* m_metadata_inspector;
+ public:
+ Inspector();
};
}
View
2 GreyBeard/Stdafx.h
@@ -3,5 +3,3 @@
// but are changed infrequently
#pragma once
-
-
View
4 Thuum/PipeReader.fs
@@ -31,7 +31,9 @@ let ListenToPipe (msg_handler : Message MailboxProcessor) =
let rec get_messages() : unit =
let raw_message = stream_reader.ReadLine()
if raw_message = null
- then () // Exit the function, the pipe is closed
+ then
+ printfn "No More Messages"
+ ()
else
match ReadMessage raw_message with
| Some message -> msg_handler.Post(message)
View
22 Thuum/Program.fs
@@ -1,23 +1,27 @@
// Learn more about F# at http://fsharp.net
printfn "FUS RO DAH"
+type ClassInfo = {
+ Name : string
+}
+
// Mailbox processor for handling incomming messages.
let message_handler = MailboxProcessor.Start(fun messagebox ->
- let rec loop() = async {
+ let rec loop (class_info : Map<PipeReader.ClassID, ClassInfo>) = async {
let! msg = messagebox.Receive()
match msg with
| PipeReader.ClassLoad (class_id, type_def_token, module_name) ->
- printfn "ClassLoad %d - %d - %s" class_id type_def_token module_name
- return! loop()
+ return! loop (class_info.Add(class_id, {Name = "MadeUp Class Name"}))
| PipeReader.ClassUnload (class_id) ->
- printfn "ClassUnload %d" class_id
- return! loop()
+ return! loop (class_info.Remove(class_id))
| PipeReader.ObjectAllocated (object_id, class_id) ->
- printfn "Object Alloc %d - %d" object_id class_id
- return! loop()
+ match class_info.TryFind(class_id) with
+ | Some info -> ()
+ | None -> () // Need to add it to the deferred object allocation queue, the class will be loaded later.
+ return! loop class_info
}
- loop()
+ loop Map.empty
)
// The thread that the namedpipe client listens on
@@ -32,6 +36,4 @@ let listen_for_messages() =
// this is on the main thread
let message_thread = listen_for_messages()
-printfn "Job done"
-printfn "Thread %d" System.Threading.Thread.CurrentThread.ManagedThreadId
System.Console.ReadLine() |> ignore

0 comments on commit 37bd266

Please sign in to comment.
Something went wrong with that request. Please try again.