commit | f960048c4a68326918b4c98cdaf7d4e82c863c33 | [log] [tgz] |
---|---|---|
author | Jim Ingham <jingham@apple.com> | Tue Mar 29 21:45:47 2011 +0000 |
committer | Jim Ingham <jingham@apple.com> | Tue Mar 29 21:45:47 2011 +0000 |
tree | 0c9d116a55123c943dd13ef838cedf3f2c7b81c4 | |
parent | d05b4903bb95b07e709986961fe387921dd0e029 [diff] |
Can't just call "rand" to get a random port, 'cause then you'll get the same sequence in two lldb's. This makes running lldb on lldb not work very well. git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128493 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 49f9aa6..b434853 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -54,9 +54,16 @@ using namespace lldb; using namespace lldb_private; +static bool rand_initialized = false; + static inline uint16_t get_random_port () { + if (!rand_initialized) + { + rand_initialized = true; + sranddev(); + } return (rand() % (UINT16_MAX - 1000u)) + 1000u; }