Skip to content

Commit

Permalink
Plugins: ⚠️ Experimental! ⚠️ Include PID in plugin file name and use …
Browse files Browse the repository at this point in the history
….pdb names that do not include full path.
  • Loading branch information
rokups committed Dec 20, 2018
1 parent c579110 commit 3004fdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Source/ThirdParty/cr/include/cr/cr.h
Expand Up @@ -448,11 +448,14 @@ struct cr_plugin {
#include <cstring> // memcpy
#include <string>
#include <thread> // this_thread::sleep_for
#include <sys/types.h>
#if defined(CR_WINDOWS)
#include <process.h>
#define CR_PATH_SEPARATOR '\\'
#define CR_PATH_SEPARATOR_INVALID '/'
#else
#include <unistd.h>
#define CR_PATH_SEPARATOR '/'
#define CR_PATH_SEPARATOR_INVALID '\\'
#endif
Expand Down Expand Up @@ -490,7 +493,8 @@ static std::string cr_version_path(const std::string &basepath,
std::string folder, fname, ext;
cr_split_path(basepath, folder, fname, ext);
std::string ver = std::to_string(version);
return folder + fname.substr(0, fname.size() - ver.size()) + ver + ext;
std::string pid = std::to_string(getpid());
return folder + fname.substr(0, fname.size() - ver.size()) + "-" + pid + "-" + ver + ext;
}
namespace cr_plugin_section_type {
Expand Down Expand Up @@ -1489,6 +1493,8 @@ static bool cr_plugin_load_internal(cr_plugin &ctx, bool rollback) {
#if defined(_MSC_VER)
auto new_pdb = cr_replace_extension(new_file, ".pdb");
auto slash_index = new_pdb.find_last_of("/\\");
new_pdb = new_pdb.substr(slash_index + 1);
if (!cr_pdb_process(new_file, new_pdb)) {
fprintf(stderr, "Couldn't process PDB, debugging may be "
Expand Down
4 changes: 2 additions & 2 deletions Source/Tools/Editor/EditorHost/Program.cs
Expand Up @@ -67,7 +67,7 @@ private string GetNewPluginPath(string path)
{
var fileDir = Path.GetDirectoryName(path);
var fileName = Path.GetFileNameWithoutExtension(path);
path = $"{fileDir}{Path.DirectorySeparatorChar}{fileName}{_version}.dll";
path = $"{fileDir}{Path.DirectorySeparatorChar}{fileName}-{Process.GetCurrentProcess().Id}-{_version}.dll";
return path;
}

Expand All @@ -78,7 +78,7 @@ private string VersionFile(string path)

var pdbPath = Path.ChangeExtension(path, "pdb");
var versionedPath = GetNewPluginPath(path);
var versionedPdbPath = Path.ChangeExtension(versionedPath, "pdb");
var versionedPdbPath = Path.ChangeExtension(Path.GetFileName(versionedPath), "pdb");
Debug.Assert(versionedPath != null, $"{nameof(versionedPath)} != null");
File.Copy(path, versionedPath, true);

Expand Down

0 comments on commit 3004fdd

Please sign in to comment.