repo_name
stringlengths 5
122
| path
stringlengths 3
232
| text
stringlengths 6
1.05M
|
---|---|---|
jlmonge/cs153-xv6 | sysproc.c | #include "types.h"
#include "x86.h"
#include "defs.h"
#include "date.h"
#include "param.h"
#include "memlayout.h"
#include "mmu.h"
#include "proc.h"
int
sys_fork(void)
{
return fork();
}
int
sys_exit(void)
{
exit();
return 0; // not reached
}
int
sys_wait(void) //Modified for part B
{
int* status;
if(argptr(0, (void*)&status, sizeof(*status)) < 0) //Fetch the nth word-sized system
return -1; //call argument as a pointer
return wait(status); // Removed pointer from parameter to get rid of casting error.
}
int
sys_kill(void)
{
int pid;
if(argint(0, &pid) < 0)
return -1;
return kill(pid);
}
int
sys_getpid(void)
{
return myproc()->pid;
}
int
sys_sbrk(void)
{
int addr;
int n;
if(argint(0, &n) < 0)
return -1;
addr = myproc()->sz;
if(growproc(n) < 0)
return -1;
return addr;
}
int
sys_sleep(void)
{
int n;
uint ticks0;
if(argint(0, &n) < 0)
return -1;
acquire(&tickslock);
ticks0 = ticks;
while(ticks - ticks0 < n){
if(myproc()->killed){
release(&tickslock);
return -1;
}
sleep(&ticks, &tickslock);
}
release(&tickslock);
return 0;
}
// return how many clock tick interrupts have occurred
// since start.
int
sys_uptime(void)
{
uint xticks;
acquire(&tickslock);
xticks = ticks;
release(&tickslock);
return xticks;
}
int
sys_exitWithStatus(void){ //Added system call for part A
int status;
if(argint(0, &status) < 0){ //Fetch the nth 32-bit system call argument.
return -1;
}
exitWithStatus(status);
return 0; //not reached
}
int
sys_waitpid(void){ //Added system call waitpid for part C
int pid;
int* status;
int options = 0; //options field returns 0, will update following version
if(argint(0, &pid) < 0){ //Fetch the nth 32-bit system call argument.
return -1;
}
if (argptr (1, (void*)&status ,sizeof(*status))){ //Fetch the nth word-sized system
return -1; //call argument as a pointer
}
return waitpid(pid, status, options);
}
void
sys_debug(void) //Added system call for part E
{
debug();
}
int
sys_modpr(void) // LAB 2
{
int pid, priority;
if(argint(0, &pid) < 0)
return -1;
if(argint(1, &priority) < 0)
return -1;
return modpr(pid, priority);
}
void
sys_ps(void) // LAB 2
{
ps();
}
int
sys_getpr(void) // LAB 2
{
return myproc()->priority;
} |
jlmonge/cs153-xv6 | l2-modpr.c | <gh_stars>0
#include "types.h"
#include "stat.h"
#include "user.h"
#include "stddef.h"
int
main(int argc, char *argv[])
{
if (argc != 3) {
printf(1, "Usage: l2-modpr <pid> <priority>\n");
}
else {
int pid = atoi(argv[1]);
int priority = atoi(argv[2]);
if (priority < 1 || priority > 5) {
printf(1, "Priority must be between 1 (highest) and 5 (lowest).\n");
exit();
}
printf(1, "~~~ BEFORE ~~~\n");
ps();
modpr(pid, priority);
printf(1, "~~~ AFTER ~~~\n");
ps();
}
exit();
return 0;
} |
jlmonge/cs153-xv6 | l2-lottery.c | <filename>l2-lottery.c<gh_stars>0
#include "types.h"
#include "stat.h"
#include "user.h"
#include "stddef.h"
// The test should be running ps
int
main(int argc, char *argv[])
{
if (argc != 2) {
printf(1, "Usage: l2-lottery <priority>\n");
}
else {
int pid = getpid();
int priority = atoi(argv[1]);
modpr(pid, priority);
printf(1, "priority of %d has been set\n", pid);
int i;
for (i = 0; i < 10; i++) {
sleep(1);
ps();
}
}
exit();
return 0;
} |
gbtunze/sesegpu | data.h | <reponame>gbtunze/sesegpu
#include <cnpy.h>
#include <stdio.h>
#include <wordexp.h>
#include <experimental/mdspan>
namespace stdex = std::experimental;
constexpr int side = 28;
using mnisttype = stdex::basic_mdspan<uint8_t, stdex::extents<stdex::dynamic_extent, side, side> >;
// Global scope to keep
cnpy::NpyArray x_test;
mnisttype getdata()
{
wordexp_t* exp = new wordexp_t;
if (wordexp("~/.keras/datasets/mnist.npz", exp, WRDE_NOCMD) != 0 || exp->we_wordc != 1)
{
fprintf(stderr, "Error expanding.\n");
std::terminate();
}
fprintf(stderr, "Loading file %s\n", exp->we_wordv[0]);
auto inputdata = cnpy::npz_load(exp->we_wordv[0]);
wordfree(exp);
x_test = inputdata["x_test"];
return mnisttype(x_test.data<uint8_t>(), (int) x_test.shape[0]);
}
const mnisttype data = getdata();
|
jamesanto/ray | src/ray/pubsub/publisher.h | // Copyright 2017 The Ray Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <gtest/gtest_prod.h>
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/synchronization/mutex.h"
#include "ray/common/asio/periodical_runner.h"
#include "ray/common/id.h"
#include "src/ray/protobuf/common.pb.h"
namespace ray {
namespace pubsub {
using SubscriberID = UniqueID;
using LongPollConnectCallback = std::function<void(const std::vector<ObjectID> &)>;
namespace pub_internal {
/// Index for object ids and node ids of subscribers.
class SubscriptionIndex {
public:
explicit SubscriptionIndex() {}
~SubscriptionIndex() = default;
/// Add a new entry to the index.
/// NOTE: If the entry already exists, it raises assert failure.
void AddEntry(const ObjectID &object_id, const SubscriberID &subscriber_id);
/// Return the set of subscriber ids that are subscribing to the given object ids.
absl::optional<std::reference_wrapper<const absl::flat_hash_set<SubscriberID>>>
GetSubscriberIdsByObjectId(const ObjectID &object_id) const;
/// Erase the subscriber from the index. Returns the number of erased subscribers.
/// NOTE: It cannot erase subscribers that were never added.
bool EraseSubscriber(const SubscriberID &subscriber_id);
/// Erase the object id and subscriber id from the index. Return the number of erased
/// entries.
/// NOTE: It cannot erase subscribers that were never added.
bool EraseEntry(const ObjectID &object_id, const SubscriberID &subscriber_id);
/// Return true if the object id exists in the index.
bool HasObjectId(const ObjectID &object_id) const;
/// Returns true if object id or subscriber id exists in the index.
bool HasSubscriber(const SubscriberID &subscriber_id) const;
/// Testing only. Return true if there's no metadata remained in the private attribute.
bool AssertNoLeak() const;
private:
/// Mapping from objects -> subscribers.
absl::flat_hash_map<ObjectID, absl::flat_hash_set<SubscriberID>>
objects_to_subscribers_;
// Mapping from subscribers -> objects. Reverse index of objects_to_subscribers_.
absl::flat_hash_map<SubscriberID, absl::flat_hash_set<ObjectID>>
subscribers_to_objects_;
};
/// Abstraction to each subscriber.
class Subscriber {
public:
explicit Subscriber(const std::function<double()> &get_time_ms,
uint64_t connection_timeout_ms, const uint64_t publish_batch_size)
: get_time_ms_(get_time_ms),
connection_timeout_ms_(connection_timeout_ms),
publish_batch_size_(publish_batch_size),
last_connection_update_time_ms_(get_time_ms()) {}
~Subscriber() = default;
/// Connect to the subscriber. Currently, it means we cache the long polling request to
/// memory. Once the bidirectional gRPC streaming is enabled, we should replace it.
///
/// \param long_polling_reply_callback reply callback to the long polling request.
/// \return True if connection is new. False if there were already connections cached.
bool ConnectToSubscriber(LongPollConnectCallback long_polling_reply_callback);
/// Queue the object id to publish to the subscriber.
///
/// \param object_id Object id to publish to the subscriber.
/// \param try_publish If true, it try publishing the object id if there is a
/// connection. False is used only for testing.
void QueueMessage(const ObjectID &object_id, bool try_publish = true);
/// Publish all queued messages if possible.
///
/// \param force If true, we publish to the subscriber although there's no queued
/// message.
/// \return True if it publishes. False otherwise.
bool PublishIfPossible(bool force = false);
/// Testing only. Return true if there's no metadata remained in the private attribute.
bool AssertNoLeak() const;
/// Return true if the subscriber is disconnected (if the subscriber is dead).
/// The subscriber is considered to be dead if there was no long polling connection for
/// the timeout.
bool IsDisconnected() const;
/// Return true if there was no new long polling connection for a long time.
bool IsActiveConnectionTimedOut() const;
private:
/// Cached long polling reply callback.
/// It is cached whenever new long polling is coming from the subscriber.
/// It becomes a nullptr whenever the long polling request is replied.
LongPollConnectCallback long_polling_reply_callback_ = nullptr;
/// Queued messages to publish.
std::list<ObjectID> mailbox_;
/// Callback to get the current time.
const std::function<double()> get_time_ms_;
/// The time in which the connection is considered as timed out.
uint64_t connection_timeout_ms_;
/// The maximum number of objects to publish for each publish calls.
const uint64_t publish_batch_size_;
/// The last time long polling was connected in milliseconds.
double last_connection_update_time_ms_;
};
} // namespace pub_internal
/// Protocol detail
///
/// - Subscriber always send a long polling connection as long as there are subscribed
/// entries from the publisher.
/// - Publisher caches the long polling request and reply whenever there are published
/// messages.
/// - Publishes messages are batched in order to avoid gRPC message limit.
/// - Look at CheckDeadSubscribers for failure handling mechanism.
///
class Publisher {
public:
/// Pubsub coordinator constructor.
///
/// \param periodical_runner Periodic runner. Used to periodically run
/// CheckDeadSubscribers.
/// \param get_time_ms A callback to get the current time in
/// milliseconds.
/// \param subscriber_timeout_ms The subscriber timeout in milliseconds.
/// Check out CheckDeadSubscribers for more details.
/// \param publish_batch_size The batch size of published messages.
explicit Publisher(PeriodicalRunner *periodical_runner,
const std::function<double()> get_time_ms,
const uint64_t subscriber_timeout_ms,
const uint64_t publish_batch_size)
: periodical_runner_(periodical_runner),
get_time_ms_(get_time_ms),
subscriber_timeout_ms_(subscriber_timeout_ms),
publish_batch_size_(publish_batch_size) {
periodical_runner_->RunFnPeriodically([this] { CheckDeadSubscribers(); },
subscriber_timeout_ms);
}
~Publisher() = default;
///
/// TODO(sang): Currently, we need to pass the callback for connection because we are
/// using long polling internally. This should be changed once the bidirectional grpc
/// streaming is supported.
void ConnectToSubscriber(const SubscriberID &subscriber_id,
LongPollConnectCallback long_poll_connect_callback);
/// Register the subscription.
///
/// \param subscriber_id The node id of the subscriber.
/// \param object_id The object id that the subscriber is subscribing to.
void RegisterSubscription(const SubscriberID &subscriber_id, const ObjectID &object_id);
/// Publish the given object id to subscribers.
///
/// \param object_id The object id to publish to subscribers.
void Publish(const ObjectID &object_id);
/// Remove the subscriber. Once the subscriber is removed, messages won't be published
/// to it anymore.
/// TODO(sang): Currently, clients don't send a RPC to unregister themselves.
///
/// \param subscriber_id The node id of the subscriber to unsubscribe.
/// \return True if erased. False otherwise.
bool UnregisterSubscriber(const SubscriberID &subscriber_id);
/// Unregister subscription. It means the given object id won't be published to the
/// subscriber anymore.
///
/// \param subscriber_id The node id of the subscriber.
/// \param object_id The object id of the subscriber.
/// \return True if erased. False otherwise.
bool UnregisterSubscription(const SubscriberID &subscriber_id,
const ObjectID &object_id);
/// Check all subscribers, detect which subscribers are dead or its connection is timed
/// out, and clean up their metadata. This uses the goal-oriented logic to clean up all
/// metadata that can happen by subscriber failures. It is how it works;
///
/// - If there's no new long polling connection for the timeout, it refreshes the long
/// polling connection.
/// - If the subscriber is dead, there will be no new long polling connection coming in
/// again. Otherwise, the long polling connection will be reestablished by the
/// subscriber.
/// - If there's no long polling connection for another timeout, it treats the
/// subscriber as dead.
///
/// TODO(sang): Currently, it iterates all subscribers periodically. This can be
/// inefficient in some scenarios.
/// For example, think about we have a driver with 100K subscribers (it can
/// happen due to reference counting). We might want to optimize this by
/// having a timer per subscriber.
void CheckDeadSubscribers();
/// Testing only. Return true if there's no metadata remained in the private attribute.
bool AssertNoLeak() const;
private:
bool UnregisterSubscriberInternal(const SubscriberID &subscriber_id)
EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Periodic runner to invoke CheckDeadSubscribers.
PeriodicalRunner *periodical_runner_;
/// Callback to get the current time.
const std::function<double()> get_time_ms_;
/// The timeout where subscriber is considered as dead.
const uint64_t subscriber_timeout_ms_;
/// Protects below fields. Since the coordinator runs in a core worker, it should be
/// thread safe.
mutable absl::Mutex mutex_;
/// Mapping of node id -> subscribers.
absl::flat_hash_map<SubscriberID, std::shared_ptr<pub_internal::Subscriber>>
subscribers_ GUARDED_BY(mutex_);
/// Index that stores the mapping of objects <-> subscribers.
pub_internal::SubscriptionIndex subscription_index_ GUARDED_BY(mutex_);
/// The maximum number of objects to publish for each publish calls.
const uint64_t publish_batch_size_;
};
} // namespace pubsub
} // namespace ray
|
jamesanto/ray | cpp/include/ray/api/static_check.h | // Copyright 2017 The Ray Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <ray/api/object_ref.h>
#include <boost/callable_traits.hpp>
#include <type_traits>
namespace ray {
namespace api {
template <typename T>
struct FilterArgType {
using type = T;
};
template <typename T>
struct FilterArgType<ObjectRef<T>> {
using type = T;
};
template <typename Function, typename... Args>
inline absl::enable_if_t<!std::is_member_function_pointer<Function>::value>
StaticCheck() {
static_assert(std::is_same<std::tuple<typename FilterArgType<Args>::type...>,
boost::callable_traits::args_t<Function>>::value,
"arguments not match");
}
template <typename Function, typename... Args>
inline absl::enable_if_t<std::is_member_function_pointer<Function>::value> StaticCheck() {
using ActorType = boost::callable_traits::class_of_t<Function>;
static_assert(
std::is_same<std::tuple<ActorType &, typename FilterArgType<Args>::type...>,
boost::callable_traits::args_t<Function>>::value,
"arguments not match");
}
} // namespace api
} // namespace ray
|
jamesanto/ray | src/ray/pubsub/subscriber.h | <reponame>jamesanto/ray
// Copyright 2017 The Ray Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "ray/common/id.h"
#include "ray/rpc/worker/core_worker_client_pool.h"
#include "src/ray/protobuf/common.pb.h"
namespace ray {
namespace pubsub {
using SubscriberID = UniqueID;
using PublisherID = UniqueID;
using SubscriptionCallback = std::function<void(const ObjectID &)>;
using SubscriptionFailureCallback = std::function<void(const ObjectID &)>;
/// Interface for the pubsub client.
class SubscriberInterface {
public:
/// Subscribe to the object.
///
/// \param publisher_address Address of the publisher to subscribe the object.
/// \param object_id The object id to subscribe from the publisher.
/// \param subscription_callback A callback that is invoked whenever the given object
/// information is published.
/// \param subscription_failure_callback A callback that is
/// invoked whenever the publisher is dead (or failed).
virtual void SubcribeObject(
const rpc::Address &publisher_address, const ObjectID &object_id,
SubscriptionCallback subscription_callback,
SubscriptionFailureCallback subscription_failure_callback) = 0;
/// Unsubscribe the object.
/// NOTE: Calling this method inside subscription_failure_callback is not allowed.
/// NOTE: Currently, this method doesn't send a RPC to the pubsub server. It is because
/// the client is currently used for WaitForObjectFree, and the coordinator will
/// automatically unregister the subscriber after publishing the object. But if we use
/// this method for OBOD, we should send an explicit RPC to unregister the subscriber
/// from the server.
///
/// TODO(sang): Once it starts sending RPCs to unsubscribe, we should start handling
/// message ordering.
/// \param publisher_address The publisher address that it will unsubscribe to.
/// \param object_id The object id to unsubscribe.
virtual bool UnsubscribeObject(const rpc::Address &publisher_address,
const ObjectID &object_id) = 0;
/// Testing only. Return true if there's no metadata remained in the private attribute.
virtual bool AssertNoLeak() const = 0;
virtual ~SubscriberInterface() {}
};
/// The pubsub client implementation.
///
/// Protocol details:
///
/// - Publisher keeps refreshing the long polling connection every subscriber_timeout_ms.
/// - Subscriber always try making reconnection as long as there are subscribed entries.
/// - If long polling request is failed (if non-OK status is returned from the RPC),
/// consider the publisher is dead.
///
class Subscriber : public SubscriberInterface {
public:
explicit Subscriber(const PublisherID subscriber_id,
const std::string subscriber_address, const int subscriber_port,
rpc::CoreWorkerClientPool &publisher_client_pool)
: subscriber_id_(subscriber_id),
subscriber_address_(subscriber_address),
subscriber_port_(subscriber_port),
publisher_client_pool_(publisher_client_pool) {}
~Subscriber() = default;
void SubcribeObject(const rpc::Address &publisher_address, const ObjectID &object_id,
SubscriptionCallback subscription_callback,
SubscriptionFailureCallback subscription_failure_callback) override;
bool UnsubscribeObject(const rpc::Address &publisher_address,
const ObjectID &object_id) override;
bool AssertNoLeak() const override;
private:
/// Encapsulates the subscription information such as subscribed object ids ->
/// callbacks.
/// TODO(sang): Use a channel abstraction instead of publisher address once OBOD uses
/// the pubsub.
struct SubscriptionInfo {
SubscriptionInfo(const rpc::Address &pubsub_server_address)
: pubsub_server_address_(pubsub_server_address) {}
/// Address of the pubsub server.
const rpc::Address pubsub_server_address_;
// Object ID -> subscription_callback
absl::flat_hash_map<const ObjectID,
std::pair<SubscriptionCallback, SubscriptionFailureCallback>>
subscription_callback_map_;
};
/// Create a long polling connection to the publisher for receiving the published
/// messages.
///
/// TODO(sang): Currently, we assume that unregistered objects will never be published
/// from the pubsub server. We may want to loose the restriction once OBOD is supported
/// by this function.
/// \param publisher_address The address of the publisher that publishes
/// objects.
/// \param subscriber_address The address of the subscriber.
void MakeLongPollingPubsubConnection(const rpc::Address &publisher_address,
const rpc::Address &subscriber_address);
/// Private method to handle long polling responses. Long polling responses contain the
/// published messages.
void HandleLongPollingResponse(const rpc::Address &publisher_address,
const rpc::Address &subscriber_address,
const Status &status,
const rpc::PubsubLongPollingReply &reply);
/// Returns a subscription callback; Returns a nullopt if the object id is not
/// subscribed.
absl::optional<SubscriptionCallback> GetSubscriptionCallback(
const rpc::Address &publisher_address, const ObjectID &object_id) const;
/// Returns a publisher failure callback; Returns a nullopt if the object id is not
/// subscribed.
absl::optional<SubscriptionCallback> GetFailureCallback(
const rpc::Address &publisher_address, const ObjectID &object_id) const;
/// Self node's address information.
const SubscriberID subscriber_id_;
const std::string subscriber_address_;
const int subscriber_port_;
/// Mapping of the publisher ID -> subscription info.
absl::flat_hash_map<PublisherID, SubscriptionInfo> subscription_map_;
/// Cache of gRPC clients to publishers.
rpc::CoreWorkerClientPool &publisher_client_pool_;
};
} // namespace pubsub
} // namespace ray
|
jamesanto/ray | cpp/include/ray/api/task_caller.h | <gh_stars>1-10
#pragma once
#include <ray/api/static_check.h>
#include "ray/core.h"
namespace ray {
namespace api {
template <typename F>
class TaskCaller {
public:
TaskCaller();
TaskCaller(RayRuntime *runtime, RemoteFunctionPtrHolder ptr);
template <typename... Args>
ObjectRef<boost::callable_traits::return_type_t<F>> Remote(Args... args);
private:
RayRuntime *runtime_;
RemoteFunctionPtrHolder ptr_{};
std::string function_name_;
std::vector<std::unique_ptr<::ray::TaskArg>> args_;
};
// ---------- implementation ----------
template <typename F>
TaskCaller<F>::TaskCaller() {}
template <typename F>
TaskCaller<F>::TaskCaller(RayRuntime *runtime, RemoteFunctionPtrHolder ptr)
: runtime_(runtime), ptr_(ptr) {}
template <typename F>
template <typename... Args>
ObjectRef<boost::callable_traits::return_type_t<F>> TaskCaller<F>::Remote(Args... args) {
StaticCheck<F, Args...>();
using ReturnType = boost::callable_traits::return_type_t<F>;
Arguments::WrapArgs(&args_, args...);
ptr_.exec_function_pointer = reinterpret_cast<uintptr_t>(
NormalExecFunction<ReturnType, typename FilterArgType<Args>::type...>);
auto returned_object_id = runtime_->Call(ptr_, args_);
return ObjectRef<ReturnType>(returned_object_id);
}
} // namespace api
} // namespace ray
|
jamesanto/ray | cpp/include/ray/api/actor_task_caller.h | <gh_stars>1-10
#pragma once
#include <ray/api/arguments.h>
#include <ray/api/exec_funcs.h>
#include <ray/api/object_ref.h>
#include <ray/api/static_check.h>
#include "ray/core.h"
namespace ray {
namespace api {
template <typename F>
class ActorTaskCaller {
public:
ActorTaskCaller() = default;
ActorTaskCaller(RayRuntime *runtime, ActorID id, RemoteFunctionPtrHolder ptr,
std::vector<std::unique_ptr<::ray::TaskArg>> &&args)
: runtime_(runtime), id_(id), ptr_(ptr), args_(std::move(args)) {}
ActorTaskCaller(RayRuntime *runtime, ActorID id, RemoteFunctionPtrHolder ptr)
: runtime_(runtime), id_(id), ptr_(ptr) {}
template <typename... Args>
ObjectRef<boost::callable_traits::return_type_t<F>> Remote(Args... args);
private:
RayRuntime *runtime_;
ActorID id_;
RemoteFunctionPtrHolder ptr_;
std::vector<std::unique_ptr<::ray::TaskArg>> args_;
};
// ---------- implementation ----------
template <typename F>
template <typename... Args>
ObjectRef<boost::callable_traits::return_type_t<F>> ActorTaskCaller<F>::Remote(
Args... args) {
using ActorType = boost::callable_traits::class_of_t<F>;
using ReturnType = boost::callable_traits::return_type_t<F>;
StaticCheck<F, Args...>();
if (!ray::api::RayConfig::GetInstance()->use_ray_remote) {
auto exe_func =
ActorExecFunction<ReturnType, ActorType, typename FilterArgType<Args>::type...>;
ptr_.exec_function_pointer = reinterpret_cast<uintptr_t>(exe_func);
}
Arguments::WrapArgs(&args_, args...);
auto returned_object_id = runtime_->CallActor(ptr_, id_, args_);
return ObjectRef<ReturnType>(returned_object_id);
}
} // namespace api
} // namespace ray
|
alessandro308/MeshWeather | src/networkSettings.h |
#define MESH_PREFIX "meshNet"
#define MESH_PASSWORD "<PASSWORD>"
#define MESH_PORT 5555
#define SERVER_SSID "serverssid"
#define RSSI_THRESHOLD 50
#define SERVER_ID
|
gsn9/SugarSpice | SpiceQL/include/utils.h | /**
* @file
*
*
**/
#pragma once
#include <iostream>
#include <regex>
#include <optional>
#include <fmt/chrono.h>
#include <fmt/format.h>
#include <fmt/compile.h>
#include <nlohmann/json.hpp>
#include "spice_types.h"
/**
* @namespace SpiceQL
*
*/
namespace SpiceQL {
/**
* @brief force a string to upper case
*
* @param s input string
* @return copy of input string, in upper case
*/
std::string toUpper(std::string s);
/**
* @brief force a string to lower case
*
* @param s input string
* @return copy of input string, in lower case
*/
std::string toLower(std::string s);
/**
* @brief find and replace one substring with another
*
* @param str input string to search
* @param from substring to find
* @param to substring to replace "from" instances to
* @return std::string
*/
std::string replaceAll(std::string str, const std::string &from, const std::string &to);
/**
* @brief Merge two json configs
*
* When arrays are merged, the values from the base config will appear
* first in the merged config.
*
* @param baseConfig First json config
* @param mergingConfig Second json config
* @return nlohmann::json
*/
nlohmann::json mergeConfigs(nlohmann::json baseConfig, nlohmann::json mergingConfig);
/**
* @brief ls, like in unix, kinda. Also it's a function.
*
* Iterates the input path and returning a list of files. Optionally, recursively.
*
* @param root The root directory to search
* @param recursive recursively iterates through directories if true
*
* @returns list of paths
**/
std::vector<std::string> ls(std::string const & root, bool recursive);
/**
* @brief glob, like python's glob.glob, except C++
*
* Given a root and a regular expression, give all the files that match.
*
* @param root The root directory to search
* @param reg std::regex object to pattern to search, defaults to ".*", or match averything.
* @param recursive recursively iterates through directories if true
*
* @returns list of paths matching regex
**/
std::vector<std::string> glob(std::string const & root,
std::regex const & reg = std::regex(".*"),
bool recursive=false);
/**
* @brief Get start and stop times a kernel.
*
* For each segment in the kernel, get all start and stop times as a vector of double pairs.
* This gets all start and stop times regardless of the frame associated with it.
*
* Input kernel is assumed to be a binary kernel with time dependant external orientation data.
*
* @param kpath Path to the kernel
* @returns std::vector of start and stop times
**/
std::vector<std::pair<double, double>> getTimeIntervals(std::string kpath);
/**
* @brief Simple struct for holding target states
*/
//! @cond Doxygen_Suppress
struct targetState {double lt; std::array<double,6> starg;};
//! @endcond
/**
* @brief Gives the position and velocity for a given frame at some ephemeris time
*
* Mostly a C++ wrap for NAIF's spkezr_c
*
* @param et ephemeris time at which you want to optain the target state
* @param target NAIF ID for the target frame
* @param observer NAIF ID for the observing frame
* @param frame The reference frame in which to get the positions in
* @param abcorr aborration correction flag, default it NONE.
* This can set to:
* "NONE" - No correction
* For the "reception" case, i.e. photons from the target being recieved by the observer at the given time.
* "LT" - One way light time correction
* "LT+S" - Correct for one-way light time and stellar aberration correction
* "CN" - Converging Newtonian light time correction
* "CN+S" - Converged Newtonian light time correction and stellar aberration correction
* For the "transmission" case, i.e. photons emitted from the oberver hitting at target at the given time
* "XLT" - One-way light time correction using a newtonian formulation
* "XLT+S" - One-way light time and stellar aberration correction using a newtonian formulation
* "XCN" - converged Newtonian light time correction
* "XCN+S" - converged Newtonian light time correction and stellar aberration correction.
* @return A TargetState struct with the light time adjustment and a Nx6 state vector of positions and velocities in x,y,z,vx,vy,vz format.
**/
targetState getTargetState(double et, std::string target, std::string observer, std::string frame="J2000", std::string abcorr="NONE");
/**
* @brief simple struct for holding target orientations
*/
//! @cond Doxygen_Suppress
struct targetOrientation {std::array<double,4> quat; std::optional<std::array<double,3>> av;};
//! @endcond
/**
* @brief Gives quaternion and angular velocity for a given frame at a given ephemeris time
*
* Orientations for an input frame in some reference frame.
* The orientations returned from this function can be used to transform a position
* in the source frame to the ref frame.
*
* @param et ephemeris time at which you want to optain the target pointing
* @param toframe the source frame's NAIF code.
* @param refframe the reference frame's NAIF code, orientations are relative to this reference frame
* @returns SPICE-style quaternions (w,x,y,z) and optional angular velocity
**/
targetOrientation getTargetOrientation(double et, int toframe, int refframe=1); // use j2000 for default reference frame
/**
* @brief finds key:values in kernel pool
*
* Given a key template, returns matching key:values from the kernel pool
* by using gnpool, gcpool, gdpool, and gipool
*
* @param keytpl input key template to search for
*
* @returns json list of found key:values
**/
nlohmann::json findKeywords(std::string keytpl);
/**
* @brief recursively search keys in json.
*
* Given a root and a regular expression, give all the files that match.
*
* @param in input json to search
* @param key key to search for
* @param recursive recursively iterates through objects if true
*
* @returns vector of refernces to matching json objects
**/
std::vector<nlohmann::json::json_pointer> findKeyInJson(nlohmann::json in, std::string key, bool recursive=true);
/**
* @brief get the Kernel type (CK, SPK, etc.)
*
*
* @param kernelPath path to kernel
* @returns Kernel type as a string
**/
std::string getKernelType(std::string kernelPath);
/**
* @brief Get the directory pointing to the db files
*
* Default behavior returns the installed DB files in $CONDA_PREFIX/etc/SpiceQL/db.
*
* If the env var $SSPICE_DEBUG is set, this returns the local source path of
* _SOURCE_PREFIX/SpiceQL/db/
*
* @return std::string directory containing db files
*/
std::string getConfigDirectory();
/**
* @brief Returns a vector of all the available configs
*
* Returns the db files in either the installed or debug directory depending
* on whether or not SSPICE_DEBUG is set.
*
* @see getConfigDirectory
*
* @return std::vector<std::string>
*/
std::vector<std::string> getAvailableConfigFiles();
/**
* @brief Get names of available config files as a json vector
*
* This iterates through all the configs in the db folder either installed
* or in the debug directory depending on whether or not SSPICE_DEBUG is set. Loads them
* as vector of json obects and returns the vector.
*
* @return std::vector<nlohmann::json>
*/
std::vector<nlohmann::json> getAvailableConfigs();
/**
* @brief Returns the path to the Mission specific Spice config file.
*
* Given a mission, search a prioritized list of directories for
* the json config file. This function checks in the order:
*
* 1. The local build dir, i.e. $CMAKE_SOURCE_DIR
* 2. The install dir, i.e. $CMAKE_PREFIX
*
* @param mission mission name of the config file
*
* @returns path object of the condig file
**/
std::string getMissionConfigFile(std::string mission);
/**
* @brief Returns the path to the Mission specific Spice config file.
*
* Given a mission, search a prioritized list of directories for
* the json config file. This function checks in the order:
*
* 1. The local build dir, i.e. $CMAKE_SOURCE_DIR
* 2. The install dir, i.e. $CMAKE_PREFIX
*
* @param mission mission name of the config file
*
* @returns path object of the config file
**/
nlohmann::json getMissionConfig(std::string mission);
/**
* @brief Returns the Instrument specific Spice config.
*
* Given an instrument, search a prioritized list of directories for
* the json config file that contains that instrument. See getAvailableConfigs
* for the search hierarchy
*
* @param instrument The name of the instrument to find a config for
*
* @returns The config file parsed into a JSON object
**/
nlohmann::json getInstrumentConfig(std::string instrument);
/**
* @brief Returns std::vector<string> interpretation of a json array.
*
* Attempts to convert the json array to a C++ array. Also handles
* strings in cases where one element arrays are stored as scalars.
* Throws exception if the json obj is not an array.
*
* @param arr input json arr
*
* @returns string vector containing arr data
**/
std::vector<std::string> jsonArrayToVector(nlohmann::json arr);
/**
* @brief Returns std::vector<string> interpretation of a json array.
*
* Attempts to convert the json array to a C++ array. Also handles
* strings in cases where one element arrays are stored as scalars.
* Throws exception if the json obj is not an array.
*
* @param arr input json arr
*
* @returns string vector containing arr data
**/
std::string getDataDirectory();
}
|
gsn9/SugarSpice | SpiceQL/include/io.h | <reponame>gsn9/SugarSpice
#pragma once
/**
* @file
*
* Functions for reading and writing Kernels
*
**/
#include <string>
#include <vector>
#include <nlohmann/json.hpp>
namespace SpiceQL {
/**
* @brief C++ object repersenting NAIF spice SPK Segment and it's metadata
*
* SPK kernels consist of multiple CK segments. These specifically define a
* type 13 SPK segment which consists of parallel arrary of ephemeris times
* in a 6 element state array's of x, y, z, vx, vy, vz
*
*/
class SpkSegment {
public:
/**
* Constructs a fully populated SpkSegment
*
* @param statePositions Time ordered vector of state positions X,Y,Z
* @param stateTimes Time ordered vector of state ephemeris times (TDB)
* @param bodyCode Naif body code of an object whose state is described by the segments
* @param centerOfMotion Naif body code of an object which is the center of motion for
* bodyCode
* @param referenceFrame Naif name of the reference system relative to which the state is
* @param id SPK segment identifier (max size 40)
* @param degree Degree of the Hermite polynomials used to interpolate the states
* @param stateVelocities Time ordered vector of state velocities dX, dY, dZ
* @param segmentComment The comment string for the new segment
**/
SpkSegment(std::vector<std::vector<double>> statePositions,
std::vector<double> stateTimes,
int bodyCode,
int centerOfMotion,
std::string referenceFrame,
std::string id, int degree,
std::optional<std::vector<std::vector<double>>> stateVelocities,
std::optional<std::string> segmentComment);
//! @cond Doxygen_Suppress
std::vector<double> stateTimes;
int bodyCode;
int centerOfMotion;
std::string referenceFrame;
std::string id;
int polyDegree;
std::vector<std::vector<double>> statePositions;
std::optional<std::vector<std::vector<double>>> stateVelocities;
std::optional<std::string> comment;
//! @endcond
};
/**
* @brief C++ object repersenting NAIF spice CK Segment and it's metadata
*
* CK kernels consist of multiple CK segments. These specifically define a
* type 3 CK segment which consists of two parallel arrays of ephemeris times
* and orientations as SPICE quaternions.
*
* @see: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/q2m_c.html
*
*/
class CkSegment {
public:
/**
* Constructs a fully populated SpkSegment
* @param quats Time ordered vector of orientations as quaternions
* @param times times for the CK segment in ascending order
* @param bodyCode Naif body code of an object whose state is described by the segments
* @param referenceFrame Naif name of the reference system relative to which the state is
* @param id SPK segment identifier (max size 40)
* @param anglularVelocities Time ordered vector of state velocities dX, dY, dZ
* @param comment The comment string for the new segment
*/
CkSegment(std::vector<std::vector<double>> quats, std::vector<double> times, int bodyCode,
std::string referenceFrame, std::string id,
std::optional<std::vector<std::vector<double>>> anglularVelocities = std::nullopt,
std::optional<std::string> comment = std::nullopt);
//! @cond Doxygen_Suppress
std::vector<double> times;
std::vector<std::vector<double>> quats;
int bodyCode;
std::string referenceFrame;
std::string id;
std::optional<std::vector<std::vector<double>>> angularVelocities = std::nullopt;
std::optional<std::string> comment = std::nullopt;
//! @endcond
};
/**
* Combine the state positions and velocities into a single vector
*
* @return Single vector with {X1, Y1, Z1, dX1, dY1, dZ1, X2, Y2, Z2, dX2, dY2, dZ2, ...}
*/
std::vector<std::vector<double>> concatStates (std::vector<std::vector<double>> statePositions,
std::vector<std::vector<double>> stateVelocities);
/**
* @brief Write SPK segments to a file
*
* Given a vector of SPK segments, write them to the requested SPK file.
*
* @param fileName file specification to have the SPK segments written to
* @param segments spkSegments to be written
*/
void writeSpk (std::string fileName,
std::vector<SpkSegment> segments);
/**
* @brief Write SPK to path
*
* @param fileName full path to file to write the segment to
* @param statePositions Nx3 array of positions in X,Y,Z order
* @param stateTimes Nx1 array of times
* @param bodyCode NAIF integer code for the body the states belong to
* @param centerOfMotion is the NAIF integer code for the center of motion of the object identified by body.
* @param referenceFrame The NAIF code the states are relative to
* @param segmentId ID for the segment
* @param polyDegree degree of the hermite polynomials used for interpolation
* @param stateVelocities Nx3 array of state velocities in VX, VY, VZ order, optional
* @param segmentComment Comment associated with the segment, optional
*/
void writeSpk(std::string fileName,
std::vector<std::vector<double>> statePositions,
std::vector<double> stateTimes,
int bodyCode,
int centerOfMotion,
std::string referenceFrame,
std::string segmentId,
int polyDegree,
std::optional<std::vector<std::vector<double>>> stateVelocities = std::nullopt,
std::optional<std::string> segmentComment = std::nullopt);
/**
* @brief Write CK segments to a file
*
* Given orientations, angular velocities, times, target and reference frames, write data as a segment in a CK kernel.
*
* @param fileName path to file to write the segment to
* @param quats nx4 vector of orientations as quaternions
* @param times nx1 vector of times matching the number of quats
* @param bodyCode NAIF body code identifying the orientations belong to
* @param referenceFrame NAIF string for the reference frame the orientations are in
* @param segmentId Some ID to give the segment
* @param sclk path to S clock kernal to convert to and from ephemeris time
* @param lsk path to leap second kernal
* @param angularVelocity optional, nx3 array of angular velocities
* @param comment optional, comment to be associated with the segment
*/
void writeCk(std::string fileName,
std::vector<std::vector<double>> quats,
std::vector<double> times,
int bodyCode,
std::string referenceFrame,
std::string segmentId,
std::string sclk,
std::string lsk,
std::optional<std::vector<std::vector<double>>> angularVelocity = std::nullopt,
std::optional<std::string> comment= std::nullopt);
/**
* @brief Write CK segments to a file
*
* Given orientations, angular velocities, times, target and reference frames, write data as a segment in a CK kernel.
*
* @param fileName path to file to write the segment to
* @param sclk path to SCLK kernel matching the segments' frame code
* @param lsk path to LSK kernel
* @param segments spkSegments to be writte
*/
void writeCk(std::string fileName,
std::string sclk,
std::string lsk,
std::vector<CkSegment> segments);
/**
* @brief Write json key value pairs into a NAIF text kernel
*
* @param fileName pull path to the text kernel
* @param type kernel type string, valid text kernel types: FK, IK, LSK, MK, PCK, SCLK
* @param comment the comment to add to the top of the kernel
* @param keywords json object containing key/value pairs to write to the text kernel
*/
void writeTextKernel(std::string fileName, std::string type, nlohmann::json &keywords, std::optional<std::string> comment = std::nullopt);
}
|
gsn9/SugarSpice | SpiceQL/include/spice_types.h | #pragma once
/**
*
*
**/
#include <iostream>
#include <unordered_map>
#include <nlohmann/json.hpp>
/**
* @namespace SpiceQL types
*
*/
namespace SpiceQL {
/**
* @brief Base Kernel class
*
* This is mostly designed to enable the automatic unloading
* of kernels. The kernel is furnsh-ed on instantiation and
* unloaded in the destructor.
*
*/
class Kernel {
public:
/**
* @brief Enumeration representing the different possible kernel types
**/
enum class Type { NA=0,
CK, SPK, TSPK,
LSK, MK, SCLK,
IAK, IK, FK,
DSK, PCK, EK
};
/**
* @brief Enumeration representing the different possible kernel qualities
**/
enum class Quality {
PREDICTED = 1, // Based on predicted future location of the spacecraft/body
NADIR = 2, // Assumes Nadir pointing
RECONSTRUCTED = 3, // Supplemented by real spacecraft/body data
SMITHED = 4, // Controlled Kernels
NA = SMITHED // Either Quaility doesn't apply (e.g. text kernels) -or-
// we dont care about quality (e.g. CK of any quality)
};
/**
* used for converting string and int kernal quality
*/
static const std::vector<std::string> QUALITIES;
/**
* used for converting between string and int kernal types
*/
static const std::vector<std::string> TYPES;
/**
* @brief Switch between Kernel type enum to string
*
* @param type Kernel::Type to translate to a string
* @return String representation of the kernel type, eg. Kernel::Type::CK returns "ck"
**/
static std::string translateType(Type type);
/**
* @brief Switch between Kernel type string to enum
*
* @param type String to translate to a Kernel::Type, must be all lower case
* @return Kernel::Type representation of the kernel type, eg. "ck" returns Kernel::Type::CK
**/
static Type translateType(std::string type);
/**
* @brief Switch between Quality enum to string
*
* @param qa Kernel::Quality to translate to a string
* @return String representation of the kernel type, eg. Kernel::Quality::Reconstructed returns "reconstructed"
**/
static std::string translateQuality(Quality qa);
/**
* @brief Switch between Kernel quality string to enum
*
* @param qa String to translate to a Kernel::Quality, must be all lower case
* @return Kernel::Type representation of the kernel type, eg. "reconstructed" returns Kernel::Quality::Reconstructed
**/
static Quality translateQuality(std::string qa);
/**
* @brief Switch between NAIF frame string code to integer frame code
*
* See <a href="https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html">NAIF's Docs on frame codes</a> for more information
*
* @param frame String to translate to a NAIF code
* @return integer Naif frame code
**/
static int translateFrame(std::string frame);
/**
* @brief Switch between NAIF frame integer code to string frame code
*
* See <a href="https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html">NAIF's Docs on frame codes</a> for more information
*
* @param frame int NAIF frame code to translate
* @return Translated string frame code
**/
static std::string translateFrame(int frame);
/**
* @brief Instantiate a kernel from path
*
* Load a kernel into memory by opening the kernel and furnishing.
* This also increases the reference count of the kernel. If the kernel
* has alrady been furnished, it is refurnshed.
*
* @param path path to a kernel.
*
**/
Kernel(std::string path);
/**
* @brief Construct a new Kernel object from another
*
* Ensures the reference counter is incremented when a copy of
* the kernel is created
*
* @param other some other Kernel instance
*/
Kernel(Kernel &other);
/**
* @brief Delete the kernel object and decrease it's reference count
*
* Deletes the kernel object and decrements it's reference count. If the reference count hits 0,
* the kernel is unloaded.
*
**/
~Kernel();
/*! path to the kernel */
std::string path;
/*! type of kernel */
Type type;
/*! quality of the kernel */
Quality quality;
};
/**
* @brief typedef of std::shared_ptr<Kernel>
*
* This basically allows the Kernel to exist as a reference counted
* variable. Once all references to the Kernel cease to exist, the kernel
* is unloaded.
*/
typedef std::shared_ptr<Kernel> SharedKernel;
/**
* @brief typedef of std::unique_ptr<Kernel>
*
* This basically allows the Kernel to exist only within the
* call stack it is used in.
*
*/
typedef std::unique_ptr<Kernel> StackKernel;
/**
* @brief Singleton class for interacting with the cspice kernel pool
*
* Contains functions required to load and unload kernels and
* keep track of furnished kernels.
*/
class KernelPool {
public:
/**
* Delete constructors and such as this is a singleton
*/
KernelPool(KernelPool const &other) = delete;
void operator=(KernelPool const &other) = delete;
/**
* @brief Get the Ref Map object
*
* @return KernelRefMap&
*/
static KernelPool &getInstance();
/**
* @brief get a kernel's reference count
*
* Everytime KernelPool::load is called, the reference count is increased by one.
* This returns the number of Kernel objects currently referencing the
* input kernel.
*
* @param key key for the kernel to get the ref count for, usually the complete file path
* @return unsigned int The number of references to the input kernel. If key doesn't exist, this is 0.
*/
unsigned int getRefCount(std::string key);
/**
* @brief get reference counts for all kernels in the pool
*
* Everytime KernelPool::load is called, the reference count is increased by one.
* This returns the number of Kernel objects referencing every Kernel in the pool.
*
* @return std::map<std::string, int> Map of kernel path to reference count.
*/
std::unordered_map<std::string, int> getRefCounts();
/**
* @brief Get the list of Loaded Kernels.
*
* @return std::vector<std::string> list of loaded kernels.
*/
std::vector<std::string> getLoadedKernels();
/**
* @brief load kernel into the kernel pool
*
* This should be called for furnshing kernel instead of furnsh_c directly
* so that they are tracked throughout the process.
*
* @param kernelPath Path to the kernel to load
* @param force_refurnsh If true, call furnsh on the kernel even if the kernel is already in the pool. Default is True.
*/
int load(std::string kernelPath, bool force_refurnsh=true);
/**
* @brief reduce the reference count for a kernel
*
* This reduces the ref count by one, and if the ref count hits 0,
* the kernel is unfurnished. Use this instead of calling unload_c
* directly as you cause errors from desyncs.
*
* @param kernelPath path to the kernel
*/
int unload(std::string kernelPath);
/**
* @brief load SCLKs
*
* Any SCLKs in the data area are furnished.
*/
void loadClockKernels();
private:
/**
* @brief load leapsecond kernels
*
* Load the LSK distributed with SpiceQL
*
*/
void loadLeapSecondKernel();
//! Default constructor, default implentation. Singletons shouldn't be constructed from anywhere
//! other than the getInstance() function.
KernelPool();
~KernelPool() = default;
//! map for tracking what kernels have been furnished and how often.
std::unordered_map<std::string, int> refCounts;
};
/**
* @brief Class for furnishing kernels in bulk
*
* Given a json object, furnish every kernel under a
* "kernels" key. The kernels are unloaded as soon as the object
* goes out of scope.
*
* Generally used on results from a kernel query.
*/
class KernelSet {
public:
/**
* @brief Construct a new Kernel Set object
*
* @param kernels
*/
KernelSet(nlohmann::json kernels);
~KernelSet() = default;
//! map of path to kernel pointers
std::unordered_map<std::string, std::vector<SharedKernel>> loadedKernels;
//! json used to populate the loadedKernels
nlohmann::json kernels;
};
/**
* @brief convert a UTC string to an ephemeris time
*
* Basically a wrapper around NAIF's cspice str2et function except it also temporarily loads the required kernels.
* See Also: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html
*
* @param et UTC string, e.g. "1988 June 13, 12:29:48 TDB"
* @returns double precision ephemeris time
**/
double utcToEt(std::string et);
}
|
michaelyhuang23/ParGeo | include/kdTree/knnImpl.h | // This code is part of the project "ParGeo: A Library for Parallel Computational Geometry"
// Copyright (c) 2021-2022 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights (to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include <limits>
#include <algorithm>
#include "parlay/parallel.h"
#include "parlay/sequence.h"
#include "kdTree.h"
#include "pargeo/point.h"
namespace pargeo::kdTree
{
namespace knnBuf
{
typedef int intT;
typedef double floatT;
template <typename T>
struct elem
{
floatT cost; // Non-negative
T entry;
elem(floatT t_cost, T t_entry) : cost(t_cost), entry(t_entry) {}
elem() : cost(std::numeric_limits<floatT>::max()) {}
bool operator<(const elem &b) const
{
if (cost < b.cost)
return true;
return false;
}
};
template <typename T>
struct buffer
{
typedef parlay::slice<elem<T> *, elem<T> *> sliceT;
intT k;
intT ptr;
sliceT buf;
buffer(intT t_k, sliceT t_buf) : k(t_k), ptr(0), buf(t_buf) {}
inline void reset() { ptr = 0; }
bool hasK() { return ptr >= k; }
elem<T> keepK()
{
if (ptr < k)
throw std::runtime_error("Error, kbuffer not enough k.");
ptr = k;
std::nth_element(buf.begin(), buf.begin() + k - 1, buf.end());
return buf[k - 1];
}
void sort()
{ // todo check
if (ptr < k)
throw std::runtime_error("Error, sorting kbuffer without enough k.");
parlay::sort(buf.cut(0, k));
}
void insert(elem<T> t_elem)
{
buf[ptr++] = t_elem;
if (ptr >= buf.size())
keepK();
}
elem<T> operator[](intT i)
{
if (i < ptr)
return buf[i];
else
return elem<T>();
}
};
}
template <int dim, typename nodeT, typename objT>
void knnRangeHelper(nodeT *tree, objT &q, point<dim> qMin, point<dim> qMax,
double radius, knnBuf::buffer<objT *> &out)
{
int relation = tree->boxCompare(qMin, qMax, tree->getMin(), tree->getMax());
if (relation == tree->boxExclude)
{
return;
}
else if (relation == tree->boxInclude)
{
for (size_t i = 0; i < tree->size(); ++i)
{
objT *p = tree->getItem(i);
out.insert(knnBuf::elem(q.dist(*p), p));
}
}
else
{ // intersect
if (tree->isLeaf())
{
for (size_t i = 0; i < tree->size(); ++i)
{
objT *p = tree->getItem(i);
double dist = q.dist(*p);
if (dist <= radius)
{
out.insert(knnBuf::elem(dist, p));
}
}
}
else
{
knnRangeHelper<dim, nodeT, objT>(tree->L(), q, qMin, qMax, radius, out);
knnRangeHelper<dim, nodeT, objT>(tree->R(), q, qMin, qMax, radius, out);
}
}
}
template <int dim, typename nodeT, typename objT>
void knnRange(nodeT *tree, objT &q, double radius, knnBuf::buffer<objT *> &out)
{
point<dim> qMin, qMax;
for (size_t i = 0; i < dim; i++)
{
auto tmp = q[i] - radius;
qMin[i] = tmp;
qMax[i] = tmp + radius * 2;
}
knnRangeHelper<dim, nodeT, objT>(tree, q, qMin, qMax, radius, out);
}
template <int dim, typename nodeT, typename objT>
void knnHelper(nodeT *tree, objT &q, knnBuf::buffer<objT *> &out)
{
// find the leaf first
int relation = tree->boxCompare(tree->getMin(), tree->getMax(),
point<dim>(q.coords()),
point<dim>(q.coords()));
if (relation == tree->boxExclude)
{
return;
}
else
{
if (tree->isLeaf())
{
// basecase
for (size_t i = 0; i < tree->size(); ++i)
{
objT *p = tree->getItem(i);
out.insert(knnBuf::elem(q.dist(*p), p));
}
}
else
{
knnHelper<dim, nodeT, objT>(tree->L(), q, out);
knnHelper<dim, nodeT, objT>(tree->R(), q, out);
}
}
if (!out.hasK())
{
if (tree->siblin() == NULL)
{
throw std::runtime_error("Error, knnHelper reached root node without enough neighbors.");
}
for (size_t i = 0; i < tree->siblin()->size(); ++i)
{
objT *p = tree->siblin()->getItem(i);
out.insert(knnBuf::elem(q.dist(*p), p));
}
}
else
{ // Buffer filled to a least k
if (tree->siblin() != NULL)
{
knnBuf::elem tmp = out.keepK();
knnRange<dim, nodeT, objT>(tree->siblin(), q, tmp.cost, out);
}
}
}
template <int dim, class objT>
parlay::sequence<size_t> batchKnn(parlay::sequence<objT> &queries,
size_t k,
node<dim, objT> *tree,
bool sorted)
{
using nodeT = node<dim, objT>;
bool freeTree = false;
if (!tree)
{
freeTree = true;
tree = build<dim, objT>(queries, true);
}
auto out = parlay::sequence<knnBuf::elem<objT *>>(2 * k * queries.size());
auto idx = parlay::sequence<size_t>(k * queries.size());
parlay::parallel_for(0, queries.size(), [&](size_t i)
{
knnBuf::buffer buf = knnBuf::buffer<objT *>(k, out.cut(i * 2 * k, (i + 1) * 2 * k));
knnHelper<dim, nodeT, objT>(tree, queries[i], buf);
buf.keepK();
if (sorted)
buf.sort();
for (size_t j = 0; j < k; ++j)
{
idx[i * k + j] = buf[j].entry - queries.data();
}
});
if (freeTree)
free(tree);
return idx;
}
template <int dim, typename objT>
parlay::sequence<size_t> bruteforceKnn(parlay::sequence<objT> &queries, size_t k)
{
auto out = parlay::sequence<knnBuf::elem<objT *>>(2 * k * queries.size());
auto idx = parlay::sequence<size_t>(k * queries.size());
parlay::parallel_for(0, queries.size(), [&](size_t i)
{
objT q = queries[i];
knnBuf::buffer buf = knnBuf::buffer<objT *>(k, out.cut(i * 2 * k, (i + 1) * 2 * k));
for (size_t j = 0; j < queries.size(); ++j)
{
objT *p = &queries[j];
buf.insert(elem(q.dist(p), p));
}
buf.keepK();
for (size_t j = 0; j < k; ++j)
{
idx[i * k + j] = buf[j].entry - queries.data();
}
});
return idx;
}
} // End namespace pargeo
|
michaelyhuang23/ParGeo | include/pargeo/atomics.h | // This file is part of pbbsbench
#pragma once
namespace pargeo {
template <typename ET>
inline bool atomic_compare_and_swap(ET* a, ET oldval, ET newval) {
static_assert(sizeof(ET) <= 8, "Bad CAS length");
if (sizeof(ET) == 1) {
uint8_t r_oval, r_nval;
std::memcpy(&r_oval, &oldval, sizeof(ET));
std::memcpy(&r_nval, &newval, sizeof(ET));
return __sync_bool_compare_and_swap(reinterpret_cast<uint8_t*>(a), r_oval, r_nval);
} else if (sizeof(ET) == 4) {
uint32_t r_oval, r_nval;
std::memcpy(&r_oval, &oldval, sizeof(ET));
std::memcpy(&r_nval, &newval, sizeof(ET));
return __sync_bool_compare_and_swap(reinterpret_cast<uint32_t*>(a), r_oval, r_nval);
} else { // if (sizeof(ET) == 8) {
uint64_t r_oval, r_nval;
std::memcpy(&r_oval, &oldval, sizeof(ET));
std::memcpy(&r_nval, &newval, sizeof(ET));
return __sync_bool_compare_and_swap(reinterpret_cast<uint64_t*>(a), r_oval, r_nval);
}
}
template <typename E, typename EV>
inline E fetch_and_add(E *a, EV b) {
volatile E newV, oldV;
do {oldV = *a; newV = oldV + b;}
while (!atomic_compare_and_swap(a, oldV, newV));
return oldV;
}
template <typename E, typename EV>
inline void write_add(E *a, EV b) {
//volatile E newV, oldV;
E newV, oldV;
do {oldV = *a; newV = oldV + b;}
while (!atomic_compare_and_swap(a, oldV, newV));
}
template <typename E, typename EV>
inline void write_add(std::atomic<E> *a, EV b) {
//volatile E newV, oldV;
E newV, oldV;
do {oldV = a->load(); newV = oldV + b;}
while (!std::atomic_compare_exchange_strong(a, &oldV, newV));
}
template <typename ET, typename BT, typename F>
inline void write_min_and(ET *a, ET b, BT *c, BT d, F less) {
// if b < *a, set *a = b, and *c = d
ET t; BT tt;
do {t = *a; tt = *c;}
while (less(b,t) && !atomic_compare_and_swap(a,t,b) && !atomic_compare_and_swap(c,tt,d));
}
template <typename ET, typename BT, typename F>
inline void write_max_and(ET *a, ET b, BT *c, BT d, F less) {
// if b > *a, set *a = b, and *c = d
ET t; BT tt;
do {t = *a; tt = *c;}
while (less(t,b) && !atomic_compare_and_swap(a,t,b) && !atomic_compare_and_swap(c,tt,d));
}
template <typename ET, typename F>
inline bool write_min(ET *a, ET b, F less) {
ET c; bool r=0;
do c = *a;
while (less(b,c) && !(r=atomic_compare_and_swap(a,c,b)));
return r;
}
template <typename ET, typename F>
inline bool write_min(std::atomic<ET> *a, ET b, F less) {
ET c; bool r=0;
do c = a->load();
while (less(b,c) && !(r=std::atomic_compare_exchange_strong(a, &c, b)));
return r;
}
template <typename ET, typename F>
inline bool write_max(ET *a, ET b, F less) {
ET c; bool r=0;
do c = *a;
while (less(c,b) && !(r=atomic_compare_and_swap(a,c,b)));
return r;
}
template <typename ET, typename F>
inline bool write_max(std::atomic<ET> *a, ET b, F less) {
ET c; bool r=0;
do c = a->load();
while (less(c,b) && !(r=std::atomic_compare_exchange_strong(a, &c, b)));
return r;
}
} // End namespace pargeo
|
michaelyhuang23/ParGeo | include/pseudoDynamicKdTree/pdKnnImpl.h | // This code is part of the project "ParGeo: A Library for Parallel Computational Geometry"
// Copyright (c) 2021-2022 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights (to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include <limits>
#include <algorithm>
#include "parlay/parallel.h"
#include "parlay/sequence.h"
#include "pdKdTree.h"
#include "pargeo/point.h"
#include "pargeo/atomics.h"
namespace pargeo::pdKdTree
{
template <int dim, typename nodeT, typename objT>
void knnRange(nodeT *tree, objT &q, double &radius, objT *&out);
template <int dim, typename nodeT, typename objT>
void knnRangeHelper(nodeT *tree, objT &q, objT qMin, objT qMax, double &radius, objT *&out);
template <int dim, typename nodeT, typename objT>
void knnRangeHelper(nodeT *tree, objT &q, objT qMin, objT qMax,
double &radius, objT *&out)
{
int relation = tree->boxCompare(qMin, qMax, tree->getMin(), tree->getMax());
if (relation == tree->boxExclude || tree->empty())
{
return;
}
else if (relation == tree->boxInclude) // first includes second, target region includes tree region
{ // use threshold to decide going down vs bruteforce
if (tree->isLeaf())
{
for(size_t i=0; i<tree->size(); ++i)
{
objT *p = tree->getItem(i);
if(p)
{
double dist = q.dist(*p);
if(dist < radius)
{
radius = dist;
out = p;
}
}
}
}
else
{
knnRangeHelper<dim, nodeT, objT>(tree->L(), q, qMin, qMax, radius, out);
knnRange<dim, nodeT, objT>(tree->R(), q, radius, out);
}
}
else
{ // intersect
if (tree->isLeaf())
{
for(size_t i=0; i<tree->size(); ++i)
{
objT *p = tree->getItem(i);
if(p)
{
double dist = q.dist(*p);
if(dist < radius)
{
radius = dist;
out = p;
}
}
}
}
else
{
knnRangeHelper<dim, nodeT, objT>(tree->L(), q, qMin, qMax, radius, out);
knnRange<dim, nodeT, objT>(tree->R(), q, radius, out);
}
}
}
template <int dim, typename nodeT, typename objT>
void knnRange(nodeT *tree, objT &q, double &radius, objT *&out)
{
objT qMin, qMax;
for (size_t i = 0; i < dim; i++)
{
auto tmp = q[i] - radius;
qMin[i] = tmp;
qMax[i] = tmp + radius * 2;
}
knnRangeHelper<dim, nodeT, objT>(tree, q, qMin, qMax, radius, out);
}
template <int dim, class objT>
objT* tree<dim, objT>::NearestNeighbor(size_t id)
{
typedef node<dim, objT> nodeT;
int loc = id2loc->at(id);
objT q = *(allItems->at(loc));
nodeT* cur = allItemLeaf->at(loc);
double radius = std::numeric_limits<double>::max()/2;
objT* out = NULL;
if(!cur->empty()){
for (size_t i = 0; i < cur->size(); ++i){
objT *p = cur->getItem(i);
if(p)
{
double dist = q.dist(*p);
if(dist < radius)
{
radius = dist;
out = p;
}
}
}
}
for( ; cur->siblin() != NULL; cur = cur->parent()){
if(!cur->siblin()->empty()){
knnRange<dim, nodeT, objT>(cur->siblin(), q, radius, out);
}
}
return out;
}
} // End namespace pargeo
|
michaelyhuang23/ParGeo | include/dynamicKdTree/dynKdTree.h | #pragma once
#include <algorithm>
#include <math.h>
#include <queue>
#include <iostream>
#include <vector>
#include "parlay/parallel.h"
#include "parlay/sequence.h"
template <typename T>
using container = parlay::sequence<T>;
namespace pargeo {
namespace dynKdTree {
static const bool spatialMedian = true;
template <typename In_Seq, typename Bool_Seq>
size_t split_two(In_Seq const &In, Bool_Seq const &Fl, parlay::flags fl = parlay::no_flag) {
using namespace parlay;
using namespace parlay::internal;
using T = typename In_Seq::value_type;
size_t n = In.size();
size_t l = num_blocks(n, _block_size);
sequence<size_t> Sums(l);
sliced_for(n, _block_size,
[&](size_t i, size_t s, size_t e) {
size_t c = 0;
for (size_t j = s; j < e; j++) c += (Fl[j] == false);
Sums[i] = c;
},
fl);
size_t m = scan_inplace(make_slice(Sums), addm<size_t>());
sequence<T> Out = sequence<T>::uninitialized(n);
sliced_for(n, _block_size,
[&](size_t i, size_t s, size_t e) {
size_t c0 = Sums[i];
size_t c1 = s + (m - c0);
for (size_t j = s; j < e; j++) {
if (Fl[j] == false)
assign_uninitialized(Out[c0++], In[j]);
else
assign_uninitialized(Out[c1++], In[j]);
}
},
fl);
//return std::make_pair(std::move(Out), m);
parallel_for(0, n, [&](size_t i) {
In[i] = Out[i];
});
return m;
}
template<int dim, typename _floatT = double>
class coordinate {
protected:
_floatT data[dim];
public:
typedef _floatT floatT;
coordinate(const _floatT* _data) {
for (int i = 0; i < dim; ++ i) data[i] = _data[i];
}
template<typename T>
coordinate(T& _data) {
for (int i = 0; i < dim; ++ i) data[i] = _data[i];
}
coordinate() { }
_floatT& operator[](int i) {
return data[i];
}
template<typename T>
_floatT& dist(T other) {
_floatT total = 0.0;
for (int i = 0; i < dim; ++ i) {
_floatT tmp = abs(other[i] - data[i]);
total += tmp * tmp;
}
return sqrt(total);
}
};
template<int dim> class boundingBox {
private:
coordinate<dim> minCoords, maxCoords;
public:
enum relation { exclude, include, overlap };
coordinate<dim> getMin() { return minCoords; }
coordinate<dim> getMax() { return maxCoords; }
void setMin(int i, typename coordinate<dim>::floatT val) { minCoords[i] = val; }
void setMax(int i, typename coordinate<dim>::floatT val) { maxCoords[i] = val; }
boundingBox() {
for (int i = 0; i < dim; ++ i) {
minCoords[i] = 0;
maxCoords[i] = 0;
}
};
template<typename T>
boundingBox(container<T>& _input, int s = -1, int e = -1) {
if (s < 0 || e < 0) {
s = 0;
e = _input.size();
}
if ((e - s) < 1) return;
minCoords = coordinate<dim>(_input[s]);
maxCoords = coordinate<dim>(_input[s]);
for (int j = s; j < e; ++ j) {
T p = _input[j];
for (int i = 0; i < dim; ++ i) {
minCoords[i] = std::min(p[i], minCoords[i]);
maxCoords[i] = std::max(p[i], maxCoords[i]);
}
}
}
template<typename T>
void update(T p) {
for (int i = 0; i < dim; ++ i) {
minCoords[i] = std::min(p[i], minCoords[i]);
maxCoords[i] = std::max(p[i], maxCoords[i]);
}
}
template <typename T>
bool contains(T x) {
for (int i = 0; i < dim; ++ i) {
if (x[i] < minCoords[i]) return false;
if (x[i] > maxCoords[i]) return false;
}
return true;
}
~boundingBox() {
}
relation compare(boundingBox other) {
bool exc = false;
bool inc = true;
for (int i = 0; i < dim; ++ i) {
if (maxCoords[i] < other.minCoords[i] || minCoords[i] > other.maxCoords[i])
exc = true;
if (maxCoords[i] < other.maxCoords[i] || minCoords[i] > other.minCoords[i])
inc = false;
}
if (exc) return exclude;
else if (inc) return include;
else return overlap;
}
};
template <typename T, typename _floatT = double>
class kBuffer: public std::priority_queue<std::pair<_floatT, T>> {
using queueT = std::priority_queue<std::pair<_floatT, T>>;
private:
int k;
public:
kBuffer(int _k): queueT(), k(_k) { };
void insertK(std::pair<_floatT, T> elem) {
queueT::push(elem);
if (queueT::size() > k) queueT::pop();
};
std::pair<_floatT, T> getK() {
return queueT::top();
}
bool hasK() { return queueT::size() >= k; }
};
// template <typename T, typename _floatT = double>
// class kBuffer {
// private:
// int k;
// int writePt;
// std::vector<std::pair<_floatT, T>> A;
// public:
// kBuffer(int _k): k(_k), writePt(0) {
// A = std::vector<std::pair<_floatT, T>>(k + 1);
// };
// void insertK(std::pair<_floatT, T> elem) {
// A[writePt ++] = elem;
// if (writePt >= k + 1) {
// std::nth_element(A.begin(), A.begin() + k, A.end());
// writePt --;
// }
// };
// std::pair<_floatT, T> getK() {
// return A[k - 1];
// }
// bool hasK() { return writePt >= k; }
// int size() { return writePt; }
// std::pair<_floatT, T> top() {
// return A[writePt - 1];
// }
// void pop() { writePt --; }
// void sort() {
// std::sort(A.begin(), A.begin() + k);
// }
// };
template<int dim, typename T, typename _floatT = double>
class baseNode {
protected:
boundingBox<dim> box;
static const int threshold = 16; // for splitting
public:
using floatT = _floatT;
boundingBox<dim>& getBox() { return box; }
virtual void setSiblin(baseNode* _siblin) = 0;
virtual baseNode<dim, T>* getSiblin() = 0;
virtual bool isRoot() = 0;
virtual int size() = 0;
baseNode() { };
virtual ~baseNode() { };
virtual baseNode* insert(container<T>& _input, int s = -1, int e = -1) = 0;
virtual int erase(container<T>& _input, int s = -1, int e = -1) = 0;
virtual bool check() = 0;
virtual void iterate(std::function<void(T)> func) = 0;
virtual void kNNHelper(T query, kBuffer<T>& buffer) = 0;
virtual void kNNRangeHelper(T query,
floatT radius,
boundingBox<dim> bb,
kBuffer<T>& buffer) = 0;
void kNNRange(T query,
floatT radius,
kBuffer<T>& buffer) {
boundingBox<dim> bb;
for (int i = 0; i < dim; ++ i) {
bb.setMin(i, query[i] - radius);
bb.setMax(i, query[i] + radius);
}
kNNRangeHelper(query, radius, bb, buffer);
}
};
template<int dim, typename T> class internalNode;
template<int dim, typename T>
class dataNode: public baseNode<dim, T> { // leaf node
private:
baseNode<dim, T>* siblin;
container<T> data;
container<char> flag;
int n;
public:
int size() { return n; }
void setSiblin(baseNode<dim, T>* _siblin) { siblin = _siblin; }
baseNode<dim, T>* getSiblin() { return siblin; }
bool isRoot() { return false; }
dataNode(container<T>& _input, int s = -1, int e = -1) {
if (s < 0 || e < 0) {
s = 0;
e = _input.size();
}
n = e - s;
baseNode<dim, T>::box = boundingBox<dim>(_input, s, e);
data = container<T>(n);
flag = container<char>(n);
int j = 0;
for (int i = s; i < e; ++ i) {
data[j] = _input[i];
flag[j] = 1;
j++;
}
}
baseNode<dim, T>* insert(container<T>& _input, int s = -1, int e = -1) {
if (s < 0 || e < 0) {
s = 0;
e = _input.size();
}
if (e - s + size() >= baseNode<dim, T>::threshold) {
container<T> tmp(e - s + size());
int i = 0;
for (int j = s; j < e; ++ j) tmp[i++] = _input[j];
iterate([&](T p) { tmp[i++] = p; });
internalNode<dim, T>* newNode = new internalNode<dim, T>(tmp);
return newNode;
} else {
for (int i = s; i < e; ++ i) {
baseNode<dim, T>::box.update(_input[i]);
data.push_back(_input[i]);
flag.push_back(1);
}
n += e - s;
return nullptr;
}
}
int erase(container<T>& _input, int s = -1, int e = -1) {
if (s < 0 || e < 0) {
s = 0;
e = _input.size();
}
if (e - s <= 0) return 0;
int erased = 0;
for (int i = s; i < e; ++ i) {
for (int j = 0; j < data.size(); ++ j) {
int k = 0;
for (; k < dim; ++ k) {
if (data[j][k] != _input[i][k]) {
break;
}
}
if (k == dim) {
flag[j] = 0;
erased ++;
}
}
}
n -= erased;
return erased;
}
void iterate(std::function<void(T)> func) {
int i = 0;
for (auto exist: flag) {
if (exist) func(data[i]);
i++;
}
}
void kNNHelper(T query,
kBuffer<T>& buffer) {
iterate([&](T x) { buffer.insertK({query.dist(x), x}); });
if (buffer.hasK()) {
siblin->kNNRange(query, buffer.getK().first, buffer);
} else {
siblin->iterate([&](T x) { buffer.insertK({query.dist(x), x}); });
}
}
void kNNRangeHelper(T query,
typename baseNode<dim, T>::floatT radius,
boundingBox<dim> bb,
kBuffer<T>& buffer) {
iterate([&](T x) {
typename baseNode<dim, T>::floatT d = query.dist(x);
if (d <= radius)
buffer.insertK({d, x});
});
}
bool check() {
for (auto x: data) {
if (!baseNode<dim, T>::box.contains(x)) return false;
}
return true;
}
};
template<int dim, typename T>
class internalNode: public baseNode<dim, T> { // internal node
protected:
baseNode<dim, T>* siblin;
baseNode<dim, T>* left = nullptr;
baseNode<dim, T>* right = nullptr;
int splitDim = -1;
typename baseNode<dim, T>::floatT split = -1;
int n;
public:
int size() { return n; }
bool isRoot() { return false; }
void setSiblin(baseNode<dim, T>* _siblin) { siblin = _siblin; }
baseNode<dim, T>* getSiblin() { return siblin; }
internalNode(container<T>& _input, int s = -1, int e = -1, int _splitDim = 0):
splitDim(_splitDim) {
if (s < 0 || e < 0) {
s = 0;
e = _input.size();
}
n = e - s;
if (n < 2)
throw std::runtime_error("dynKdTree: error, construction requires input size >= 2.");
baseNode<dim, T>::box = boundingBox<dim>(_input, s, e);
int leftSize;
if (spatialMedian) {
split = (baseNode<dim, T>::box.getMax()[splitDim] +
baseNode<dim, T>::box.getMin()[splitDim]) / 2;
if (e - s < 2000) {
auto middle = std::partition(_input.begin() + s, _input.begin() + e, [&](T& elem) {
return elem[splitDim] < split;
});
leftSize = std::distance(_input.begin(), middle) - s;
} else {
parlay::sequence<bool> flag(e - s);
parlay::parallel_for(0, e - s, [&](size_t i) {
flag[i] = _input[s + i][splitDim] >= split;
});
leftSize = split_two(_input.cut(s, e), flag);
}
if (leftSize == 0 || leftSize == n) {
splitDim = (splitDim + 1) % dim;
goto computeObjectMedian;
}
} else {
computeObjectMedian:
if (n < 2000) {
std::nth_element(_input.begin() + s,
_input.begin() + s + (e - s) / 2,
_input.begin() + e,
[&](T& a, T& b){
return a[splitDim] < b[splitDim];
});
} else {
parlay::sort_inplace(_input.cut(s, e), [&](T a, T b){
return a[splitDim] < b[splitDim];
});
}
split = _input[s + (e - s) / 2][splitDim];
leftSize = s + (e - s) / 2 - s;
}
if (leftSize < baseNode<dim, T>::threshold) {
left = new dataNode<dim, T>(_input, s, s + leftSize);
} else {
left = new internalNode(_input, s, s + leftSize, (splitDim + 1) % dim);
}
int rightSize = e - s - leftSize;;
if (rightSize < baseNode<dim, T>::threshold) {
right = new dataNode<dim, T>(_input, s + leftSize, e);
} else {
right = new internalNode(_input, s + leftSize, e, (splitDim + 1) % dim);
}
left->setSiblin(right);
right->setSiblin(left);
}
baseNode<dim, T>* insert(container<T>& _input, int s = -1, int e = -1) {
if (s < 0 || e < 0) {
s = 0;
e = _input.size();
}
n += e - s;
for (int i = s; i < e; ++ i) {
baseNode<dim, T>::box.update(_input[i]);
}
int middleIdx;
if (e - s < 2000) {
auto middle = std::partition(_input.begin() + s, _input.begin() + e, [&](T& elem) {
return elem[splitDim] < split;
});
middleIdx = std::distance(_input.begin(), middle);
} else {
parlay::sequence<bool> flag(e - s);
parlay::parallel_for(0, e - s, [&](size_t i) {
flag[i] = _input[s + i][splitDim] >= split;
});
middleIdx = s + split_two(_input.cut(s, e), flag);
}
auto insertLeft = [&] () {
auto newLeft = left->insert(_input, s, middleIdx);
if (newLeft) {
delete left;
left = newLeft;
left->setSiblin(right);
right->setSiblin(left);
}
};
auto insertRight = [&] () {
auto newRight = right->insert(_input, middleIdx, e);
if (newRight) {
delete right;
right = newRight;
left->setSiblin(right);
right->setSiblin(left);
}
};
if (e - s < 2000) {
insertLeft();
insertRight();
} else parlay::par_do(insertLeft, insertRight);
return nullptr;
}
int erase(container<T>& _input, int s = -1, int e = -1) {
if (s < 0 || e < 0) {
s = 0;
e = _input.size();
}
if (e - s <= 0) return 0;
int middleIdx;
if (e - s < 2000) {
auto middle = std::partition(_input.begin() + s, _input.begin() + e, [&](T& elem) {
return elem[splitDim] < split;
});
middleIdx = std::distance(_input.begin(), middle);
} else {
parlay::sequence<bool> flag(e - s);
parlay::parallel_for(0, e - s, [&](size_t i) {
flag[i] = _input[s + i][splitDim] >= split;
});
middleIdx = s + split_two(_input.cut(s, e), flag);
}
int leftErased, rightErased;
auto eraseLeft = [&] () {
leftErased = left->erase(_input, s, middleIdx);
};
auto eraseRight = [&] () {
rightErased = right->erase(_input, middleIdx, e);
};
if (e - s < 2000) {
eraseLeft();
eraseRight();
} else parlay::par_do(eraseLeft, eraseRight);
n -= leftErased + rightErased;
return leftErased + rightErased;
}
~internalNode() {
delete left;
delete right;
}
void iterate(std::function<void(T)> func) {
left->iterate(func);
right->iterate(func);
}
void kNNHelper(T query,
kBuffer<T>& buffer) {
if (query[splitDim] < split) left->kNNHelper(query, buffer);
else right->kNNHelper(query, buffer);
if (buffer.hasK()) {
siblin->kNNRange(query, buffer.getK().first, buffer);
} else {
siblin->iterate([&](T x) { buffer.insertK({query.dist(x), x}); });
}
}
void kNNRangeHelper(T query,
typename baseNode<dim, T>::floatT radius,
boundingBox<dim> bb,
kBuffer<T>& buffer) {
typename boundingBox<dim>::relation rel = bb.compare(baseNode<dim, T>::box);
if (rel == boundingBox<dim>::relation::include) {
iterate([&](T x) {
typename baseNode<dim, T>::floatT d = query.dist(x);
if (d <= radius)
buffer.insertK({d, x});
});
} else if (rel == boundingBox<dim>::relation::overlap) {
left->kNNRangeHelper(query, radius, bb, buffer);
right->kNNRangeHelper(query, radius, bb, buffer);
}
}
bool check() {
if (left->getSiblin() != right) return false;
if (right->getSiblin() != left) return false;
boundingBox<dim> leftBox = left->getBox();
boundingBox<dim> rightBox = right->getBox();
if (!baseNode<dim, T>::box.contains(leftBox.getMin()) ||
!baseNode<dim, T>::box.contains(leftBox.getMax())) {
return false;
}
return left->check() && right->check();
}
};
template<int dim, typename T>
class rootNode: public internalNode<dim, T> { // root node
public:
baseNode<dim, T>* getSiblin() {
throw std::runtime_error("dynKdTree: error, cannot get siblin of root\n");
}
bool isRoot() { return true; }
void iterate(std::function<void(T)> func) {
internalNode<dim, T>::left->iterate(func);
internalNode<dim, T>::right->iterate(func);
}
void kNNHelper(T query,
kBuffer<T>& buffer) {
if (query[internalNode<dim, T>::splitDim] < internalNode<dim, T>::split)
internalNode<dim, T>::left->kNNHelper(query, buffer);
else
internalNode<dim, T>::right->kNNHelper(query, buffer);
}
rootNode(container<T>& _input, int s = -1, int e = -1, int _splitDim = 0):
internalNode<dim, T>(_input, s, e, _splitDim) { };
container<T> kNN(T query, int k) {
kBuffer<T> buffer(k);
kNNHelper(query, buffer);
int kOut = buffer.size();
if (kOut < k) {
std::cout << "dynKdTree: warning, kNN outputs ";
std::cout << kOut << ", fewer than k.\n";
}
auto nns = container<T>(kOut);
// buffer.sort();
for (int i = 0; i < kOut; ++ i) {
nns[kOut - 1 - i] = buffer.top().second;
buffer.pop();
}
return nns;
}
};
}; // End namespace dynKdTree
}; // End namespace pargeo
|
michaelyhuang23/ParGeo | include/pseudoDynamicKdTree/pdKdTree.h | // This code is part of the project "ParGeo: A Library for Parallel Computational Geometry"
// Copyright (c) 2021-2022 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights (to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include "parlay/sequence.h"
#include "pargeo/point.h"
#include <tuple>
namespace pargeo::pdKdTree
{
/* Kd-tree node */
template <int _dim, class _objT>
class node;
/********* Implementations *********/
template <int _dim, class _objT>
class tree : public node<_dim, _objT>
{
private:
using baseT = node<_dim, _objT>;
parlay::sequence<_objT *> *allItems;
parlay::sequence<bool> *allItemActive;
parlay::sequence<int> *id2loc;
parlay::sequence<baseT *> *allItemLeaf;
node<_dim, _objT> *space;
public:
tree(parlay::slice<_objT *, _objT *> _items,
typename baseT::intT leafSize = 16)
{
typedef tree<_dim, _objT> treeT;
typedef node<_dim, _objT> nodeT;
// allocate space for children
space = (nodeT *)malloc(sizeof(nodeT) * (2 * _items.size() - 1));
// allocate space for a copy of the items
allItems = new parlay::sequence<_objT *>(_items.size());
allItemActive = new parlay::sequence<bool>(_items.size(),false);
allItemLeaf = new parlay::sequence<nodeT *>(_items.size(),NULL);
id2loc = new parlay::sequence<int>(_items.size());
for (size_t i = 0; i < _items.size(); ++i){
allItems->at(i) = &_items[i];
allItems->at(i)->attribute = i;
}
// construct self
baseT::items = allItems->cut(0, allItems->size());
baseT::itemActive = allItemActive->cut(0, allItemActive->size());
baseT::itemLeaf = allItemLeaf->cut(0, allItemLeaf->size());
baseT::resetId();
baseT::constructSerial(space, leafSize);
for (size_t i=0; i < _items.size(); ++i)
id2loc->at(allItems->at(i)->attribute) = i;
}
tree(parlay::slice<_objT *, _objT *> _items,
parlay::slice<bool *, bool *> flags,
typename baseT::intT leafSize = 16)
{
typedef tree<_dim, _objT> treeT;
typedef node<_dim, _objT> nodeT;
// allocate space for children
space = (nodeT *)malloc(sizeof(nodeT) * (2 * _items.size() - 1));
// allocate space for a copy of the items
allItems = new parlay::sequence<_objT *>(_items.size());
allItemActive = new parlay::sequence<bool>(_items.size(),false);
allItemLeaf = new parlay::sequence<nodeT *>(_items.size());
id2loc = new parlay::sequence<int>(_items.size());
parlay::parallel_for(0, _items.size(), [&](size_t i)
{
allItems->at(i) = &_items[i];
allItems->at(i)->attribute = i;
});
// construct self
baseT::items = allItems->cut(0, allItems->size());
baseT::itemActive = allItemActive->cut(0, allItemActive->size());
baseT::itemLeaf = allItemLeaf->cut(0, allItemLeaf->size());
baseT::resetId();
if (baseT::size() > 2000)
baseT::constructParallel(space, flags, leafSize);
else
baseT::constructSerial(space, leafSize);
parlay::parallel_for(0, _items.size(), [&](size_t i){
id2loc->at(allItems->at(i)->attribute) = i;
});
}
~tree()
{
free(space);
delete allItems;
delete allItemActive;
delete allItemLeaf;
delete id2loc;
}
inline void activateItem(int idx){
int loc = id2loc->at(idx);
allItemActive->at(loc) = true;
baseT* cur = allItemLeaf->at(loc);
for( ; cur != NULL; cur = cur->parent()){
cur->activate();
}
}
void activateRange(int st, int ed){
if(ed - st < 100){
for(int i=st; i<ed; i++)
activateItem(i);
}else{
parallel_for(st, ed, [&](int i){
activateItem(i);
});
}
}
_objT* NearestNeighbor(size_t id);
void print_data(){
for(size_t i=0;i<allItems->size();i++){
std::cout<<allItems->at(i)->attribute<<" ";
}
std::cout<<std::endl;
for(size_t i=0;i<allItemLeaf->size();i++){
std::cout<<allItemLeaf->at(i)<<" ";
}
std::cout<<std::endl;
}
};
/* Kd-tree construction and destruction */
template <int dim, class objT>
tree<dim, objT> *build(parlay::slice<objT *, objT *> P,
bool parallel = true,
size_t leafSize = 16);
template <int dim, class objT>
tree<dim, objT> *build(parlay::sequence<objT> &P,
bool parallel = true,
size_t leafSize = 16);
template <int dim, class objT>
void del(node<dim, objT> *tree);
template <int _dim, class _objT>
class node
{
protected:
using intT = int;
using floatT = double;
using pointT = _objT;
using nodeT = node<_dim, _objT>;
intT id;
int k;
pointT pMin, pMax;
nodeT *left;
nodeT *right;
nodeT *sib;
nodeT *par;
bool active;
parlay::slice<_objT **, _objT **> items;
parlay::slice<bool *, bool *> itemActive;
parlay::slice<nodeT **, nodeT **> itemLeaf;
inline void minCoords(pointT &_pMin, pointT &p)
{
for (int i = 0; i < dim; ++i)
_pMin[i] = std::min(_pMin[i], p[i]);
}
inline void maxCoords(pointT &_pMax, pointT &p)
{
for (int i = 0; i < dim; ++i)
_pMax[i] = std::max(_pMax[i], p[i]);
}
void boundingBoxSerial();
void boundingBoxParallel();
intT splitItemSerial(floatT xM);
inline bool itemInBox(pointT pMin1, pointT pMax1, _objT *item)
{
for (int i = 0; i < _dim; ++i)
{
if (pMax1[i] < item->at(i) || pMin1[i] > item->at(i))
return false;
}
return true;
}
inline intT findWidest()
{
floatT xM = -1;
for (int kk = 0; kk < _dim; ++kk)
{
if (pMax[kk] - pMin[kk] > xM)
{
xM = pMax[kk] - pMin[kk];
k = kk;
}
}
return k;
}
void constructSerial(nodeT *space, intT leafSize);
void constructParallel(nodeT *space, parlay::slice<bool *, bool *> flags, intT leafSize);
public:
using objT = _objT;
static constexpr int dim = _dim;
inline nodeT *L() { return left; }
inline nodeT *R() { return right; }
inline nodeT *parent() { return par; }
inline nodeT *siblin() { return sib; }
inline void activate() { active = true; }
inline void deactivate() { active = false; }
inline bool empty() { return !active; }
inline intT size() { return items.size(); }
inline _objT *operator[](intT i) { if(itemActive[i]) return items[i]; else return NULL; }
inline _objT *at(intT i) { if(itemActive[i]) return items[i]; else return NULL; }
inline bool isLeaf() { return !left; }
inline _objT *getItem(intT i) { if(itemActive[i]) return items[i]; else return NULL; }
inline pointT getMax() { return pMax; }
inline pointT getMin() { return pMin; }
inline floatT getMax(int i) { return pMax[i]; }
inline floatT getMin(int i) { return pMin[i]; }
void initSerial();
void initParallel();
// inline void setEmpty() { id = -2; }
// inline bool isEmpty() { return id == -2; }
inline bool hasId()
{
return id != -1;
}
inline void setId(intT _id)
{
id = _id;
}
inline void resetId()
{
id = -1;
}
inline intT getId()
{
return id;
}
static const int boxInclude = 0;
static const int boxOverlap = 1;
static const int boxExclude = 2;
inline floatT diag()
{
floatT result = 0;
for (int d = 0; d < _dim; ++d)
{
floatT tmp = pMax[d] - pMin[d];
result += tmp * tmp;
}
return sqrt(result);
}
inline floatT lMax()
{
floatT myMax = 0;
for (int d = 0; d < _dim; ++d)
{
floatT thisMax = pMax[d] - pMin[d];
if (thisMax > myMax)
{
myMax = thisMax;
}
}
return myMax;
}
inline int boxCompare(pointT pMin1, pointT pMax1, pointT pMin2, pointT pMax2)
{
bool exclude = false;
bool include = true; //1 include 2
for (int i = 0; i < _dim; ++i)
{
if (pMax1[i] < pMin2[i] || pMin1[i] > pMax2[i])
exclude = true;
if (pMax1[i] < pMax2[i] || pMin1[i] > pMin2[i])
include = false;
}
if (exclude)
return boxExclude;
else if (include)
return boxInclude;
else
return boxOverlap;
}
node();
node(parlay::slice<_objT **, _objT **> items_,
parlay::slice<bool *, bool *> itemActive_,
parlay::slice<nodeT **, nodeT **> itemLeaf_,
intT nn,
nodeT *space,
parlay::slice<bool *, bool *> flags,
intT leafSize = 16);
node(parlay::slice<_objT **, _objT **> items_,
parlay::slice<bool *, bool *> itemActive_,
parlay::slice<nodeT **, nodeT **> itemLeaf_,
intT nn,
nodeT *space,
intT leafSize = 16);
virtual ~node()
{
}
};
} // End namespace pargeo::kdTree
#include "pdTreeImpl.h"
#include "pdKnnImpl.h"
|
michaelyhuang23/ParGeo | include/pargeo/pointIO.h | <filename>include/pargeo/pointIO.h
// This code is part of the Problem Based Benchmark Suite (PBBS)
// Copyright (c) 2011 <NAME> and the PBBS team
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights (to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include "parlay/parallel.h"
#include "parlay/primitives.h"
#include "IO.h"
namespace pargeo {
namespace pointIO {
std::string pbbsHeader(int dim) {
if (dim < 2 || dim > 9) {
throw std::runtime_error("Error, unsupported dimension");
}
return "pbbs_sequencePoint" + std::to_string(dim) + "d";
}
bool isGenericHeader(std::string line) {
for (auto c: line) {
if (!pargeo::IO::is_number(c) && !pargeo::IO::is_delim(c)) return true;
}
return false;
}
int countEntry(std::string line) {
while (pargeo::IO::is_delim(line.back()) ||
pargeo::IO::is_space(line.back()) ||
pargeo::IO::is_newline(line.back())) {
line.pop_back();
}
int count = 0;
for (auto c: line) {
if (pargeo::IO::is_delim(c)) count ++;
}
return count + 1;
}
// returns dim
int readHeader(const char* fileName) {
std::ifstream file (fileName);
if (!file.is_open())
throw std::runtime_error("Unable to open file");
std::string line1; std::getline(file, line1);
if (isGenericHeader(line1)) {
std::string line2; std::getline(file, line2);
return countEntry(line2);
} else {
return countEntry(line1);
}
}
// todo deprecate
int readDimensionFromFile(char* const fileName) {
std::cout << "warning: using deprecated function readDimensionFromFile\n";
return readHeader(fileName);
}
template <class pointT>
int writePointsToFile(parlay::sequence<pointT> const &P, char const *fname) {
int r = pargeo::IO::writeSeqToFile("", P, fname);
return r;
}
template <class pointT>
int writePointsToFilePbbs(parlay::sequence<pointT> const &P, char const *fname) {
std::string Header = pbbsHeader(pointT::dim);
int r = pargeo::IO::writeSeqToFile(Header, P, fname);
return r;
}
template <class pointT, class Seq>
parlay::sequence<pointT> parsePoints(Seq W) {
using coord = double;
int d = pointT::data_len;
size_t n = W.size()/d;
auto a = parlay::tabulate(d * n, [&] (size_t i) -> coord {
return atof(W[i]);});
auto points = parlay::tabulate(n, [&] (size_t i) -> pointT {
return pointT(a, d*i, d*(i + 1));});
return points;
}
template <class pointT>
parlay::sequence<pointT> readPointsFromFile(char const *fname) {
parlay::sequence<char> S = pargeo::IO::readStringFromFile(fname);
parlay::sequence<char*> W = pargeo::IO::stringToWords(S);
if (W.size() == 0)
throw std::runtime_error("readPointsFromFile empty file");
if (isGenericHeader(W[0]))
return parsePoints<pointT>(W.cut(1,W.size()));
else
return parsePoints<pointT>(W.cut(0,W.size()));
}
} // End namespace pointIO
} // End namespace pargeo
|
michaelyhuang23/ParGeo | include/pseudoDynamicKdTree/pdTreeImpl.h | // This code is part of the project "ParGeo: A Library for Parallel Computational Geometry"
// Copyright (c) 2021-2022 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights (to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include "parlay/parallel.h"
#include "parlay/utilities.h"
#include "pdKdTree.h"
namespace pargeo::pdKdTree
{
namespace kdTreeInternal
{
template <typename In_Seq, typename Bool_Seq>
auto split_two(In_Seq const &In,
Bool_Seq const &Fl,
parlay::flags fl = parlay::no_flag)
-> std::pair<parlay::sequence<typename In_Seq::value_type>, size_t>
{
using namespace parlay;
using namespace parlay::internal;
using T = typename In_Seq::value_type;
size_t n = In.size();
size_t l = num_blocks(n, _block_size);
sequence<size_t> Sums(l);
sliced_for(
n, _block_size,
[&](size_t i, size_t s, size_t e)
{
size_t c = 0;
for (size_t j = s; j < e; j++)
c += (Fl[j] == false);
Sums[i] = c;
},
fl);
size_t m = scan_inplace(make_slice(Sums), addm<size_t>());
sequence<T> Out = sequence<T>::uninitialized(n);
sliced_for(
n, _block_size,
[&](size_t i, size_t s, size_t e)
{
size_t c0 = Sums[i];
size_t c1 = s + (m - c0);
for (size_t j = s; j < e; j++)
{
if (Fl[j] == false)
assign_uninitialized(Out[c0++], In[j]);
else
assign_uninitialized(Out[c1++], In[j]);
}
},
fl);
return std::make_pair(std::move(Out), m);
}
} // End namespace kdTreeInternal
template <int _dim, class _objT>
void node<_dim, _objT>::boundingBoxSerial()
{
pMin = pointT(items[0]->coords());
pMax = pointT(items[0]->coords());
for (intT i = 0; i < size(); ++i)
{
minCoords(pMin, items[i][0]);
maxCoords(pMax, items[i][0]);
}
}
template <int _dim, class _objT>
void node<_dim, _objT>::boundingBoxParallel()
{
intT P = parlay::num_workers() * 8;
intT blockSize = (size() + P - 1) / P;
pointT localMin[P];
pointT localMax[P];
for (intT i = 0; i < P; ++i)
{
localMin[i] = pointT(items[0]->coords());
localMax[i] = pointT(items[0]->coords());
}
parlay::parallel_for(0, P,
[&](intT p)
{
intT s = p * blockSize;
intT e = std::min((intT)(p + 1) * blockSize, size());
for (intT j = s; j < e; ++j)
{
minCoords(localMin[p], items[j][0]);
maxCoords(localMax[p], items[j][0]);
}
});
pMin = pointT(items[0]->coords());
pMax = pointT(items[0]->coords());
for (intT p = 0; p < P; ++p)
{
minCoords(pMin, localMin[p]);
maxCoords(pMax, localMax[p]);
}
}
template <int _dim, class _objT>
typename node<_dim, _objT>::intT
node<_dim, _objT>::splitItemSerial(floatT xM)
{
if (size() < 2)
{
throw std::runtime_error("Error, kdTree splitting singleton.");
}
intT lPt = 0;
intT rPt = size() - 1;
while (lPt < rPt)
{
if (items[lPt]->at(k) >= xM)
{
while (items[rPt]->at(k) >= xM && lPt < rPt)
{
rPt--;
}
if (lPt < rPt)
{
std::swap(items[lPt], items[rPt]);
// std::swap(itemActive[lPt], itemActive[rPt]);
// std::swap(itemLeaf[lPt], itemLeaf[rPt]);
rPt--;
}
else
{
break;
}
}
lPt++;
}
if (items[lPt]->at(k) < xM)
lPt++;
return lPt;
}
template <int _dim, class _objT>
void node<_dim, _objT>::initSerial()
{
par = NULL;
if(!left && !right){
for(size_t i=0;i<size();i++)
itemLeaf[i]=this;
}else{
left->initSerial();
right->initSerial();
left->par = this;
right->par = this;
}
}
template <int _dim, class _objT>
void node<_dim, _objT>::initParallel()
{
par = NULL;
if(!left && !right){
parlay::parallel_for(0, size(), [&](size_t i){
itemLeaf[i]=this;
});
}else{
parlay::par_do([&](){ left->initParallel(); }, [&](){ right->initParallel(); });
left->par = this;
right->par = this;
}
}
template <int _dim, class _objT>
void node<_dim, _objT>::constructSerial(nodeT *space, intT leafSize)
{
boundingBoxSerial();
sib = NULL;
active = false;
if (size() <= leafSize)
{ // create another slice for the leaves each belongs to
left = NULL;
right = NULL;
}
else
{
intT k = findWidest();
floatT xM = (pMax[k] + pMin[k]) / 2;
// Split items by xM (serial)
intT median = splitItemSerial(xM);
if (median == 0 || median == size())
{
median = ceil(size() / 2.0);
}
// Recursive construction
space[0] = nodeT(items.cut(0, median), itemActive.cut(0, median), itemLeaf.cut(0, median), median, space + 1, leafSize);
space[2 * median - 1] = nodeT(items.cut(median, size()), itemActive.cut(median, size()), itemLeaf.cut(median, size()), size() - median, space + 2 * median, leafSize);
left = space;
right = space + 2 * median - 1;
left->sib = right;
right->sib = left;
}
}
template <int _dim, class _objT>
void node<_dim, _objT>::constructParallel(nodeT *space, parlay::slice<bool *, bool *> flags, intT leafSize)
{
boundingBoxParallel();
sib = NULL;
active = false;
if (size() <= leafSize)
{
left = NULL;
right = NULL;
}
else
{
intT k = findWidest();
floatT xM = (pMax[k] + pMin[k]) / 2;
// Split items by xM in dim k (parallel)
parlay::parallel_for(0, size(),
[&](intT i)
{
if (items[i]->at(k) < xM)
flags[i] = 1;
else
flags[i] = 0;
});
auto mySplit = kdTreeInternal::split_two(items, flags);
auto splited = mySplit.first;
intT median = mySplit.second;
parlay::parallel_for(0, size(), [&](intT i)
{ items[i] = splited[i]; }); // Copy back
if (median == 0 || median == size())
{
median = (size() / 2.0);
}
// if (!space[0].isEmpty() || !space[2*median-1].isEmpty()) {
// throw std::runtime_error("Error, kdNode overwrite.");
// }
// Recursive construction
parlay::par_do([&]()
{ space[0] = nodeT(items.cut(0, median), itemActive.cut(0, median), itemLeaf.cut(0, median), median, space + 1, flags.cut(0, median), leafSize); },
[&]()
{ space[2 * median - 1] = nodeT(items.cut(median, size()), itemActive.cut(median, size()), itemLeaf.cut(median, size()), size() - median, space + 2 * median, flags.cut(median, size()), leafSize); });
left = space;
right = space + 2 * median - 1;
left->sib = right;
right->sib = left;
}
}
template <int _dim, class _objT>
node<_dim, _objT>::node() {}
template <int _dim, class _objT>
node<_dim, _objT>::node(parlay::slice<_objT **, _objT **> items_,
parlay::slice<bool*, bool*> itemActive_,
parlay::slice<nodeT **, nodeT **> itemLeaf_,
intT nn,
nodeT *space,
parlay::slice<bool *, bool *> flags,
intT leafSize) : items(items_), itemActive(itemActive_), itemLeaf(itemLeaf_)
{
resetId();
if (size() > 2000)
constructParallel(space, flags, leafSize);
else
constructSerial(space, leafSize);
}
template <int _dim, class _objT>
node<_dim, _objT>::node(parlay::slice<_objT **, _objT **> items_,
parlay::slice<bool *, bool *> itemActive_,
parlay::slice<nodeT **, nodeT **> itemLeaf_,
intT nn,
nodeT *space,
intT leafSize) : items(items_), itemActive(itemActive_), itemLeaf(itemLeaf_)
{
resetId();
constructSerial(space, leafSize);
}
template <typename nodeT>
double nodeDistance(nodeT *n1, nodeT *n2)
{
using floatT = typename nodeT::objT::floatT;
for (int d = 0; d < n1->dim; ++d)
{
if (n1->getMin(d) > n2->getMax(d) || n2->getMin(d) > n1->getMax(d))
{
// disjoint at dim d, and intersect on dim < d
floatT rsqr = 0;
for (int dd = d; dd < n1->dim; ++dd)
{
floatT tmp = std::max(n1->getMin(dd) - n2->getMax(dd),
n2->getMin(dd) - n1->getMax(dd));
tmp = std::max(tmp, (floatT)0);
rsqr += tmp * tmp;
}
return sqrt(rsqr);
}
}
return 0; // could be intersecting
}
template <typename nodeT>
double nodeFarDistance(nodeT *n1, nodeT *n2)
{
using floatT = typename nodeT::objT::floatT;
floatT result = 0;
for (int d = 0; d < n1->dim; ++d)
{
floatT tmp = std::max(n1->getMax(d), n2->getMax(d)) - std::min(n1->getMin(d), n2->getMin(d));
result += tmp * tmp;
}
return sqrt(result);
}
template <int dim, class objT>
tree<dim, objT> *build(parlay::slice<objT *, objT *> P,
bool parallel,
size_t leafSize)
{
typedef tree<dim, objT> treeT;
typedef node<dim, objT> nodeT;
if (parallel)
{
auto flags = parlay::sequence<bool>(P.size());
auto flagSlice = parlay::slice(flags.begin(), flags.end());
return new treeT(P, flagSlice, leafSize);
}
else
{
return new treeT(P, leafSize);
}
}
template <int dim, class objT>
tree<dim, objT> *build(parlay::sequence<objT> &P,
bool parallel,
size_t leafSize)
{
return build<dim, objT>(parlay::make_slice(P), parallel, leafSize);
}
template <int dim, class objT>
void del(node<dim, objT> *tree)
{
delete tree;
}
} // End namespace pargeo
|
jkrueger/phosphorus_mk2 | src/shaders/noise.h | <gh_stars>1-10
#include "vector2.h"
#include "vector4.h"
float safe_noise(float p)
{
float f = noise("noise", p);
if (isinf(f))
return 0.5;
return f;
}
float safe_noise(vector2 p)
{
float f = noise("noise", p.x, p.y);
if (isinf(f))
return 0.5;
return f;
}
float safe_noise(vector p)
{
float f = noise("noise", p);
if (isinf(f))
return 0.5;
return f;
}
float safe_noise(vector4 p)
{
float f = noise("noise", vector(p.x, p.y, p.z), p.w);
if (isinf(f))
return 0.5;
return f;
}
float safe_snoise(float p)
{
float f = noise("snoise", p);
if (isinf(f))
return 0.0;
return f;
}
float safe_snoise(vector2 p)
{
float f = noise("snoise", p.x, p.y);
if (isinf(f))
return 0.0;
return f;
}
float safe_snoise(vector p)
{
float f = noise("snoise", p);
if (isinf(f))
return 0.0;
return f;
}
float safe_snoise(vector4 p)
{
float f = noise("snoise", vector(p.x, p.y, p.z), p.w);
if (isinf(f))
return 0.0;
return f;
}
/* Copied fomr blender*/
float fractal_noise(vector2 p, float details, float roughness)
{
float fscale = 1.0;
float amp = 1.0;
float maxamp = 0.0;
float sum = 0.0;
float octaves = clamp(details, 0.0, 16.0);
int n = (int)octaves;
for (int i = 0; i <= n; i++) {
float t = safe_noise(fscale * p);
sum += t * amp;
maxamp += amp;
amp *= clamp(roughness, 0.0, 1.0);
fscale *= 2.0;
}
float rmd = octaves - floor(octaves);
if (rmd != 0.0) {
float t = safe_noise(fscale * p);
float sum2 = sum + t * amp;
sum /= maxamp;
sum2 /= maxamp + amp;
return (1.0 - rmd) * sum + rmd * sum2;
}
else {
return sum / maxamp;
}
}
/* Copied from blender */
float fractal_noise(vector p, float details, float roughness)
{
float fscale = 1.0;
float amp = 1.0;
float maxamp = 0.0;
float sum = 0.0;
float octaves = clamp(details, 0.0, 16.0);
int n = (int)octaves;
for (int i = 0; i <= n; i++) {
float t = safe_noise(fscale * p);
sum += t * amp;
maxamp += amp;
amp *= clamp(roughness, 0.0, 1.0);
fscale *= 2.0;
}
float rmd = octaves - floor(octaves);
if (rmd != 0.0) {
float t = safe_noise(fscale * p);
float sum2 = sum + t * amp;
sum /= maxamp;
sum2 /= maxamp + amp;
return (1.0 - rmd) * sum + rmd * sum2;
}
else {
return sum / maxamp;
}
} |
jkrueger/phosphorus_mk2 | src/shaders/color_ramp.h | <filename>src/shaders/color_ramp.h
color rgb_ramp_lut(
color lut[]
, float at
, int interpolate
, int extrapolate)
{
float f = at;
if ((f < 0.0f || f > 1.0f) && extrapolate) {
return rgb_ramp_extrapolate(lut, f);
}
f = clamp(at, 0.0f, 1.0f) * (arraysize(lut) - 1);
int i = (int) f;
float t = f - (float) i;
color result = lut[i];
if (interpolate) {
result = lerp(t, result, lut[i + 1]);
}
return result;
}
|
jkrueger/phosphorus_mk2 | src/shaders/fresnel.h |
float fresnel_dielectric(float cosi, float eta)
{
float c = fabs(cosi);
float g = eta * eta - 1.0 + c * c;
float result;
if (g > 0) {
g = sqrt(g);
float A = (g - c) / (g + c);
float B = (c * (g + c) - 1) / (c * (g - c) + 1);
result = 0.5 * A * A * (1 + B * B);
}
else {
result = 1.0;
}
return result;
}
color fresnel_conductor(float cosi, color eta, color k)
{
return color(0,0,0);
}
|
jkrueger/phosphorus_mk2 | src/shaders/phosphorus.h | <filename>src/shaders/phosphorus.h
#pragma once
/**
* Closures
*
*/
closure color sheen(normal N, float r) BUILTIN;
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/other/WebRTCTool.h | <filename>JSIMWebrtcOverMQTT/other/WebRTCTool.h
//
// WebRTCManager.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/21.
// Copyright © 2015年 weaver software. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "JSIMTool.h"
#import "ServerConfig.h"
#import "MQTTSessionTool.h"
#import <RTCAVFoundationVideoSource.h>
#import <RTCAudioSource.h>
#import <RTCAudioTrack.h>
#import <RTCDataChannel.h>
#import <RTCEAGLVideoView.h>
#import <RTCFileLogger.h>
#import <RTCLogging.h>
#import <RTCI420Frame.h>
#import <RTCICECandidate.h>
#import <RTCICEServer.h>
#import <RTCMediaConstraints.h>
#import <RTCMediaStream.h>
#import <RTCMediaStreamTrack.h>
//#import <RTCNSGLVideoView.h>
#import <RTCOpenGLVideoRenderer.h>
#import <RTCPair.h>
#import <RTCPeerConnection.h>
#import <RTCPeerConnectionDelegate.h>
#import <RTCPeerConnectionFactory.h>
#import <RTCPeerConnectionInterface.h>
#import <RTCSessionDescription.h>
#import <RTCSessionDescriptionDelegate.h>
#import <RTCStatsDelegate.h>
#import <RTCStatsReport.h>
#import <RTCTypes.h>
#import <RTCVideoCapturer.h>
#import <RTCVideoRenderer.h>
#import <RTCVideoSource.h>
#import <RTCVideoTrack.h>
@protocol WebRTCToolDelegate;
@interface WebRTCTool : NSObject<RTCPeerConnectionDelegate,RTCSessionDescriptionDelegate>
@property (strong ,nonatomic)MQTTSessionTool *mqttSessionTool;
@property (strong ,nonatomic)RTCPeerConnectionFactory *peerConnectionFactory;
@property (strong ,nonatomic)RTCMediaConstraints *pcConstraints;
@property (strong ,nonatomic) RTCMediaConstraints *sdpConstraints;
@property (strong ,nonatomic)RTCMediaConstraints *videoConstraints;
@property (strong ,nonatomic)RTCPeerConnection *peerConnection;
@property (strong ,nonatomic)RTCVideoCapturer *localVideoCapture;
@property (strong ,nonatomic)RTCVideoSource *localVideoSource;
@property (strong ,nonatomic)RTCAudioTrack *localAudioTrack;
@property (strong ,nonatomic)RTCVideoTrack *localVideoTrack;
@property (strong ,nonatomic)ServerConfig *stunServerConfig;
@property (strong ,nonatomic)ServerConfig *turnServerConfig;
@property (assign ,nonatomic)BOOL isInitiator;
@property(nonatomic, assign) BOOL hasCreatedPeerConnection;
@property (weak ,nonatomic)id<WebRTCToolDelegate> webDelegate;
/**
* 当用户(caller/callee)触发按钮,进行通话操作,首先进入到这里
*
* @param flag yes时,是以caller进入,no即为callee
* @param queueSingleMessage 消息队列
*/
- (void)startRTCWorkerAsInitiator:(BOOL)flag queuedSignalMessage:(NSMutableArray *)queueSingleMessage;
/**
* callee接收到信令传过来的offer,将caller的offer设置为自己的remote description
*
* @param type offer
* @param offer caller offer(caller local description)
*/
- (void)calleeHandleOfferWithType:(NSString *)type offer:(NSString *)offer;
/**
* caller接受到信令传送过来的answer,将callee的offer设置为自己的remote description
*
* @param type answer
* @param answer callee answer(callee local description)
*/
- (void)callerHandleAnswerWithType:(NSString *)type answer:(NSString *)answer;
/**
* 不管作为caller,还是callee,在通过ICE服务器设置完peerConnection后,一直会搜寻ice伺服器。
*
* @param ID <#ID description#>
* @param label <#label description#>
* @param sdp <#sdp description#>
*/
- (void)handleIceCandidateWithID:(NSString *)ID label:(NSNumber *)label candidate:(NSString *)candidate;
@end
/**
* 实现webrtcTool代理,需要有以下功能
*/
@protocol WebRTCToolDelegate <NSObject>
@optional
/**
* 发送Sdp
*/
- (void)sendSdpWithData:(NSData *)data;
/**
* 发送ICE信息
*/
- (void)sendICECandidate:(NSData *)data;
/**
* 处理rtc通信中的信息,并将处理后的结果返回给WebrtcTool
*
* @param rtcDic 需要处理的RTC信息
*/
- (void)handleRTCMessage:(NSDictionary *)rtcDic;
/**
* 处理RTC信息完毕信息后调用
*/
- (void)handleRTCMessageDone;
/**
* 打开视频窗口,并进行初始化
*/
- (void)addVideoView;
/**
* 处理从peerConnection传过来的媒体数据流
*
* @param mediaStream 传送的媒体数据流
*/
- (void)receiveStreamWithPeerConnection:(RTCMediaStream *)mediaStream;
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/model/ChatMessage.h | //
// ChatMessage.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/18.
// Copyright (c) 2015年 weaver software. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ClientUser.h"
@interface ChatMessage : NSObject<NSCoding>
@property (assign ,nonatomic)NSInteger mesID;
@property (strong ,nonatomic)ClientUser *fromUser;
@property (strong ,nonatomic)ClientUser *toUser;
@property (copy ,nonatomic)NSString *content;
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/model/ServerConfig.h | //
// ServerConfig.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/18.
// Copyright (c) 2015年 weaver software. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ServerConfig : NSObject
@property (copy ,nonatomic)NSString *url;
@property (copy ,nonatomic)NSString *port;
@property (copy ,nonatomic)NSString *serverName;
@property (copy ,nonatomic)NSString *username;
@property (copy ,nonatomic)NSString *credential;
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/view/RTCVideoView.h | <gh_stars>10-100
//
// RTCVideoView.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/22.
// Copyright © 2015年 weaver software. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <RTCVideoRenderer.h>
@interface RTCVideoView : UIView<RTCVideoRenderer>
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/viewController/ViewController.h | <reponame>wenghengcong/JSIMWebrtcOverMQTT
//
// ViewController.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/17.
// Copyright (c) 2015年 weaver software. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ClientUser.h"
#import "ChatMessage.h"
#import "ServerConfig.h"
#import "ConfigSet.h"
#import "JSIMTool.h"
#import "MQTTSessionTool.h"
#import "WebRTCTool.h"
#import "RTCVideoView.h"
@interface ViewController : UIViewController<MQTTSessionDelegate,UITextFieldDelegate,UIAlertViewDelegate,WebRTCToolDelegate,RTCEAGLVideoViewDelegate>
@property (strong ,nonatomic)ClientUser *mySelf;
@property (strong ,nonatomic)ClientUser *otherUser;
@property (weak, nonatomic) IBOutlet UISegmentedControl *chooseUserSeg;
@property (weak, nonatomic) IBOutlet UITextField *myIDTextField;
@property (weak, nonatomic) IBOutlet UITextField *otherIDTextField;
@property (weak, nonatomic) IBOutlet UITextField *iceServerTextField;
@property (weak, nonatomic) IBOutlet UITextField *mqttServerTextField;
@property (weak, nonatomic) IBOutlet UILabel *mqttStateLabel;
@property (strong ,nonatomic)RTCVideoView *rtcVideoView;
@property (strong ,nonatomic)RTCEAGLVideoView *remoteVideoView;
- (IBAction)chooseMyID:(id)sender;
- (IBAction)chooseUID:(id)sender;
- (IBAction)chooseICEServer:(id)sender;
- (IBAction)chooseMqttServer:(id)sender;
- (IBAction)chooseUser:(id)sender;
/**
* 连接前发布消息
*
*/
- (IBAction)warmUpAction:(id)sender;
/**
* 发起连接
*
*/
- (IBAction)connectAction:(id)sender;
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/model/ClientUser.h | <gh_stars>10-100
//
// ClientUser.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/18.
// Copyright (c) 2015年 weaver software. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ClientUser : NSObject<NSCoding>
@property (assign ,nonatomic)NSInteger userID;
@property (copy ,nonatomic)NSString *userName;
@property (copy ,nonatomic)NSString *userPassword;
@property (copy ,nonatomic)NSString *iceServerUrl;
@property (copy ,nonatomic)NSString *mqttServerUrl;
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/ConfigSet.h | <filename>JSIMWebrtcOverMQTT/ConfigSet.h
//
// ConfigSet.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/18.
// Copyright (c) 2015年 weaver software. All rights reserved.
//
#ifndef JSIMWebrtcOverMQTT_ConfigSet_h
#define JSIMWebrtcOverMQTT_ConfigSet_h
#endif
#define UserAliceName @"JSIMUser/Alice"
#define UserBobName @"JSIMUser/Bob"
//server name
#define SERVERNAME_IPTEL @"iptel server"
#define SERVERNAME_SOFTJOYS @"softjoys server"
#define SERVERNAME_IBM @"ibm server"
#define SERVERNAME_MOSQUITTOR @"mosquitto server"
#define SERVERNAME_OTHER @"other server"
//mqtt server config
#define MQTTSERVER_IBMHOST @"messagesight.demos.ibm.com"
#define MQTTSERVER_IBMPORT @"1883"
#define MQTTSERVER_MOSQUITTOHOST @"test.mosquitto.org"
#define MQTTSERVER_MOSQUITTOPORT @"1883"
//ice
#define ICESERVER_IPTEL_STUN_HOST @"stun:stun.iptel.org"
#define ICESERVER_IPTEL_STUN_PORT @""
#define ICESERVER_IPTEL_TURN_HOST @"stun:stun.iptel.org"
#define ICESERVER_IPTEL_TURN_PORT @""
#define ICESERVER_IPTEL_TURN_USERNAME @""
#define ICESERVER_IPTEL_TURN_CREDENTIAL @""
#define ICESERVER_SOFTJOYS_STUN_HOST @"stun:stun.softjoys.com"
#define ICESERVER_SOFTJOYS_STUN_PORT @""
#define ICESERVER_SOFTJOYS_TURN_HOST @"stun:stun.softjoys.com"
#define ICESERVER_SOFTJOYS_TURN_PORT @""
#define ICESERVER_SOFTJOYS_TURN_USERNAME @""
#define ICESERVER_SOFTJOYS_TURN_CREDENTIAL @""
#define JSIMRTCLOG
#ifdef JSIMRTCLOG
#define JSIMRTCLOG(format, ...) NSLog(format, ## __VA_ARGS__)
#else
#define JSIMRTCLOG(format, ...)
#endif
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/viewController/VideoChatViewController.h | //
// VideoChatViewController.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/18.
// Copyright (c) 2015年 weaver software. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface VideoChatViewController : UIViewController
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/other/JSIMTool.h | <reponame>wenghengcong/JSIMWebrtcOverMQTT
//
// JSIMTool.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/18.
// Copyright (c) 2015年 weaver software. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ConfigSet.h"
@interface JSIMTool : NSObject
/**
* 按步骤打印log
*
* @param setp <#setp description#>
* @param content <#content description#>
*/
+ (void)logOutWithStep:(NSInteger)setp Content:(NSString *)content;
+ (void)logOutContent:(NSString *)content;
@end
|
wenghengcong/JSIMWebrtcOverMQTT | JSIMWebrtcOverMQTT/other/MQTTSessionTool.h | <filename>JSIMWebrtcOverMQTT/other/MQTTSessionTool.h
//
// MQTTSessionManager.h
// JSIMWebrtcOverMQTT
//
// Created by WHC on 15/9/21.
// Copyright © 2015年 weaver software. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <MQTTSession.h>
#import "ChatMessage.h"
#import "JSIMTool.h"
@interface MQTTSessionTool : NSObject
@property (strong ,nonatomic)MQTTSession *mqttSession;
@property (copy ,nonatomic)NSString *subTopic;
@property (copy ,nonatomic)NSString *pubTopic;
+ (instancetype)sharedInstance;
- (void)sessionConnectToHost:(NSString *)host Port:(NSInteger )port;
/**
* 订阅主题
*/
- (void)subscriberTopic;
/**
* 订阅多个主题
*
* @param topics 主题数组
*/
- (void)subscriberTopicsWithDic:(NSArray *)topics;
/**
* 取消订阅
*/
- (void)unSubscriberTopic;
/**
* 取消订阅多个主题
*
* @param topics 主题数组
*/
- (void)unSubscriberTopicsWithArray:(NSArray *)topics;
/**
* 取消所有订阅
*/
- (void)unSubscriberAllTopic;
/**
* 发送二进制消息
*
* @param data <#data description#>
*/
- (void)sendMessageWithData:(NSData *)data;
/**
* 发送字典消息(传送的仍然是二进制)
*
* @param dic <#dic description#>
*/
- (void)sendMessageWithDic:(NSDictionary *)dic;
/**
* 发送字符串消息(传送的仍然是二进制)
*
* @param string <#string description#>
*/
- (void)sendMessageWithString:(NSString *)string;
/**
* 发送自定义消息(传送的仍然是二进制)
*
* @param chatMessage <#chatMessage description#>
*/
- (void)sendChatMessage:(ChatMessage*)chatMessage;
@end
|
SeanKh/mC-program_of_PointDriver | pointDriverController/PortIntHandler.c | <reponame>SeanKh/mC-program_of_PointDriver
#include "int_handler.h"
#include "tm4c1294ncpdt.h"
#include "inc/hw_memmap.h"
#include <stdint.h>
#include <stdbool.h>
#include "stdio.h"
#include <string.h>
#include <stdlib.h>
// PM0 servo, PM1 motor
void PortAHandler(void)
{
unsigned int i;
for(i=0;i<500000;i++);
unsigned varPortA=GPIO_PORTA_AHB_DATA_R;
unsigned varPortD=GPIO_PORTD_AHB_DATA_R;
unsigned varPortC=GPIO_PORTC_AHB_DATA_R;
if((varPortA & 0x40) & (varPortD & 0x80)){
printf("Error");
return;
}
else if(varPortA & 0x40){
varPortC |= 0x80; // PC7 high
for(i=0;i<500000;i++);
varPortC &= 0x00; // PC7 low
}
GPIO_PORTA_AHB_ICR_R = 0x40;
}
// PORT E INTERRUPT HANDLER
void PortEHandler(void)
{
unsigned int i;
for(i=0;i<500000;i++);
unsigned varPortE=GPIO_PORTE_AHB_DATA_R;
unsigned varPortC=GPIO_PORTC_AHB_DATA_R;
if((varPortE & 0x03) == 0x03){
printf("Error");
return;
}
else if(varPortE & 0x01){
varPortC |= 0x10; // PC4 high
for(i=0;i<500000;i++);
varPortC &= 0x00; // PC4 low
}
else if(varPortE & 0x02){
varPortC |= 0x02; //PC5 high
for(i=0;i<500000;i++);
varPortC &= 0x00; // PC4 low
}
if(varPortE & 0x0C){
printf("Error");
}
else if(varPortE & 0x04){
varPortC |= 0x40; // PC6 high
for(i=0;i<500000;i++);
varPortC &= 0x00; // PC6 low
}
else if(varPortE & 0x08){
varPortE |= 0x20; //PE5 high
for(i=0;i<500000;i++);
varPortE &= 0x00; // PE5 low
}
GPIO_PORTE_AHB_ICR_R = 0x0F;
}
// PORT D INTERRUPT HANDLER
void PortDHandler(void)
{
unsigned int i;
for(i=0;i<500000;i++);
unsigned varPortD=GPIO_PORTD_AHB_DATA_R;
unsigned varPortA=GPIO_PORTA_AHB_DATA_R;
if((varPortD & 0x80) & (varPortA & 0x04)){
printf("Error");
return;
}
else if(varPortD & 0x80){
varPortD |= 0x08; // PD3 high
for(i=0;i<500000;i++);
varPortD &= 0x00; // PD3 low
}
GPIO_PORTD_AHB_ICR_R = 0x80;
}
// PORT M INTERRUPT HANDLER
void PortMHandler(void)
{
unsigned int i;
for(i=0;i<500000;i++);
unsigned varPortM=GPIO_PORTM_DATA_R;
unsigned varPortB=GPIO_PORTB_AHB_DATA_R;
if(varPortM & 0x30){
printf("Error");
return;
}
else if(varPortM & 0x10){
varPortB |= 0x04; // PB2 high
for(i=0;i<500000;i++);
varPortB &= 0x00; // PB2 low
}
else if(varPortM & 0x20){
varPortB |= 0x08; // PB3 high
for(i=0;i<500000;i++);
varPortB &= 0x00; // PB3 low
}
GPIO_PORTM_ICR_R = 0x30;
}
|
SeanKh/mC-program_of_PointDriver | pointDriverController/main.c | /**
* main.c
*/
#include <stdio.h>
#include "tm4c1294ncpdt.h"
#include "int_handler.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom_map.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
/**
* main.c
* 2 out 3,3V
* 2 in 3,3V
*/
int main(void)
{
// Port Clock Gating Control Port A
SYSCTL_RCGCGPIO_R |= 0x00000001;
while((SYSCTL_PRGPIO_R & 0x00000001) == 0);
// Set INPUT direction I/O pin PA6
GPIO_PORTA_AHB_DIR_R &= 0xBF;
// Digital I/O pins PA6 enable
GPIO_PORTA_AHB_DEN_R |= 0x40;
GPIO_PORTA_AHB_DATA_R &= 0x00;
//GPIO_PORTA_AHB_AFSEL_R &= ~0x40; // disable alt funct on PA6 (default setting)
//GPIO_PORTA_AHB_PCTL_R &= ~0x0F000000;// configure PA6 as GPIO (default setting)
//GPIO_PORTA_AHB_AMSEL_R &= ~0x40;// disable analog functionality on PA6 (default setting)
GPIO_PORTA_AHB_IS_R &= ~0x40; // PA6 is edge-sensitive (default setting)
GPIO_PORTA_AHB_IBE_R &= ~0x40; // PA6 is not both edges (default setting)
GPIO_PORTA_AHB_IEV_R |= 0x40; // PA6 rising edge event
GPIO_PORTA_AHB_ICR_R = 0x40; // clear flag6
GPIO_PORTA_AHB_IM_R |= 0x40; // enable interrupt on PA6
// GPIO PortC=priority 2
NVIC_EN0_R |= (1<<0); // enable PortA interrupt (Int#0/Vec#16) in NVIC
// Port Clock Gating Control Port B
SYSCTL_RCGCGPIO_R |= 0x00000002;
while((SYSCTL_PRGPIO_R & 0x00000002) == 0);
// Set output direction I/O pins PB0 to PB7
GPIO_PORTB_AHB_DIR_R |= 0xFF;
// Digital I/O pins PB2 to PB3 enable
GPIO_PORTB_AHB_DEN_R |= 0x0C;
// Port Clock Gating Control Port C
SYSCTL_RCGCGPIO_R |= 0x00000004;
while((SYSCTL_PRGPIO_R & 0x00000004) == 0);
// Set output direction I/O pins PC0 to PC7
GPIO_PORTC_AHB_DIR_R |= 0xFF;
// Digital I/O pins PC4 to PC7 enable
GPIO_PORTC_AHB_DEN_R |= 0xF0;
// Port Clock Gating Control Port D
SYSCTL_RCGCGPIO_R |= 0x00000008;
while((SYSCTL_PRGPIO_R & 0x00000008) == 0);
// Set output direction I/O pins PD3
GPIO_PORTD_AHB_DIR_R |= 0x0F;
GPIO_PORTD_AHB_DIR_R &= 0x0F; // Set INPUT direction I/O pins PD7
// Digital I/O pins PD3 AND PD7 enable
GPIO_PORTD_AHB_DEN_R |= 0x88;
GPIO_PORTD_AHB_IS_R &= ~0x80; // PD7 is edge-sensitive (default setting)
GPIO_PORTD_AHB_IBE_R &= ~0x80; // PD7 is not both edges (default setting)
GPIO_PORTD_AHB_IEV_R |= 0x80; // PD7 rising edge event
GPIO_PORTD_AHB_ICR_R = 0x80; // clear flag6
GPIO_PORTD_AHB_IM_R |= 0x80; // enable interrupt on PA6
NVIC_EN0_R |= (1<<3); // enable PortD interrupt (Int#3/Vec#19) in NVIC
// Port Clock Gating Control Port E
SYSCTL_RCGCGPIO_R |= (1 << 4);
while((SYSCTL_PRGPIO_R & (1 << 4)) == 0);
// Set INPUT direction I/O pins PE0 to PE3
GPIO_PORTE_AHB_DIR_R &= 0xF0;
GPIO_PORTE_AHB_DIR_R |= 0xF0;// Set OUTPUT direction I/O pins PE5
// Digital I/O pins PE0 to PE3 AND PE5 enable
GPIO_PORTE_AHB_DEN_R |= 0x2F;
GPIO_PORTE_AHB_IS_R &= ~0x0F; // PE0 to PE3 is edge-sensitive (default setting)
GPIO_PORTE_AHB_IBE_R &= ~0x0F; // PA6 is not both edges (default setting)
GPIO_PORTE_AHB_IEV_R |= 0x0F; // PA6 rising edge event
GPIO_PORTE_AHB_ICR_R = 0x0F; // clear flag6
GPIO_PORTE_AHB_IM_R |= 0x0F; // enable interrupt on PA6
// GPIO PortC=priority 2
NVIC_EN0_R |= (1<<4); // enable PortE interrupt (Int#4/Vec#20) in NVIC
// Port Clock Gating Control Port M
SYSCTL_RCGCGPIO_R |= (1 << 11);
while((SYSCTL_PRGPIO_R & (1 << 11)) == 0);
// Set input direction I/O pins PM4 and PM5
GPIO_PORTM_DIR_R &= ~(0x30);
// Digital I/O pins PM4 and PM5 enable
GPIO_PORTM_DEN_R |= 0x30;
GPIO_PORTM_IS_R &= ~0x30; // PE0 to PE3 is edge-sensitive (default setting)
GPIO_PORTM_IBE_R &= ~0x30; // PA6 is not both edges (default setting)
GPIO_PORTM_IEV_R |= 0x30; // PA6 rising edge event
GPIO_PORTM_ICR_R = 0x30; // clear flag6
GPIO_PORTM_IM_R |= 0x30; // enable interrupt on PA6
// GPIO PortC=priority 2
NVIC_EN2_R |= (1<<8); // enable PortM interrupt (Int#72/Vec#88) in NVIC
while(1){
}
}
|
SeanKh/mC-program_of_PointDriver | pointDriverController/int_handler.h | <reponame>SeanKh/mC-program_of_PointDriver
#ifndef INT_HANDLER_H_
#define INT_HANDLER_H_
void PortAHandler(void);
void PortMHandler(void);
void PortDHandler(void);
void PortEHandler(void);
#endif
|
zhizhengwu/sparrowhawk | src/include/sparrowhawk/normalizer.h | <reponame>zhizhengwu/sparrowhawk
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright 2015 and onwards Google, Inc.
// The normalizer is the main part of Sparrowhawk. Loosely speaking it follows
// the discussion of the (Google-internal) Kestrel system as described in
//
// <NAME> <NAME>. 2015. The Kestrel TTS text normalization
// system. Natural Language Engineering, Issue 03, pp 333-353.
//
// After sentence segmentation (sentence_boundary.h), the individual sentences
// are first tokenized with each token being classified, and then passed to the
// normalizer. The system can output as an unannotated string of words, and
// richer annotation with links between input tokens, their input string
// positions, and the output words is also available.
#ifndef SPARROWHAWK_NORMALIZER_H_
#define SPARROWHAWK_NORMALIZER_H_
#include <string>
using std::string;
#include <vector>
using std::vector;
#include <fst/compat.h>
#include <sparrowhawk/items.pb.h>
#include <sparrowhawk/sentence_boundary.h>
#include <sparrowhawk/sparrowhawk_configuration.pb.h>
#include <sparrowhawk/rule_system.h>
namespace speech {
namespace sparrowhawk {
class Normalizer {
public:
Normalizer();
~Normalizer();
// The functions definitions have been split across two files, normalizer.cc
// and normalizer_utils.cc, just to keep things a littler tidier. Below we
// indicate where each function is found.
// normalizer.cc
// Method to load and set data for each derived method
bool Setup(const string &configuration_proto, const string &pathname_prefix);
// normalizer.cc
// Interface to the normalization system for callers that want to be agnostic
// about utterances.
bool Normalize(const string &input, string *output) const;
// normalizer.cc
// Interface to the normalization system for callers that want to be agnostic
// about utterances. Shows the token/word alignment.
bool NormalizeAndShowLinks(const string &input, string *output) const;
// normalizer_utils.cc
// Helper for linearizing words from an utterance into a string
string LinearizeWords(Utterance *utt) const;
// normalizer_utils.cc
// Helper for showing the indices of all tokens, words and their alignment
// links.
string ShowLinks(Utterance *utt) const;
// normalizer.cc
// Preprocessor to use the sentence splitter to break up text into
// sentences. An application would normally call this first, and then
// normalize each of the resulting sentences.
vector<string> SentenceSplitter(const string &input) const;
private:
// normalizer.cc
// Internal interface to normalization.
bool Normalize(Utterance *utt, const string &input) const;
// normalizer_utils.cc
// As in Kestrel, adds a phrase and silence.
void AddPhraseToUtt(Utterance *utt) const { AddPhraseToUtt(utt, false); }
// normalizer_utils.cc
void AddPhraseToUtt(Utterance *utt, bool addword) const;
// normalizer_utils.cc
// Adds a single word to the end of the Word stream
Word* AddWord(Utterance *utt, Token *token,
const string &spelling) const;
// normalizer_utils.cc
// Function to add the words in the string 'name' onto the
// end of the Word stream.
Word* AddWords(Utterance *utt, Token *token,
const string &name) const;
// Finds the index of the provided token.
int TokenIndex(Utterance *utt, Token *token) const;
// normalizer_utils.cc
// As with Peter's comment in
// speech/patts2/modules/kestrel/verbalize_general.cc, clear out all the mucky
// fields that we don't want verbalization to see.
void CleanFields(Token *markup) const;
// normalizer_utils.cc
// Returns the substring of the input between left and right
string InputSubstring(int left, int right) const;
// normalizer.cc
// Performs tokenization and classification on the input utterance, the first
// step of normalization
bool TokenizeAndClassifyUtt(Utterance *utt, const string &input) const;
// normalizer_utils.cc
// Serializes the contents of a Token to a string
string ToString(const Token &markup) const;
// normalizer.cc
// Verbalizes semiotic classes, defaulting to verbatim verbalization for
// something that is marked as a semiotic class but for which the
// verbalization grammar fails.
bool VerbalizeSemioticClass(const Token &markup, string *words) const;
// normalizer.cc
// Performs verbalization on the input utterance, the second step of
// normalization
bool VerbalizeUtt(Utterance *utt) const;
string input_;
std::unique_ptr<RuleSystem> tokenizer_classifier_rules_;
std::unique_ptr<RuleSystem> verbalizer_rules_;
std::unique_ptr<SentenceBoundary> sentence_boundary_;
set<string> sentence_boundary_exceptions_;
DISALLOW_COPY_AND_ASSIGN(Normalizer);
};
} // namespace sparrowhawk
} // namespace speech
#endif // SPARROWHAWK_NORMALIZER_H_
|
madebr/3d-pinball-space-cadet | Classes/TlightGroup/TLightGroup.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TLIGHTGROUP_H
#define PINBALL_TLIGHTGROUP_H
/* 93 */
struct TLightGroup;
TZmapList* __thiscall TLightGroup::~TLightGroup(TLightGroup* this);
void __thiscall TLightGroup::Reset(TLightGroup* __hidden this); // idb
void TLightGroup::TimerExpired(int, void*); // idb
void __thiscall TLightGroup::reschedule_animation(TLightGroup* this, float); // idb
int __thiscall TLightGroup::next_light_up(TLightGroup* __hidden this); // idb
int __thiscall TLightGroup::next_light_down(TLightGroup* __hidden this); // idb
void __thiscall TLightGroup::start_animation(TLightGroup* __hidden this); // idb
void TLightGroup::NotifyTimerExpired(int, void*); // idb
int __thiscall TLightGroup::Message(TLightGroup* this, int, float); // idb
TLightGroup* __thiscall TLightGroup::TLightGroup(TLightGroup* this, struct TPinballTable* a2, int a3);
TLightGroup* __thiscall TLightGroup::destroy(TLightGroup *this, char a2);
void* TLightGroup::vftable = &TLightGroup::Message; // weak
#endif //PINBALL_TLIGHTGROUP_H
|
madebr/3d-pinball-space-cadet | Classes/TBumper/TBumper.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TBUMPER_H
#define PINBALL_TBUMPER_H
/* 104 */
struct TBumper;
void TBumper::TimerExpired(int, void*); // idb
void __thiscall TBumper::Fire(TBumper* this); // idb
int __thiscall TBumper::Message(TBumper* this, int, float); // idb
int __thiscall TBumper::get_scoring(TBumper* this, int); // idb
void __thiscall TBumper::put_scoring(TBumper* this, int, int); // idb
void __thiscall TBumper::Collision(TBumper* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TBumper* __thiscall TBumper::TBumper(TBumper* this, struct TPinballTable* a2, int a3);
void* TBumper::vftable = &TBumper::Message; // weak
#endif //PINBALL_TBUMPER_H
|
madebr/3d-pinball-space-cadet | pinball.h | <gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "Classes/classes.h"
#include <SDL.h>
#include <d3d.h>
#ifdef _WIN32
#include <CommCtrl.h>
#include <Vfw.h>
#include <gdiplus.h>
#include <WinUser.h>
#include <Windows.h>
#endif
#ifndef PINBALL_PINBALL_H
#define PINBALL_PINBALL_H
/*
This file has been generated by IDA.
It contains local type definitions from
the type library 'pinball'
*/
//-------------------------------------------------------------------------
// Function declarations
#define __thiscall __cdecl // Test compile in C mode
#ifdef _DEBUG
void RedirectIOToConsole();
// guicon.cpp
#endif
HDC _GetDC(HWND hWnd);
HDC _BeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
CHAR *options_path_init(LPCSTR lpString);
void options_path_uninit();
LPCSTR options_path(LPCSTR lpString2);
void options_path_free();
HKEY options_get_int(DWORD cbData, LPCSTR lpValueName, HKEY phkResult);
void options_get_string(DWORD dwDisposition, LPCSTR lpValueName, LPSTR lpString1, LPCSTR lpString2, int iMaxLength);
void options_set_int(HKEY phkResult, LPCSTR lpValueName, BYTE Data);
void options_set_string(HKEY phkResult, LPCSTR lpValueName, LPCSTR lpString);
CHAR *get_rc_string(int a1, int a2);
int get_rc_int(int a1, int *a2);
int grtext_draw_ttext_in_box(LPCSTR lpString, int mode, int, COLORREF color, int, int); // idb
int sub_10038F8();
LONG sub_1003975();
LONG sub_100399D();
BOOL fullscrn_set_menu_mode(int a1);
signed int sub_1003A23();
int sub_1003B66();
LONG fullscrn_set_screen_mode(int a1);
void fullscrn_force_redraw();
signed int fullscrn_displaychange();
BOOL fullscrn_init(int a1, int a2, int a3, HWND a4, int a5, int a6);
LONG fullscrn_shutdown();
BOOL fullscrn_activate(int a1);
int fullscrn_convert_mouse_pos(int a1);
DWORD *fullscrn_getminmaxinfo(DWORD *a1);
HBRUSH sub_1003F10(LONG a1, LONG a2, int a3, int a4);
void fullscrn_paint();
signed int rectangle_clip(int *a1, int *a2, DWORD *a3);
int enclosing_box(DWORD *a1, DWORD *a2, DWORD *a3);
int DibSetUsage(int, HPALETTE hpal, int); // idb
DWORD *DibCreate(int a1, int a2, int a3);
int gdrv_init(int a1, HWND a2);
int gdrv_display_palette(int a1);
int gdrv_uninit();
int gdrv_create_bitmap_dib(int a1, int a2, int a3);
int gdrv_create_bitmap(int a1, int a2, int a3);
signed int gdrv_create_raw_bitmap(int a1, int a2, int a3, int a4);
signed int gdrv_destroy_bitmap(int a1);
UINT gdrv_start_blit_sequence();
int gdrv_blit_sequence(int, int xSrc, int, int xDest, int yDest, int DestWidth, int DestHeight); // idb
int gdrv_end_blit_sequence();
HDC gdrv_blit(int a1, int xSrc, int a3, int xDest, int yDest, int DestWidth, int DestHeight);
int gdrv_blat(int, int xDest, int yDest); // idb
int gdrv_fill_bitmap(int a1, DWORD *a2, unsigned int a3, int a4, int a5, int a6, char a7);
char *gdrv_copy_bitmap(DWORD *a1, int a2, int a3, int a4, int a5, DWORD *a6, int a7, int a8);
_BYTE *gdrv_copy_bitmap_w_transparency(DWORD *a1, int a2, int a3, int a4, int a5, DWORD *a6, int a7, int a8);
int zdrv_pad(int a1);
signed int zdrv_create_zmap(int a1, int a2, int a3);
signed int zdrv_destroy_zmap(DWORD *a1);
int zdrv_fill(int a1, int a2, unsigned int a3, int a4, int a5, int a6, int a7);
WORD *zdrv_paint(int a1, int a2, DWORD *a3, int a4, int a5, int a6, int a7, int a8, DWORD *a9, int a10, int a11, int a12, int a13, int a14);
unsigned int *zdrv_paint_flat(int a1, int a2, DWORD *a3, int a4, int a5, int a6, int a7, int a8, DWORD *a9, int a10, int a11, unsigned int a12);
int high_score_clear_table(int a1);
signed int high_score_get_score_position(int a1, int a2);
int high_score_place_new_score_into(int, int, LPCSTR lpString, int); // idb
char *scramble_number_string(int Val, char *DstBuf);
signed int high_score_read(int a1, int a2);
int high_score_write(LPCSTR lpString, int); // idb
char *score_string_format(int a1, char *a2);
void hsdlg_show_score(HWND hDlg, LPCSTR lpString, int a3, int a4);
void show_high_scores(HWND hDlg, LPCSTR lpString);
BOOL HighScore(HWND, UINT, WPARAM, LPARAM); // idb
INT_PTR show_high_score_dialog(const CHAR *a1);
INT_PTR show_and_set_high_score_dialog(const CHAR *a1, int a2, int a3, const CHAR *a4);
int memory_init(int a1);
int memoryallocate(unsigned int a1);
void memoryfree(int a1);
int memoryrealloc(int a1, unsigned int a2);
void options_uninit();
HMENU options_menu_set(UINT uIDEnableItem, int a2);
HMENU options_menu_check(UINT uIDCheckItem, int a2);
HMENU options_toggle(UINT uIDCheckItem);
unsigned int get_vk_key_name(int a1, LPSTR lpString);
BOOL KeyMapDlgProc(HWND, UINT, WPARAM, LPARAM); // idb
INT_PTR options_keyboard();
void options_init(HMENU a1);
int partman_field(int a1, int a2, int a3);
int partman_field_size_nth(int a1, int a2, int a3, int a4);
int partman_field_size(int a1, int a2, int a3);
int partman_field_nth(int a1, int a2, int a3, int a4);
int partman_record_labeled(int, LPCSTR lpString); // idb
int partman_field_labeled(int, LPCSTR lpString, int); // idb
void partman_unload_records(WORD *a1);
char lread_char(HFILE hFile);
int lread_long(HFILE hFile); // idb
signed int *partman_load_records(LPCSTR lpFileName);
int FindShiftKeys();
int nullsub_1(int, int, int); // weak
LRESULT SoundCallBackWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
int Sound_Init(HINSTANCE hInstance, int, int); // idb
HLOCAL Sound_Close();
CHAR *Sound_LoadWaveFile(LPCSTR lpName);
LPCVOID Sound_FreeSound(LPCVOID pMem);
LPCVOID Sound_Deactivate();
LPCVOID Sound_Activate();
int Sound_Idle();
signed int Sound_Flush(signed int a1, int a2);
void Sound_PlaySound(int a1, int a2, int a3, unsigned int a4, int a5);
void Sound_Enable(signed int a1, int a2, int a3);
HPALETTE splash_init_palette(LOGPALETTE *plpal);
HBITMAP load_title_bitmap(HMODULE hModule, HDC hdc, LPCSTR lpName, UINT iStart, int a5, int a6);
int splash_bitmap_setup(int a1);
void splash_paint(int a1, HDC hdc);
void splash_hide(int a1);
HINSTANCE splash_destroy(int a1);
LRESULT splash_message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
int splash_screen(int, LPCSTR lpString2, LPCSTR); // idb
signed int timer_init(int a1);
void timer_uninit();
int timer_set(float, int, int); // idb
signed int timer_check();
int timer_kill(int a1);
int make_path_name(LPSTR lpFilename, LPCSTR lpString2, DWORD nSize); // idb
void help_introduction(int a1, int a2);
BOOL center_in(HWND hWnd, HWND a2);
INT a_dialog(HINSTANCE hInstance, HWND hWnd, int a3);
void winmain_pause(int a1);
void winmain_end_pause(int a1);
HCURSOR winmain_new_game(int a1);
void winmain_memalloc_failure(); // idb
HANDLE adjust_priority(int a1);
LRESULT message_handler(HWND hWnd, UINT Msg, WPARAM wParam, int a4);
signed int message_loop();
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
double normalize_2d(float *a1);
double ray_intersect_circle(float *a1, float *a2);
int line_init(int, float, float, float, float); // idb
double ray_intersect_line(float *a1, float *a2);
float *proj_matrix_vector_multiply(float *a1, float *a2, float *a3);
float *cross(float *a1, float *a2, float *a3);
double magnitude(float *a1);
int proj_init(int a1, int a2, int a3, int a4);
int proj_recenter(int a1, int a2);
double proj_z_distance(DWORD); // weak
double proj_xform_to_2d(float *a1, DWORD *a2);
signed int loader_error(int a1, int a2);
DWORD *loader_default_vsi(DWORD *a1);
signed int loader_get_sound_id(int a1);
void loader_unload();
int loader_loadfrom(WORD *a1);
int loader_query_handle(LPCSTR lpString); // idb
signed int loader_query_visual_states(int a1);
signed int loader_material(int a1, DWORD *a2);
signed int loader_kicker(int a1, DWORD *a2);
signed int loader_state_id(int a1, signed int a2);
signed int loader_query_visual(int a1, signed int a2, DWORD *a3);
int loader_query_name(int a1);
int loader_query_float_attribute(int a1, signed int a2, int a3);
int loader_query_iattribute(int a1, int a2, DWORD *a3);
double loader_play_sound(int a1);
void flasher_callback(int, void *); // idb
void flasher_start(flasher_type *, int); // idb
void flasher_stop(flasher_type *, int); // idb
int midi_music_init(HWND a1);
MCIERROR midi_music_shutdown();
MCIERROR midi_music_stop();
MCIERROR midi_play_pb_theme(int a1);
HWND restart_midi_seq(int a1);
void create(void *, unsigned int, int, void *(__thiscall *)(void *)); // idb
void destroy(void *, unsigned int, int, void (__thiscall *)(void *)); // idb
void edges_insert_circle(circle_type *, TEdgeSegment *, field_effect_type *); // idb
void edges_insert_square(float, float, float, float, TEdgeSegment *, field_effect_type *); // idb
TPinballComponent *make_component_link(component_tag *); // idb
void control_make_links(TPinballTable *); // idb
BOOL light_on(component_tag *a1);
void table_control_handler(int); // idb
void table_set_replay(int a1, float a2);
void table_set_multiball(int a1);
void table_set_jackpot(int a1);
void table_set_bonus(int a1);
void table_set_flag_lights(int a1);
void table_set_bonus_hold(int a1);
void table_bump_ball_sink_lock(int a1);
void table_add_extra_ball(int a1, float a2);
int SpecialAddScore(int); // idb
void AdvanceWormHoleDestination(int); // idb
void FlipperRebounderControl1(int, TPinballComponent *); // idb
void FlipperRebounderControl2(int, TPinballComponent *); // idb
void RebounderControl(int, TPinballComponent *); // idb
void BumperControl(int, TPinballComponent *); // idb
void LeftKickerControl(int, TPinballComponent *); // idb
void RightKickerControl(int, TPinballComponent *); // idb
void LeftKickerGateControl(int, TPinballComponent *); // idb
void RightKickerGateControl(int, TPinballComponent *); // idb
void DeploymentChuteToEscapeChuteOneWayControl(int a1, int a2, int a3, TPinballComponent *a4);
void DeploymentChuteToTableOneWayControl(int, TPinballComponent *); // idb
void DrainBallBlockerControl(int, TPinballComponent *); // idb
void LaunchRampControl(int a1, int a2, TPinballComponent *a3);
void LaunchRampHoleControl(int, TPinballComponent *); // idb
void SpaceWarpRolloverControl(int, TPinballComponent *); // idb
void ReentryLanesRolloverControl(int a1, int a2, int a3, int a4, TPinballComponent *a5);
void BumperGroupControl(int, TPinballComponent *); // idb
void LaunchLanesRolloverControl(int a1, int a2, int a3, int a4, TPinballComponent *a5);
void OutLaneRolloverControl(int a1, int a2, int a3, TPinballComponent *a4);
void ExtraBallLightControl(int, TPinballComponent *); // idb
void ReturnLaneRolloverControl(int a1, int a2, TPinballComponent *a3);
void BonusLaneRolloverControl(int a1, int a2, TPinballComponent *a3);
void FuelRollover1Control(int a1, int a2, TPinballComponent *a3);
void FuelRollover2Control(int a1, int a2, TPinballComponent *a3);
void FuelRollover3Control(int a1, int a2, TPinballComponent *a3);
void FuelRollover4Control(int a1, int a2, TPinballComponent *a3);
void FuelRollover5Control(int a1, int a2, TPinballComponent *a3);
void FuelRollover6Control(int a1, int a2, TPinballComponent *a3);
void HyperspaceLightGroupControl(int, TPinballComponent *); // idb
void WormHoleControl(int a1, int a2, int a3, int a4, TPinballComponent *a5);
void LeftFlipperControl(int, TPinballComponent *); // idb
void RightFlipperControl(int, TPinballComponent *); // idb
void JackpotLightControl(int, TPinballComponent *); // idb
void BonusLightControl(int, TPinballComponent *); // idb
void BoosterTargetControl(int, TPinballComponent *); // idb
void MedalLightGroupControl(int, TPinballComponent *); // idb
void MultiplierLightGroupControl(int a1, int a2, TPinballComponent *a3);
void FuelSpotTargetControl(int a1, int a2, TPinballComponent *a3);
void MissionSpotTargetControl(int a1, int a2, TPinballComponent *a3);
void LeftHazardSpotTargetControl(int, TPinballComponent *); // idb
void RightHazardSpotTargetControl(int, TPinballComponent *); // idb
void WormHoleDestinationControl(int a1, int a2, TPinballComponent *a3);
void BlackHoleKickoutControl(int a1, int a2, TPinballComponent *a3);
void FlagControl(int, TPinballComponent *); // idb
void GravityWellKickoutControl(int a1, int a2, TPinballComponent *a3);
void SkillShotGate1Control(int, TPinballComponent *); // idb
void SkillShotGate2Control(int, TPinballComponent *); // idb
void SkillShotGate3Control(int, TPinballComponent *); // idb
void SkillShotGate4Control(int, TPinballComponent *); // idb
void SkillShotGate5Control(int, TPinballComponent *); // idb
void SkillShotGate6Control(int, TPinballComponent *); // idb
void ShootAgainLightControl(int, TPinballComponent *); // idb
void EscapeChuteSinkControl(int, TPinballComponent *); // idb
int cheat_bump_rank(int a1);
void pbctrl_bdoor_controller(int a1, int a2);
int AddRankProgress(int); // idb
void WaitingDeploymentController(int a1, int a2, TPinballComponent *a3);
void SelectMissionController(int, TPinballComponent *); // idb
void PracticeMissionController(int a1, int a2, TPinballComponent *a3);
void LaunchTrainingController(int a1, int a2, TPinballComponent *a3);
void ReentryTrainingController(int a1, int a2, TPinballComponent *a3);
void ScienceMissionController(int a1, int a2, TPinballComponent *a3);
void StrayCometController(int a1, int a2, TPinballComponent *a3);
void SpaceRadiationController(int a1, int a2, TPinballComponent *a3);
void BlackHoleThreatController(int a1, int a2, TPinballComponent *a3);
void BugHuntController(int a1, int a2, TPinballComponent *a3);
void RescueMissionController(int a1, int a2, TPinballComponent *a3);
void AlienMenaceController(int a1, int a2, TPinballComponent *a3);
void AlienMenacePartTwoController(int a1, int a2, TPinballComponent *a3);
void SatelliteController(int a1, int a2, TPinballComponent *a3);
void ReconnaissanceController(int a1, int a2, TPinballComponent *a3);
void DoomsdayMachineController(int a1, int a2, TPinballComponent *a3);
void CosmicPlagueController(int a1, int a2, TPinballComponent *a3);
void CosmicPlaguePartTwoController(int a1, int a2, TPinballComponent *a3);
void SecretMissionYellowController(int a1, int a2, TPinballComponent *a3);
void SecretMissionRedController(int a1, int a2, TPinballComponent *a3);
void SecretMissionGreenController(int a1, int a2, TPinballComponent *a3);
void TimeWarpController(int a1, int a2, TPinballComponent *a3);
void TimeWarpPartTwoController(int a1, int a2, TPinballComponent *a3);
void MaelstromController(int a1, int a2, TPinballComponent *a3);
void MaelstromPartTwoController(int a1, int a2, TPinballComponent *a3);
void MaelstromPartThreeController(int a1, int a2, TPinballComponent *a3);
void MaelstromPartFourController(int a1, int a2, TPinballComponent *a3);
void MaelstromPartFiveController(int a1, int a2, TPinballComponent *a3);
void MaelstromPartSixController(int a1, int a2, TPinballComponent *a3);
void MaelstromPartSevenController(int a1, int a2, TPinballComponent *a3);
void MaelstromPartEightController(int a1, int a2, TPinballComponent *a3);
void GameoverController(int, TPinballComponent *); // idb
void UnselectMissionController(int, TPinballComponent *); // idb
void MissionControl(int, TPinballComponent *); // idb
void control_handler(int, TPinballComponent *); // idb
void HyperspaceKickOutControl(int, TPinballComponent *); // idb
void PlungerControl(int a1, int a2, TPinballComponent *a3);
void MedalTargetControl(int a1, int a2, int a3, int a4, TPinballComponent *a5);
void MultiplierTargetControl(int a1, int a2, int a3, int a4, TPinballComponent *a5);
void BallDrainControl(int, TPinballComponent *); // idb
int objlist_add_object(DWORD *a1, int a2);
signed int objlist_delete_object(int a1, int a2);
DWORD *objlist_new(int a1);
int *objlist_grow(int *a1, int a2);
void build_occlude_list();
void render_repaint(render_sprite_type_struct *); // idb
void render_paint_balls(); // idb
void render_unpaint_balls(); // idb
int render_remove_sprite(render_sprite_type_struct *); // idb
int render_remove_ball(render_sprite_type_struct *); // idb
BOOL overlapping_box(rectangle_type *a1, rectangle_type *a2, rectangle_type *a3);
void render_update();
void render_uninit();
char *render_init(DWORD *a1, float a2, float a3, int a4, int a5);
int render_sprite_modified(int a1);
int render_create_sprite(int a1, int a2, int a3, int a4, int a5, DWORD *a6);
int render_set_background_zmap(zmap_header_type *a1, int a2, int a3);
int render_sprite_set(DWORD *a1, int a2, int a3, int a4, int a5);
void render_sprite_set_bitmap(DWORD *a1, int a2);
void render_ball_set(int a1, int a2, float a3, int a4, int a5);
void render_paint();
void render_shift(int a1, int a2, int xSrc, int a4, int DestWidth, int DestHeight);
DWORD *score_create(LPCSTR lpString, int a2);
void *score_dup(const void *a1, int a2);
void objlist_destroy(int a1);
DWORD *score_set(DWORD *a1, int a2);
void *score_erase(int a1, DWORD *a2, int a3);
HDC score_update(int a1, int *a2);
signed int score_init();
void score_unload_msg_font();
HRSRC score_load_msg_font(LPCSTR lpName);
DWORD pb_paint(); // idb
signed int pb_mode_change(int a1);
signed int pb_mode_countdown(int a1);
int pb_end_game();
signed int pb_chk_highscore();
long double pb_collide(TEdgeSegment *a1, float a2, TBall *a3);
void pb_timed_frame(float, float, int); // idb
signed int pb_frame(int a1, int a2);
void pb_firsttime_setup();
TPinballTable *pb_tilt_no_more(int a1);
void pb_ballset(signed int a1, signed int a2);
void nudge(float, float); // idb
void un_nudge_left(int, void *); // idb
void un_nudge_right(int, void *); // idb
void nudge_left(); // idb
void nudge_right(); // idb
void un_nudge_up(int, void *); // idb
void nudge_up(); // idb
void pb_keydown(HKEY a1);
void pb_keyup(HKEY a1);
int pb_replay_level(int a1);
INT_PTR pb_high_scores();
DWORD *pb_window_size(DWORD *a1, DWORD *a2);
int pb_init();
int pb_uninit();
int pb_loose_focus();
void pb_pause_continue(int a1);
int pb_launch_ball();
int pb_reset_table();
void pb_toggle_demo(int a1);
DWORD gdrv_get_focus(); // idb
void throw_ball(TBall *, vector_type *, float, float, float); // idb
void find_closest_edge(ramp_plane_type *, int, wall_point_type *, vector_type **, vector_type **); // idb
double basic_collision(TBall *a1, vector_type *a2, vector_type *a3, float a4, float a5, float a6, float a7);
TEdgeSegment *install_wall(float *, TCollisionComponent *, char *, unsigned int, float, void *); // idb
void vswap(vector_type *, vector_type *); // idb
double distance_to_flipper(ray_type *a1, ray_type *a2);
void vector_add(vector_type *, vector_type *); // idb
void RotatePt(vector_type *, float, float, vector_type *); // idb
long double Distance(vector_type *a1, vector_type *a2);
double Distance_Squared(float a1, float a2, int a3, float a4, float a5, int a6);
double DotProduct(const vector_type *a1, const vector_type *a2);
void SinCos(float, float *, float *); // idb
void RotateVector(vector_type *, float); // idb
int sub_101CEB6(LPBYTE lpData); // idb
HWND HtmlHelpA(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData);
WORD *SessionToGlobalDataPtr(WORD *a1);
BOOL IsValidLPMIXWAVE(int a1);
bool HasCurrentOutputFormat(const void *a1);
int DefaultPauseBlocks(int a1);
unsigned int DefaultGoodWavePos(UINT_PTR uDeviceID);
DWORD MyWaveOutGetPosition(HWAVEOUT hwo, int a2);
int AddFactor(int a1, int a2);
int SubFactor(int a1, int a2);
unsigned int SetWaveOutPosition(unsigned int a1);
unsigned int MyWaveOutReset(HWAVEOUT hwo);
int cmixit(_BYTE *a1, char *a2, char *a3, int a4, unsigned int a5);
DWORD *InitChannelNodes();
int GetChannelNode();
DWORD *FreeChannelNode(DWORD *a1);
wavehdr_tag *FreeWaveBlocks(HWAVEOUT hwo, int a2);
int AllocWaveBlocks(HWAVEOUT hwo, int); // idb
DWORD *SwapWaveBlocks();
DWORD *GetWaveBlock();
wavehdr_tag *RemoveFromPlayingQueue(wavehdr_tag *a1);
LPWAVEHDR DestroyPlayQueue();
int ReleaseWaveDevice(int a1);
signed int GetWaveDevice();
signed int WaveMixOpenChannel(WORD *a1, signed int a2, unsigned int a3);
LPWAVEHDR AddToPlayingQueue(wavehdr_tag *a1);
int MixerPlay(LPWAVEHDR pwh, int); // idb
DWORD FreePlayedBlocks();
int WaveMixPump();
LRESULT WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
signed int NoResetRemix(int a1, int a2);
signed int ResetRemix(int a1, int a2);
void ResetWavePosIfNoChannelData();
signed int WaveMixPlay(int a1);
signed int WaveMixFlushChannel(WORD *a1, signed int a2, char a3);
signed int WaveMixCloseChannel(WORD *a1, signed int a2, char a3);
int WaveMixFreeWave(int, LPCVOID pMem); // idb
// WORD *BitsPerSampleAlign(int a1, LPCVOID pMem, int a3, int a4, int a5);
_BYTE *ChannelAlign(LPCVOID pMem, int a2, int a3, int a4, int a5);
void AvgSample(WORD *a1, unsigned __int8 *a2, int a3, int a4, int a5);
int RepSample(_BYTE *a1, unsigned __int8 *a2, signed int a3, int a4, int a5);
LPCVOID SamplesPerSecAlign(LPCVOID pMem, int a2, int a3, int a4, int a5, int a6);
LPCVOID WaveFormatConvert(int a1, int a2, LPCVOID pMem, int a4);
CHAR *WaveMixOpenWave(LPCVOID pMem, LPCSTR lpName, HMODULE hModule, LONG cch);
unsigned int FigureOutDMABufferSize(unsigned int a1, int a2);
int RemoveInvalidIniNameCharacters(LPCSTR lpString); // idb
UINT ShowWaveOutDevices();
const char *GetOperatingSystemPrefix();
int ReadRegistryToGetMachineSpecificInfSection(int, LPSTR lpString1, int); // idb
int ReadRegistryInt(HKEY hKey, LPCSTR lpSubKey, int); // idb
signed int ReadRegistryForAppSpecificConfigs(int a1);
int ShowCurrentSettings();
int Settings_OnInitDialog(HWND hWnd, int, int); // idb
int Settings_OnCommand(HWND hWnd, int, int, int); // idb
BOOL SettingsDlgProc(HWND, UINT, WPARAM, LPARAM); // idb
DWORD *MakeDlgTemplate(int a1, int a2, int a3, int a4, int a5, int a6, wchar_t *Str);
WORD *AddDlgControl(int a1, LPCVOID pMem, int a3, int a4, int a5, int a6, int a7, int a8, int a9, wchar_t *Str);
WORD *MakeSettingsDlgTemplate();
void DestroySettingsDlgTemplate(LPCVOID pMem);
signed int WaveMixGetConfig(WORD *a1, int a2);
BOOL SaveConfigSettings(int a1);
DWORD SetIniFileName(HMODULE hModule);
int InitVolumeTable();
int WaveMixStartup(HMODULE hModule); // idb
signed int WaveMixActivate(WORD *a1, int a2);
MMRESULT WaveMixConfigure(int a1, HWND hWndParent, int a3, int a4, int a5);
signed int ReadConfigSettings(int a1);
int WaveMixConfigureInit(WORD *a1);
int WaveMixInit();
HLOCAL WaveMixCloseSession(HLOCAL hMem);
int WinMainCRTStartup();
void component_delete(void *); idb
void *component_create(unsigned int); idb
int _initterm(DWORD, DWORD); weak
unsigned int _setdefaultprecision();
int check_expiration_date();
// unsigned int __cdecl _controlfp(unsigned int NewValue, unsigned int Mask);
//-------------------------------------------------------------------------
// Data declarations
// extern _UNKNOWN __acmdln; weak
// extern _UNKNOWN __adjust_fdiv; weak
CHAR WindowName[2] = { '\0', '\0' }; // idb
int gpFormat[4] = { 65537, 11025, 11025, 524289 }; // weak
_UNKNOWN __xc_a; // weak
_UNKNOWN __xc_z; // weak
_UNKNOWN __xi_a; // weak
_UNKNOWN __xi_z; // weak
int grtext_red = 4294967295; // weak
int trick = 1; // weak
LOGPALETTE current_palette = { 768u, 256u, { { 0u, 0u, 0u, 0u } } }; // idb
_UNKNOWN unk_102305B; // weak
PALETTEENTRY pPalEntries = { 0u, 0u, 0u, 0u }; // idb
char byte_1023458 = '\0'; // weak
char byte_1023459 = '\0'; // weak
char byte_102345A = '\0'; // weak
_UNKNOWN unk_102345F; // weak
_UNKNOWN unk_1023460; // weak
int vk_list = 32833; // weak
_UNKNOWN unk_1023540; // weak
int field_size[14] =
{
2,
65535,
2,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
65535,
0
}; // idb
int LeftShift = 4294967295; // weak
int RightShift = 4294967295; // weak
int dword_10235F4 = 1; // weak
int loader_errors[] = { 0 }; // weak
char *error_messages[54] =
{
"Bad Handle",
(char *)1,
"No Type Field",
(char *)2,
"No Attributes Field",
(char *)0xB,
"No float Attributes Field",
(char *)3,
"Wrong Type: MATERIAL Expected",
(char *)4,
"Wrong Type: KICKER Expected",
(char *)5,
"Wrong Type: AN_OBJECT Expected",
(char *)6,
"Wrong Type: A_STATE Expected",
(char *)7,
"STATES (re)defined in a state",
(char *)9,
"Unrecognized Attribute",
(char *)0xA,
"Unrecognized float Attribute",
(char *)0xD,
"float Attribute not found",
(char *)0xC,
"state_index out of range",
(char *)0xF,
"loader_material() reports failure",
(char *)0xE,
"loader_kicker() reports failure",
(char *)0x10,
"loader_state_id() reports failure",
(char *)8,
"# walls doesn't match data size",
(char *)0x11,
"loader_query_visual_states()",
(char *)0x12,
"loader_query_visual()",
(char *)0x15,
"loader_material()",
(char *)0x14,
"loader_kicker()",
(char *)0x16,
"loader_query_attribute()",
(char *)0x17,
"loader_query_iattribute()",
(char *)0x13,
"loader_query_name()",
(char *)0x18,
"loader_state_id()",
(char *)0x19,
"loader_get_sound_id()",
(char *)0x1A,
"sound reference is not A_SOUND record",
(char *)0xFFFFFFFF
}; // idb
int sound_count = 1; // weak
int dword_10236E4 = 0; // weak
int dword_10236EC = 0; // weak
int dword_10236F4 = 0; // weak
int dword_10236FC = 0; // weak
int dword_1023704 = 0; // weak
int dword_102370C = 0; // weak
int dword_1023714 = 0; // weak
int dword_102371C = 0; // weak
int dword_1023724 = 0; // weak
int dword_102372C = 0; // weak
int dword_1023734 = 0; // weak
int dword_102373C = 0; // weak
int dword_1023758 = 0; // weak
int dword_1023770 = 0; // weak
int dword_1023778 = 0; // weak
int dword_1023780 = 0; // weak
int dword_1023788 = 0; // weak
int dword_1023790 = 0; // weak
int dword_1023798 = 0; // weak
int dword_10237A0 = 0; // weak
int dword_10237A8 = 0; // weak
int dword_10237C4 = 0; // weak
int dword_10237CC = 0; // weak
int dword_10237D4 = 0; // weak
int dword_10237DC = 0; // weak
int dword_10237E8 = 0; // weak
int dword_10237F0 = 0; // weak
int dword_1023808 = 0; // weak
int dword_1023810 = 0; // weak
char *lite30 = "lite30"; // weak
int dword_1023818 = 0; // weak
char *lite29 = "lite29"; // weak
int dword_1023820 = 0; // weak
int dword_1023828 = 0; // weak
int dword_1023830 = 0; // weak
int dword_1023838 = 0; // weak
int dword_1023840 = 0; // weak
TPinballComponent *dword_1023860 = NULL; // idb
int dword_1023868 = 0; // weak
int dword_1023870 = 0; // weak
char *lite54 = "lite54"; // weak
int dword_1023878 = 0; // weak
char *lite55 = "lite55"; // weak
int dword_1023880 = 0; // weak
char *lite56 = "lite56"; // weak
int dword_1023888 = 0; // weak
int dword_102389C = 0; // weak
int dword_10238A4 = 0; // weak
char *lite17 = "lite17"; // weak
int dword_10238AC = 0; // weak
char *lite18 = "lite18"; // weak
int dword_10238B4 = 0; // weak
int dword_10238C0 = 0; // weak
int dword_10238C8 = 0; // weak
char *lite27 = "lite27"; // weak
int dword_10238D0 = 0; // weak
char *lite28 = "lite28"; // weak
int dword_10238D8 = 0; // weak
int dword_10238E8 = 0; // weak
char *lite16 = "lite16"; // weak
int dword_10238F0 = 0; // weak
int dword_1023924 = 0; // weak
int dword_1023930 = 0; // weak
char *lite20 = "lite20"; // weak
int dword_1023940 = 0; // weak
int dword_1023948 = 0; // weak
int dword_1023950 = 0; // weak
int dword_1023958 = 0; // weak
int dword_1023960 = 0; // weak
int dword_1023968 = 0; // weak
int dword_1023970 = 0; // weak
int dword_1023978 = 0; // weak
int dword_1023980 = 0; // weak
TPinballComponent *dword_10239A8 = NULL; // idb
char *lite25 = "lite25"; // weak
int dword_10239B0 = 0; // weak
char *lite26 = "lite26"; // weak
int dword_10239B8 = 0; // weak
char *lite130 = "lite130"; // weak
int dword_10239C0 = 0; // weak
int dword_10239C8 = 0; // weak
int dword_10239D0 = 0; // weak
int dword_10239EC = 0; // weak
int dword_10239F4 = 0; // weak
int dword_10239FC = 0; // weak
int dword_1023A04 = 0; // weak
int dword_1023A0C = 0; // weak
int dword_1023A14 = 0; // weak
int dword_1023A1C = 0; // weak
char *lite4 = "lite4"; // weak
int dword_1023A24 = 0; // weak
int dword_1023A2C = 0; // weak
int dword_1023A34 = 0; // weak
int dword_1023A3C = 0; // weak
char **some_parts[9] =
{
&off_10239E8,
&off_10239F0,
&off_10239F8,
&off_1023A00,
&off_1023A08,
&off_1023A10,
&lite4,
&off_1023A28,
&off_1023A30
}; // weak
char **off_1023A4C[6] =
{
&off_1023A00,
&off_1023A08,
&off_1023A10,
&lite4,
&off_1023A28,
&off_1023A30
}; // weak
char **off_1023A58[3] = { &lite4, &off_1023A28, &off_1023A30 }; // weak
int dword_1023A74 = 0; // weak
int dword_1023A7C = 0; // weak
int dword_1023A84 = 0; // weak
int dword_1023A8C = 0; // weak
int dword_1023A94 = 0; // weak
int dword_1023A9C = 0; // weak
int dword_1023AA4 = 0; // weak
int dword_1023AAC = 0; // weak
char *lite61 = "lite61"; // weak
int dword_1023AB4 = 0; // weak
char *lite60 = "lite60"; // weak
int dword_1023ABC = 0; // weak
char *lite59 = "lite59"; // weak
int dword_1023AC4 = 0; // weak
char *lite58 = "lite58"; // weak
int dword_1023ACC = 0; // weak
int dword_1023ADC = 0; // weak
int dword_1023AE4 = 0; // weak
int dword_1023AEC = 0; // weak
TPinballComponent *dword_1023B0C = NULL; // idb
int dword_1023B20 = 0; // weak
int dword_1023B28 = 0; // weak
int dword_1023B30 = 0; // weak
TPinballComponent *dword_1023B38 = NULL; // idb
int dword_1023B48 = 0; // weak
int dword_1023B50 = 0; // weak
int dword_1023B58 = 0; // weak
int dword_1023B60 = 0; // weak
int dword_1023B68 = 0; // weak
int dword_1023B70 = 0; // weak
int dword_1023B78 = 0; // weak
int dword_1023B84 = 0; // weak
int dword_1023B8C = 0; // weak
int dword_1023B94 = 0; // weak
int dword_1023B9C = 0; // weak
int dword_1023BA4 = 0; // weak
int dword_1023BAC = 0; // weak
int dword_1023BB4 = 0; // weak
char *lite198 = "lite198"; // weak
int dword_1023BBC = 0; // weak
int dword_1023BC8 = 0; // weak
int dword_1023BD0 = 0; // weak
int dword_1023BD8 = 0; // weak
int dword_1023BE0 = 0; // weak
int dword_1023BE8 = 0; // weak
int dword_1023BF0 = 0; // weak
int dword_1023BF8 = 0; // weak
int dword_1023C00 = 0; // weak
int dword_1023C08 = 0; // weak
int dword_1023C10 = 0; // weak
int dword_1023C18 = 0; // weak
int dword_1023C20 = 0; // weak
int dword_1023C28 = 0; // weak
int dword_1023C30 = 0; // weak
int dword_1023C3C = 0; // weak
char *lite110 = "lite110"; // weak
int dword_1023C44 = 0; // weak
int dword_1023C50 = 0; // weak
int dword_1023C5C = 0; // weak
int dword_1023C68 = 0; // weak
int dword_1023C70 = 0; // weak
int dword_1023C7C = 0; // weak
char *lite67 = "lite67"; // weak
int dword_1023CB4 = 0; // weak
int dword_1023CBC = 0; // weak
int dword_1023CC4 = 0; // weak
int dword_1023CCC = 0; // weak
int dword_1023CD4 = 0; // weak
int dword_1023CDC = 0; // weak
int dword_1023CE4 = 0; // weak
int dword_1023CEC = 0; // weak
int dword_1023CF4 = 0; // weak
int dword_1023CFC = 0; // weak
char *lite200 = "lite200"; // weak
int dword_1023D04 = 0; // weak
char *lite199 = "lite199"; // weak
int dword_1023D0C = 0; // weak
int dword_1023D14 = 0; // weak
int dword_1023D1C = 0; // weak
int dword_1023D24 = 0; // weak
int dword_1023D2C = 0; // weak
int dword_1023D34 = 0; // weak
int dword_1023D3C = 0; // weak
int dword_1023D44 = 0; // weak
int dword_1023D4C = 0; // weak
int dword_1023D54 = 0; // weak
int dword_1023D64 = 0; // weak
int dword_1023D6C = 0; // weak
int dword_1023D74 = 0; // weak
int dword_1023D7C = 0; // weak
int dword_1023D84 = 0; // weak
int dword_1023D8C = 0; // weak
int dword_1023D94 = 0; // weak
int dword_1023D9C = 0; // weak
int dword_1023DA4 = 0; // weak
int dword_1023DAC = 0; // weak
int dword_1023DB4 = 0; // weak
int dword_1023DBC = 0; // weak
int dword_1023DC4 = 0; // weak
int dword_1023DCC = 0; // weak
int dword_1023DD4 = 0; // weak
int dword_1023DDC = 0; // weak
int dword_1023DE4 = 0; // weak
int dword_1023DEC = 0; // weak
int dword_1023DF4 = 0; // weak
int dword_1023DFC = 0; // weak
int dword_1023E04 = 0; // weak
int dword_1023E0C = 0; // weak
int dword_1023E14 = 0; // weak
TTextBox *dword_1023E1C = NULL; // idb
TTextBox *tTextBox = NULL; // idb
int dword_1023E34 = 0; // weak
int dword_1023E3C = 0; // weak
int dword_1023E44 = 0; // weak
char *lite303 = "lite303"; // weak
int dword_1023E4C = 0; // weak
char *lite304 = "lite304"; // weak
int dword_1023E54 = 0; // weak
int dword_1023E5C = 0; // weak
int dword_1023E64 = 0; // weak
int dword_1023E6C = 0; // weak
int dword_1023E74 = 0; // weak
int dword_1023E7C = 0; // weak
int dword_1023E84 = 0; // weak
int dword_1023E8C = 0; // weak
int dword_1023E94 = 0; // weak
int dword_1023E9C = 0; // weak
char *lite314 = "lite314"; // weak
int dword_1023EA4 = 0; // weak
int dword_1023EAC = 0; // weak
char *lite316 = "lite316"; // weak
int dword_1023EB4 = 0; // weak
char *lite317 = "lite317"; // weak
int dword_1023EBC = 0; // weak
char *lite318 = "lite318"; // weak
int dword_1023EC4 = 0; // weak
char *lite319 = "lite319"; // weak
int dword_1023ECC = 0; // weak
int dword_1023ED4 = 0; // weak
int dword_1023EDC = 0; // weak
int dword_1023EE4 = 0; // weak
int dword_1023EEC = 0; // weak
_UNKNOWN unk_1023EF8; // weak
char **off_1024470[142] =
{
&off_1023708,
&off_1023710,
&off_1023718,
&off_1023720,
&off_1023774,
&off_102377C,
&off_1023784,
&off_102378C,
&lite30,
&lite29,
&off_1023864,
&lite54,
&lite55,
&lite56,
&lite18,
&lite27,
&lite28,
&lite16,
&off_1023984,
&off_102398C,
&off_1023994,
&off_102399C,
&lite25,
&lite26,
&lite130,
&off_1023A00,
&off_1023A08,
&off_1023A10,
&off_1023A18,
&lite4,
&off_1023A28,
&off_1023A30,
&off_1023A38,
&off_1023A88,
&off_1023A90,
&off_1023944,
&off_102394C,
&off_1023954,
&off_102395C,
&off_1023964,
&off_102396C,
&off_1023974,
&lite20,
&off_10239CC,
&lite61,
&lite58,
&off_1023AF0,
&off_1023AF8,
&off_1023B00,
&off_1023B5C,
&off_1023B64,
&off_1023B6C,
&off_1023B74,
&off_1023B98,
&off_1023BA0,
&off_1023BA8,
&off_1023BB0,
&off_1023BF4,
&off_1023BFC,
&off_1023C04,
&off_1023C0C,
&off_1023C14,
&off_1023C1C,
&off_1023C24,
&off_1023C2C,
&lite110,
&off_1023C6C,
&lite67,
&off_1023CB8,
&off_1023CC0,
&off_1023CC8,
&off_1023CD0,
&off_1023CD8,
&off_1023CE0,
&off_1023CE8,
&lite198,
&off_1023CF0,
&off_1023CF8,
&off_1023D10,
&off_1023D18,
&off_1023D20,
&off_1023D28,
&off_1023D30,
&off_1023D38,
&off_1023D40,
&off_1023D48,
&off_1023D58,
&off_1023D60,
&off_1023D68,
&off_1023D70,
&off_1023D78,
&off_1023D80,
&off_1023D88,
&off_1023D90,
&off_1023D98,
&off_1023DA0,
&off_1023DA8,
&off_1023DB0,
&off_1023DB8,
&off_1023DC0,
&off_1023DC8,
&off_1023DD0,
&off_1023DD8,
&off_1023DE0,
&lite199,
&off_1023824,
&off_102382C,
&off_1023E18,
&off_1023E20,
&off_1023DE8,
&off_10237D0,
&off_10237D8,
&off_1023DF0,
&off_1023DF8,
&off_1023E00,
&off_1023E08,
&off_1023E30,
&off_1023E38,
&off_1023E40,
&lite303,
&lite304,
&off_1023E58,
&off_1023E60,
&off_1023E68,
&off_1023E70,
&off_1023E78,
&off_1023E80,
&off_1023E88,
&off_1023E90,
&off_1023E98,
&lite314,
&off_1023EA8,
&lite316,
&lite317,
&lite318,
&lite319,
&off_1023ED0,
&off_1023ED8,
&off_1023EE0,
&off_1023EE8,
&off_1023D50,
&off_1023E10
}; // weak
int off_10246A0 = 16923984; // idb
int word_10246EC[] = { 84 }; // weak
int word_1024708[] = { 91 }; // weak
int render_blit = 1; // weak
int dword_1024758[5] = { 1, 2, 3, 5, 10 }; // idb
CHAR aWavemixV23ByAn[] = "WaveMix V 2.3 by <NAME>, Jr. (c) Microsoft 1993-1995"; // idb
LPCSTR lpString2 = NULL; // idb
LPSTR lpString1 = NULL; // idb
CHAR rc_strings[1536] = { '\0' }; // idb
int rc_string_slot; // weak
HWND hWnd; // idb
int dword_1024EC0; // weak
int dword_1024ED4; // weak
int dword_1024ED8; // weak
int dword_1024EDC; // weak
int dword_1024EE0; // weak
int fullscrn_screen_mode; // weak
int dword_1024EE8; // weak
int dword_1024EEC; // weak
int dword_1024EF0; // weak
int fullscrn_display_changed; // weak
int dword_1024EF8; // weak
int gdrv_use_wing; // weak
int memory_use_total; // weak
int memory_critical_allocation; // weak
int (*memory_critical_callback)(void); // weak
HMENU hMenu; // idb
int word_1024F18; // weak
int dword_1024F1C[8]; // idb
int dword_1024F3C[8]; // idb
LPCVOID pMem; // idb
HMODULE dword_1024F60; // idb
HWND dword_1024F64; // idb
int (*dword_1024F68)(DWORD, DWORD, DWORD); // weak
HINSTANCE hInstance; // idb
int dword_1024F70; // weak
int dword_1024F74; // weak
int dword_1024F78; // weak
int dword_1024F7C; // weak
int dword_1024F80; // weak
int time_ticks; // weak
char Dest[80]; // idb
int single_step; // weak
int bQuit; // weak
int DispFrameRate; // weak
int DispGRhistory; // weak
int mouse_down; // weak
int has_focus; // weak
int activated; // weak
int no_time_loss; // weak
int cheat_mode; // weak
int midi_seq1_open; // weak
int midi_seq1_playing; // weak
HWND midi_notify_hwnd; // weak
_UNKNOWN mci_open_info; // weak
MCIDEVICEID mciId; // idb
int dword_1025014; // weak
int dword_1025018; // weak
CHAR byte_1025020[28]; // idb
TEdgeManager *edge_manager; // idb
TPinballTable *dword_1025040; // idb
int dword_1025044; // weak
int dword_1025048; // weak
int dword_102504C; // weak
int dword_1025050; // weak
_UNKNOWN zscreen; // weak
int word_102505A; // weak
render_sprite_type_struct **render_dirty_list; // weak
render_sprite_type_struct **render_ball_list; // weak
int render_many_balls; // weak
_UNKNOWN vscreen_rect; // weak
int dword_1025078; // weak
int dword_102507C; // weak
int dword_1025080; // weak
render_sprite_type_struct **render_sprite_list; // weak
_UNKNOWN vscreen; // weak
int dword_1025094; // weak
int dword_1025098; // weak
int xDest; // idb
int yDest; // idb
float render_zscaler; // weak
int render_many_sprites; // weak
float render_zmax; // weak
float render_zmin; // weak
int render_many_dirty; // weak
_UNKNOWN ball_bitmap; // weak
int render_offset_x; // weak
int render_offset_y; // weak
int render_background_bitmap; // idb
zmap_header_type *render_background_zmap; // weak
_UNKNOWN render_zmap_offset; // weak
int dword_10253C0; // weak
score_msg_font_type *score_msg_fontp; // weak
float ball_speed_limit; // weak
_UNKNOWN pb_state; // weak
CHAR byte_102543C[300]; // idb
int dword_1025568; // weak
int play_midi_music; // weak
int dword_1025570; // weak
int dword_1025574; // weak
CHAR byte_1025578[32]; // idb
int dword_1025598[36]; // idb
float time_now; // weak
float time_next; // weak
int pb_record_table; // idb
int nudged_left; // weak
int nudged_right; // weak
int nudged_up; // weak
int nudge_timer; // weak
float nudge_count; // weak
TTextBox *InfoTextBox; // idb
TTextBox *MissTextBox; // idb
TPinballTable *MainTable; // idb
float flipper_sin_angle; // idb
_UNKNOWN circlebase; // weak
int dword_1025664; // weak
int dword_102566C; // weak
_UNKNOWN circleT1; // weak
int dword_1025674; // weak
int dword_102567C; // weak
_UNKNOWN lineA; // weak
float flt_1025684; // weak
_UNKNOWN unk_10256A4; // weak
float flipper_cos_angle; // idb
_UNKNOWN A2; // weak
float flt_10256B8; // weak
_UNKNOWN lineB; // weak
float flt_10256C4; // weak
_UNKNOWN unk_10256E4; // weak
_UNKNOWN B1; // weak
float flt_10256F4; // weak
_UNKNOWN B2; // weak
float flt_1025700; // weak
_UNKNOWN T1; // weak
int dword_102570C; // weak
_UNKNOWN A1; // weak
float flt_1025718; // weak
HWND (*pHtmlHelpA)(HWND, const char *, unsigned int, unsigned int); // weak
int dword_1025728; // weak
HMODULE hModule; // idb
int dword_1025730[16]; // idb
_UNKNOWN unk_1025770; // weak
int dword_1025798; // weak
int dword_10257A0[16]; // idb
HINSTANCE dword_10257E0; // idb
_UNKNOWN unk_10257E4; // weak
int word_1025810[]; // weak
int word_1025812[30]; // idb
CHAR FileName[276]; // idb
int dword_1025964; // weak
int dword_1025968; // weak
char byte_1025970[128]; // idb
_UNKNOWN unk_10259F0; // weak
_UNKNOWN unk_10263F0; // weak
_UNKNOWN unk_1026470; // weak
_UNKNOWN unk_1027B68; // weak
int dword_1027BA4; // weak
LPARAM hMem; // idb
int dword_1027BE4; // weak
int dword_1027BE8; // weak
LPWAVEHDR pwh; // idb
int dword_1027BF0; // weak
int dword_1027BF4; // weak
int dword_1027BF8; // weak
int _dowildcard; // weak
int _newmode; // weak
int _commode; // weak
int _fmode;
int loader_table; // idb
int sound_record_table; // weak
int sound_list[]; // weak
int dword_1027C24[]; // weak
int dword_1027C28[]; // weak
char algn_1027C2C[4]; // weak
int dword_1027C30[]; // weak
_UNKNOWN unk_1027C34; // weak
int loader_sound_count; // weak
int proj_centery; // weak
int proj_centerx; // weak
int proj_d; // weak
_UNKNOWN proj_matrix; // weak
_UNKNOWN unk_1028170; // weak
float flt_1028190; // weak
float flt_1028194; // weak
float flt_1028198; // weak
float flt_102819C; // weak
int then; // weak
_UNKNOWN gfr_display; // weak
int displaying_splashscreen; // weak
UINT iFrostUniqueMsg; // idb
int last_mouse_y; // idb
int now; // weak
HCURSOR mouse_hsave; // idb
int last_mouse_x; // idb
HWND hwnd_frame; // idb
int return_value; // weak
HINSTANCE hinst; // idb
int num_channels; // weak
HKEY options; // idb
HKEY phkResult; // idb
HKEY dword_1028228; // idb
HKEY fullscreen_toggle; // idb
HKEY application_priority; // idb
HKEY dword_1028234; // idb
HKEY dword_1028238; // idb
HKEY dword_102823C; // idb
HKEY dword_1028240; // idb
HKEY dword_1028244; // idb
HKEY dword_1028248; // idb
HKEY dword_102824C; // idb
int dword_1028250; // idb
int dword_1028254; // idb
int dword_1028258; // idb
int dword_102825C; // idb
int dword_1028260; // idb
int dword_1028264; // idb
int high_score_dlg_score; // idb
LPCSTR high_score_dlg_hst; // idb
int high_score_dlg_enter_name; // weak
int high_score_position; // idb
LPCSTR high_score_default_name; // idb
HGDIOBJ gdrv_palette_handle; // idb
HDC gdrv_sequence_hdc; // idb
int gdrv_hinst; // weak
HWND gdrv_hwnd; // idb
int gdrv_sequence_handle; // weak
int grtext_blue; // weak
int grtext_green; // weak
int __onexitend; // weak
int __onexitbegin; // weak
int _adjust_fdiv; // weak
#endif //PINBALL_PINBALL_H
|
madebr/3d-pinball-space-cadet | Classes/TComponentGroup/TComponentGroup.h | <filename>Classes/TComponentGroup/TComponentGroup.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TCOMPONENTGROUP_H
#define PINBALL_TCOMPONENTGROUP_H
/* 127 */
struct TComponentGroup;
void TComponentGroup::NotifyTimerExpired(int, struct TPinballComponent*); // idb
int TComponentGroup::Message(TComponentGroup* this, int, float); // idb
TComponentGroup* TComponentGroup::TComponentGroup(TComponentGroup* this, struct TPinballTable* a2, int a3);
TZmapList* TComponentGroup::~TComponentGroup(TComponentGroup* this);
TComponentGroup* TComponentGroup::destroy(TComponentGroup *this, char a2);
void* TComponentGroup::vftable = &TComponentGroup::Message; // weak
#endif //PINBALL_TCOMPONENTGROUP_H
|
madebr/3d-pinball-space-cadet | Classes/TGate/TGate.h | <reponame>madebr/3d-pinball-space-cadet<filename>Classes/TGate/TGate.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TGATE_H
#define PINBALL_TGATE_H
/* 133 */
struct TGate;
int __thiscall TGate::Message(TGate* this, int, float); // idb
TGate* __thiscall TGate::TGate(TGate* this, struct TPinballTable* a2, int a3);
void* TGate::vftable = &TGate::Message; // weak
#endif //PINBALL_TGATE_H
|
madebr/3d-pinball-space-cadet | Classes/TPlunger/TPlunger.h | <filename>Classes/TPlunger/TPlunger.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TPLUNGER_H
#define PINBALL_TPLUNGER_H
/* 118 */
struct TPlunger;
void TPlunger::BallFeedTimer(int, void*); // idb
void TPlunger::PullbackTimer(int, void*); // idb
void TPlunger::PlungerReleasedTimer(int, void*); // idb
int __thiscall TPlunger::Message(TPlunger* this, int, float); // idb
void __thiscall TPlunger::Collision(TPlunger* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TPlunger* __thiscall TPlunger::TPlunger(TPlunger* this, struct TPinballTable* a2, int a3);
void* TPlunger::vftable = &TPlunger::Message; // weak
#endif //PINBALL_TPLUNGER_H
|
madebr/3d-pinball-space-cadet | Classes/TLightRollover/TLightRollover.h | <reponame>madebr/3d-pinball-space-cadet
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TLIGHTROLLOVER_H
#define PINBALL_TLIGHTROLLOVER_H
/* 109 */
struct TLightRollover;
void TLightRollover::delay_expired(int, void*); // idb
void __thiscall TLightRollover::Collision(TLightRollover* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
int __thiscall TLightRollover::Message(TLightRollover* this, int, float); // idb
TLightRollover* __thiscall TLightRollover::TLightRollover(TLightRollover* this, struct TPinballTable* a2, int a3);
void* TLightRollover::vftable = &TLightRollover::Message; // weak
#endif //PINBALL_TLIGHTROLLOVER_H
|
madebr/3d-pinball-space-cadet | Classes/TOneWay/TOneWay.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TONEWAY_H
#define PINBALL_TONEWAY_H
/* 103 */
struct TOneway;
int __thiscall TOneway::get_scoring(TOneway* this, int); // idb
void __thiscall TOneway::put_scoring(TOneway* this, int, int); // idb
void __thiscall TOneway::Collision(TOneway* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TOneway* __thiscall TOneway::TOneway(TOneway* this, struct TPinballTable* a2, int a3);
TOneway* __thiscall TOneway::destroy(TOneway* this, char a2);
void* TOneway::vftable = &TPinballComponent::Message; // weak
#endif //PINBALL_TONEWAY_H
|
madebr/3d-pinball-space-cadet | Classes/TRollover/TRollover.h | <reponame>madebr/3d-pinball-space-cadet<gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TROLLOVER_H
#define PINBALL_TROLLOVER_H
/* 108 */
struct TRollover;
void TRollover::TimerExpired(int, void*); // idb
int __thiscall TRollover::Message(TRollover* this, int, float); // idb
int __thiscall TRollover::get_scoring(TRollover* this, int); // idb
void __thiscall TRollover::put_scoring(TRollover* this, int, int); // idb
void __thiscall TRollover::build_walls(TRollover* this, int); // idb
void __thiscall TRollover::Collision(TRollover* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TRollover* __thiscall TRollover::TRollover(TRollover* this, struct TPinballTable* a2, int a3, int a4);
TRollover* __thiscall TRollover::TRollover(TRollover* this, struct TPinballTable* a2, int a3);
void* TRollover::vftable = &TRollover::Message; // weak
#endif //PINBALL_TROLLOVER_H
|
madebr/3d-pinball-space-cadet | Classes/TFlipper/TFlipper.h | <reponame>madebr/3d-pinball-space-cadet
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TFLIPPER_H
#define PINBALL_TFLIPPER_H
/* 121 */
struct TFlipper;
TZmapList* __thiscall TFlipper::~TFlipper(TFlipper* this);
void TFlipper::TimerExpired(int, void*); // idb
int __thiscall TFlipper::Message(TFlipper* this, int, float); // idb
void __thiscall TFlipper::port_draw(TFlipper* __hidden this); // idb
TFlipper* __thiscall TFlipper::TFlipper(TFlipper* this, struct TPinballTable* a2, int a3);
TFlipper* __thiscall TFlipper::destroy(TFlipper *this, char a2);
void* TFlipper::vftable = &TFlipper::Message; // weak
#endif //PINBALL_TFLIPPER_H
|
madebr/3d-pinball-space-cadet | Classes/TBlocker/TBlocker.h | <filename>Classes/TBlocker/TBlocker.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TBLOCKER_H
#define PINBALL_TBLOCKER_H
/* 130 */
struct TBlocker;
void TBlocker::TimerExpired(int, struct TPinballComponent*); // idb
int __thiscall TBlocker::Message(TBlocker* this, int, float); // idb
TBlocker* __thiscall TBlocker::TBlocker(TBlocker* this, struct TPinballTable* a2, int a3);
void* TBlocker::vftable = &TBlocker::Message; // weak
#endif //PINBALL_TBLOCKER_H
|
madebr/3d-pinball-space-cadet | Classes/TDemo/TDemo.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TDEMO_H
#define PINBALL_TDEMO_H
/* 128 */
struct TDemo;
void TDemo::PlungerRelease(int, void*); // idb
void TDemo::UnFlipRight(int, void*); // idb
void TDemo::UnFlipLeft(int, void*); // idb
void TDemo::FlipRight(int, void*); // idb
void TDemo::FlipLeft(int, void*); // idb
void TDemo::NewGameRestartTimer(int, void*); // idb
void __thiscall TDemo::Collision(TDemo* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
int __thiscall TDemo::Message(TDemo* this, int, float); // idb
TDemo* __thiscall TDemo::TDemo(TDemo* this, struct TPinballTable* a2, int a3);
void* TDemo::vftable = &TDemo::Message; // weak
#endif //PINBALL_TDEMO_H
|
madebr/3d-pinball-space-cadet | Classes/TTableLayer/TTableLayer.h | <gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TTABLELAYER_H
#define PINBALL_TTABLELAYER_H
/* 116 */
struct TTableLayer;
int __thiscall TTableLayer::FieldEffect(TTableLayer* this, struct TBall*, struct vector_type*); // idb
TTableLayer* __thiscall TTableLayer::TTableLayer(TTableLayer* this, struct TPinballTable* a2);
TZmapList* __thiscall TTableLayer::~TTableLayer(TTableLayer* this);
TTableLayer* __thiscall TTableLayer::destroy(TTableLayer* this, char a2);
void* TTableLayer::vftable = &TPinballComponent::Message; // weak
#endif //PINBALL_TTABLELAYER_H
|
madebr/3d-pinball-space-cadet | Classes/TSound/TSound.h | <filename>Classes/TSound/TSound.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TSOUND_H
#define PINBALL_TSOUND_H
/* 132 */
struct TSound;
TSound* __thiscall TSound::destroy(TSound *this, char a2);
double __thiscall TSound::Play(TSound* this);
TSound* __thiscall TSound::TSound(TSound* this, struct TPinballTable* a2, int a3);
void* TSound::vftable = &TPinballComponent::Message; // weak
#endif //PINBALL_TSOUND_H
|
madebr/3d-pinball-space-cadet | sound/sound.h | <reponame>madebr/3d-pinball-space-cadet
#include "../pinball.h"
#ifndef PINBALL_SOUND_H
#define PINBALL_SOUND_H
#endif |
madebr/3d-pinball-space-cadet | Classes/TTextBoxMessage/TTextBoxMessage.h | <reponame>madebr/3d-pinball-space-cadet<filename>Classes/TTextBoxMessage/TTextBoxMessage.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TTEXTBOXMESSAGE_H
#define PINBALL_TTEXTBOXMESSAGE_H
/* 97 */
struct TTextBoxMessage;
TTextBoxMessage* __thiscall TTextBoxMessage::TTextBoxMessage(TTextBoxMessage* this, char* a2, float a3);
double __thiscall TTextBoxMessage::TimeLeft(TTextBoxMessage* this);
void __thiscall TTextBoxMessage::Refresh(TTextBoxMessage* this, float); // idb
TTextBoxMessage* __thiscall TTextBoxMessage::destroy(TTextBoxMessage* this, char a2);
#endif //PINBALL_TTEXTBOXMESSAGE_H
|
madebr/3d-pinball-space-cadet | Classes/TCircle/TCircle.h | <reponame>madebr/3d-pinball-space-cadet<filename>Classes/TCircle/TCircle.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TCIRCLE_H
#define PINBALL_TCIRCLE_H
/* 99 */
struct TCircle;
TCircle* __thiscall TCircle::TCircle(TCircle* this, struct TCollisionComponent* a2, char* a3, unsigned int a4, struct vector_type* a5, float a6);
double __thiscall TCircle::FindCollisionDistance(TCircle* this, struct ray_type* a2);
void __thiscall TCircle::place_in_grid(TCircle* this); // idb
void __thiscall TCircle::EdgeCollision(TCircle* this, struct TBall*, float); // idb
void* TCircle::vftable = &TCircle::EdgeCollision; // weak
#endif //PINBALL_TCIRCLE_H
|
madebr/3d-pinball-space-cadet | Classes/TTextBox/TTextbox.h | <filename>Classes/TTextBox/TTextbox.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TTEXTBOX_H
#define PINBALL_TTEXTBOX_H
/* 119 */
struct TTextBox {
TTextBox* TTextBox::TTextBox(TPinballTable* a2, int a3);
void TTextBox::Clear(int a2);
void TTextBox::TimerExpired(int a1, int a2, TTextBox *a3);
TZmapList* TTextBox::~TTextBox();
void TTextBox::Draw(int a2);
void TTextBox::Display(int a2, char *a3, float a4);
TTextBox* TTextBox::destroy(char a2);
int TTextBox::Message(int a2, float a3);
void* TTextBox::vftable = &TTextBox::Message; // weak
};
#endif //PINBALL_TTEXTBOX_H
|
madebr/3d-pinball-space-cadet | Classes/TLightBargraph/TLightBargraph.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TLIGHTBARGRAPH_H
#define PINBALL_TLIGHTBARGRAPH_H
/* 94 */
struct TLightBargraph;
TZmapList* __thiscall TLightBargraph::~TLightBargraph(TLightBargraph* this);
void __thiscall TLightBargraph::Reset(TLightBargraph* this); // idb
void TLightBargraph::BargraphTimerExpired(int, void*); // idb
int __thiscall TLightBargraph::Message(TLightBargraph* this, int, float); // idb
TLightBargraph* __thiscall TLightBargraph::TLightBargraph(TLightBargraph* this, struct TPinballTable* a2, int a3);
TLightBargraph* __thiscall TLightBargraph::destroy(TLightBargraph *this, char a2);
void* TLightBargraph::vftable = &TLightBargraph::Message; // weak
#endif //PINBALL_TLIGHTBARGRAPH_H
|
madebr/3d-pinball-space-cadet | Classes/Objlist/objlist.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_OBJLIST_CLASS_H
#define PINBALL_OBJLIST_CLASS_H
/* 123 */
struct objlist_class;
objlist_class* __thiscall objlist_class::objlist_class(objlist_class* this, int a2, int a3);
void __thiscall objlist_class::Grow(objlist_class* __hidden this); // idb
void __thiscall objlist_class::Add(objlist_class* this, void*); // idb
#endif //PINBALL_OBJLIST_CLASS_H
|
madebr/3d-pinball-space-cadet | Classes/TZmapList/TZmaplist.h | <filename>Classes/TZmapList/TZmaplist.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TZMAPLIST_H
#define PINBALL_TZMAPLIST_H
/* 126 */
struct TZmapList;
TZmapList* __thiscall TZmapList::destroy(TZmapList* this, char a2);
TZmapList* __thiscall TZmapList::TZmapList(TZmapList* this, int a2, int a3);
#endif //PINBALL_TZMAPLIST_H
|
madebr/3d-pinball-space-cadet | Classes/TPopupTarget/TPopupTarget.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TPOPUPTARGET_H
#define PINBALL_TPOPUPTARGET_H
/* 106 */
struct TPopupTarget;
void TPopupTarget::TimerExpired(int, void*); // idb
int __thiscall TPopupTarget::Message(TPopupTarget* this, int, float); // idb
int __thiscall TPopupTarget::get_scoring(TPopupTarget* this, int); // idb
void __thiscall TPopupTarget::put_scoring(TPopupTarget* this, int, int); // idb
void __thiscall TPopupTarget::Collision(TPopupTarget* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TPopupTarget* __thiscall TPopupTarget::TPopupTarget(TPopupTarget* this, struct TPinballTable* a2, int a3);
void* TPopupTarget::vftable = &TPopupTarget::Message; // weak
#endif //PINBALL_TPOPUPTARGET_H
|
madebr/3d-pinball-space-cadet | Classes/TEdgeBox/TEdgeBox.h | <filename>Classes/TEdgeBox/TEdgeBox.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TEDGEBOX_H
#define PINBALL_TEDGEBOX_H
/* 125 */
struct TEdgeBox;
TEdgeBox* __thiscall TEdgeBox::TEdgeBox(TEdgeBox* this);
void __thiscall TEdgeBox::~TEdgeBox(TEdgeBox* this);
TEdgeBox* __thiscall TEdgeBox::destroy(TEdgeBox *this, char a2);
#endif //PINBALL_TEDGEBOX_H
|
madebr/3d-pinball-space-cadet | Classes/TDrain/TDrain.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TDRAIN_H
#define PINBALL_TDRAIN_H
/* 115 */
struct TDrain
int __thiscall TDrain::Message(TDrain* this, int, float); // idb
void TDrain::TimerCallback(int, struct TPinballComponent*); // idb
void __thiscall TDrain::Collision(TDrain* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TDrain* __thiscall TDrain::TDrain(TDrain* this, struct TPinballTable* a2, int a3);
void* TDrain::vftable = &TDrain::Message; // weak
#endif //PINBALL_TDRAIN_H
|
madebr/3d-pinball-space-cadet | Classes/TSink/TSink.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TSINK_H
#define PINBALL_TSINK_H
/* 114 */
struct TSink;
void TSink::TimerExpired(int, void*); // idb
int __thiscall TSink::Message(TSink* this, int, float); // idb
int __thiscall TSink::get_scoring(TSink* this, int); // idb
void __thiscall TSink::put_scoring(TSink* this, int, int); // idb
void __thiscall TSink::Collision(TSink* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TSink* __thiscall TSink::TSink(TSink* this, struct TPinballTable* a2, int a3);
void* TSink::vftable = &TSink::Message; // weak
#endif //PINBALL_TSINK_H
|
madebr/3d-pinball-space-cadet | Classes/THole/THole.h | <filename>Classes/THole/THole.h<gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_THOLE_H
#define PINBALL_THOLE_H
/* 112 */
struct THole;
void THole::TimerExpired(int, void*); // idb
int __thiscall THole::FieldEffect(THole* this, struct TBall*, struct vector_type*); // idb
int __thiscall THole::Message(THole* this, int, float); // idb
void __thiscall THole::Collision(THole* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
THole* __thiscall THole::THole(THole* this, struct TPinballTable* a2, int a3);
void* THole::vftable = &THole::Message; // weak
#endif //PINBALL_THOLE_H
|
madebr/3d-pinball-space-cadet | Classes/TSoloTarget/TSoloTarget.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TSOLOTARGET_H
#define PINBALL_TSOLOTARGET_H
/* 107 */
struct TSoloTarget;
void TSoloTarget::TimerExpired(int, void*); // idb
int __thiscall TSoloTarget::Message(TSoloTarget* this, int, float); // idb
int __thiscall TSoloTarget::get_scoring(TSoloTarget* this, int); // idb
void __thiscall TSoloTarget::put_scoring(TSoloTarget* this, int, int); // idb
void __thiscall TSoloTarget::Collision(TSoloTarget* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TSoloTarget* __thiscall TSoloTarget::TSoloTarget(TSoloTarget* this, struct TPinballTable* a2, int a3);
void* TSoloTarget::vftable = &TSoloTarget::Message; // weak
#endif //PINBALL_TSOLOTARGET_H
|
madebr/3d-pinball-space-cadet | Classes/TCollisionComponent/TCollisionComponent.h | <gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TCOLLISIONCOMPONENT_H
#define PINBALL_TCOLLISIONCOMPONENT_H
/* 101 */
struct TCollisionComponent;
void __thiscall TCollisionComponent::port_draw(TCollisionComponent* __hidden this); // idb
void __thiscall TCollisionComponent::Collision(TCollisionComponent* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
int __thiscall TCollisionComponent::DefaultCollision(TCollisionComponent* this, struct TBall*, struct vector_type*, struct vector_type*); // idb
TCollisionComponent* __thiscall TCollisionComponent::TCollisionComponent(TCollisionComponent* this, struct TPinballTable* a2, int a3, int a4);
TZmapList* __thiscall TCollisionComponent::~TCollisionComponent(TCollisionComponent* this);
void* TCollisionComponent::vftable = &TPinballComponent::Message; // weak
#endif //PINBALL_TCOLLISIONCOMPONENT_H
|
madebr/3d-pinball-space-cadet | Classes/TKickback/TKickback.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TKICKBACK_H
#define PINBALL_TKICKBACK_H
/* 110 */
struct TKickback;
void TKickback::TimerExpired(int, struct TPinballComponent*); // idb
int __thiscall TKickback::Message(TKickback* this, int, float); // idb
void __thiscall TKickback::Collision(TKickback* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TKickback* __thiscall TKickback::TKickback(TKickback* this, struct TPinballTable* a2, int a3);
void* TKickback::vftable = &TKickback::Message; // weak
#endif //PINBALL_TKICKBACK_H
|
madebr/3d-pinball-space-cadet | Classes/TPinballTable/TPinballTable.h | <gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TPINBALLTABLE_H
#define PINBALL_TPINBALLTABLE_H
/* 117 */
struct TPinballTable;
void TPinballTable::LightShow_timeout(int, void*); // idb
void TPinballTable::EndGame_timeout(int, void*); // idb
int __thiscall TPinballTable::AddScore(TPinballTable* this, int); // idb
// void TPinballTable::ChangeBallCount(TPinballTable *this, int a2, int a3);
void TPinballTable::replay_timer_callback(int, void*); // idb
void __thiscall TPinballTable::port_draw(TPinballTable* __hidden this); // idb
void TPinballTable::tilt_timeout(int, void*); // idb
// void TPinballTable::tilt(TPinballTable *this, int a2, float a3);
// int TPinballTable::Message(TPinballTable *this, int a2, int a3, float a4);
TZmapList* __thiscall TPinballTable::~TPinballTable(TPinballTable* this);
TPinballTable* __thiscall TPinballTable::destroy(TPinballTable *this, char a2);
TPinballTable* __thiscall TPinballTable::TPinballTable(TPinballTable* this);
TPinballComponent* __thiscall TPinballTable::find_component(TPinballTable* this, char*); // idb
TPinballComponent* __thiscall TPinballTable::find_component(TPinballTable* this, int); // idb
void* TPinballTable::vftable = &TPinballTable::Message; // weak
#endif //PINBALL_TPINBALLTABLE_H
|
madebr/3d-pinball-space-cadet | Classes/TLight/TLight.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TLIGHT_H
#define PINBALL_TLIGHT_H
/* 124 */
struct TLight;
void __thiscall TLight::Reset(TLight* __hidden this); // idb
void TLight::TimerExpired(int, void*); // idb
void __thiscall TLight::schedule_timeout(TLight* this, float); // idb
int __thiscall TLight::Message(TLight* this, int, float); // idb
TLight* __thiscall TLight::TLight(TLight* this, struct TPinballTable* a2, int a3);
void* TLight::vftable = &TLight::Message; // weak
#endif //PINBALL_TLIGHT_H
|
madebr/3d-pinball-space-cadet | Classes/TFlipperEdge/TFlipperEdge.h | <filename>Classes/TFlipperEdge/TFlipperEdge.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TFLIPPEREDGE_H
#define PINBALL_TFLIPPEREDGE_H
/* 120 */
struct TFlipperEdge;
void __thiscall TFlipperEdge::place_in_grid(TFlipperEdge* this); // idb
double __thiscall TFlipperEdge::flipper_angle(TFlipperEdge* this, float a2);
void __thiscall TFlipperEdge::build_edges_in_motion(TFlipperEdge* __hidden this); // idb
void __thiscall TFlipperEdge::set_control_points(TFlipperEdge* this, float); // idb
int __thiscall TFlipperEdge::is_ball_inside(TFlipperEdge* this, float, float); // idb
double __thiscall TFlipperEdge::FindCollisionDistance(TFlipperEdge* this, struct ray_type* a2);
void __thiscall TFlipperEdge::EdgeCollision(TFlipperEdge* this, struct TBall*, float); // idb
void __thiscall TFlipperEdge::SetMotion(TFlipperEdge* this, int, float); // idb
void __thiscall TFlipperEdge::port_draw(TFlipperEdge* this); // idb
TFlipperEdge* __thiscall TFlipperEdge::TFlipperEdge(TFlipperEdge* this, struct TCollisionComponent* a2, char* a3, unsigned int a4, struct TPinballTable* a5, struct vector_type* a6, struct vector_type* a7, struct vector_type* a8, float a9, float a10, float a11, float a12, float a13);
void* TFlipperEdge::vftable = &TFlipperEdge::EdgeCollision; // weak
#endif //PINBALL_TFLIPPEREDGE_H
|
madebr/3d-pinball-space-cadet | Classes/TWall/TWall.h | <gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TWALL_H
#define PINBALL_TWALL_H
/* 102 */
struct TWall;
void TWall::TimerExpired(int, void*); // idb
int __thiscall TWall::Message(TWall* this, int, float); // idb
int __thiscall TWall::get_scoring(TWall* this, int); // idb
void __thiscall TWall::put_scoring(TWall* this, int, int); // idb
void __thiscall TWall::Collision(TWall* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TWall* __thiscall TWall::TWall(TWall* this, struct TPinballTable* a2, int a3);
void* TWall::vftable = &TWall::Message; // weak
#endif //PINBALL_TWALL_H
|
madebr/3d-pinball-space-cadet | Classes/TTimer/TTimer.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TTIMER_H
#define PINBALL_TTIMER_H
/* 129 */
struct TTimer;
void TTimer::TimerExpired(int, struct TPinballComponent*); // idb
int __thiscall TTimer::Message(TTimer* this, int, float); // idb
TTimer* __thiscall TTimer::TTimer(TTimer* this, struct TPinballTable* a2, int a3);
void* TTimer::vftable = &TTimer::Message; // weak
#endif //PINBALL_TTIMER_H
|
madebr/3d-pinball-space-cadet | Classes/TRamp/TRamp.h | <filename>Classes/TRamp/TRamp.h
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TRAMP_H
#define PINBALL_TRAMP_H
/* 113 */
struct TRamp;
int __thiscall TRamp::get_scoring(TRamp* this, int); // idb
void __thiscall TRamp::put_scoring(TRamp* this, int, int); // idb
void __thiscall TRamp::Collision(TRamp* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
int __thiscall TRamp::FieldEffect(TRamp* this, struct TBall*, struct vector_type*); // idb
TRamp* __thiscall TRamp::TRamp(TRamp* this, struct TPinballTable* a2, void* a3);
void* TRamp::vftable = &TPinballComponent::Message; // weak
#endif //PINBALL_TRAMP_H
|
madebr/3d-pinball-space-cadet | Classes/TBall/TBall.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TBALL_H
#define PINBALL_TBALL_H
/* 95 */
struct TBall;
bool __thiscall TBall::already_hit(TBall* this, struct TEdgeSegment* a2);
void __thiscall TBall::not_again(TBall* this, struct TEdgeSegment*); // idb
int __thiscall TBall::Message(TBall* this, int, float); // idb
void __thiscall TBall::Repaint(TBall* __hidden this); // idb
TBall* __thiscall TBall::TBall(TBall* this, struct TPinballTable* a2);
void* TBall::vftable = &TBall::Message; // weak
#endif //PINBALL_TBALL_H
|
madebr/3d-pinball-space-cadet | Classes/TTripwire/TTripwire.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TTRIPWIRE_H
#define PINBALL_TTRIPWIRE_H
/* 131 */
struct TTripwire;
void __thiscall TTripwire::Collision(TTripwire* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TTripwire* __thiscall TTripwire::TTripwire(TTripwire* this, struct TPinballTable* a2, int a3);
void* TTripwire::vftable = &TRollover::Message; // weak
#endif //PINBALL_TTRIPWIRE_H
|
madebr/3d-pinball-space-cadet | Classes/TEdgeManager/TEdgeManager.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TEDGEMANAGER_H
#define PINBALL_TEDGEMANAGER_H
/* 96 */
struct TEdgeManager;
signed __int64 __thiscall TEdgeManager::box_x(TEdgeManager* this, float a2);
signed __int64 __thiscall TEdgeManager::box_y(TEdgeManager* this, float a2);
int __thiscall TEdgeManager::increment_box_x(TEdgeManager* this, int); // idb
int __thiscall TEdgeManager::increment_box_y(TEdgeManager* this, int); // idb
void __thiscall TEdgeManager::FieldEffects(TEdgeManager* this, struct TBall*, struct vector_type*); // idb
// int TEdgeManager::TestGridBox(TEdgeManager *this, double a2@<st0>, int a3, int a4, float *a5, struct TEdgeSegment **a6, struct ray_type *a7, struct TBall *a8, int a9);
double __thiscall TEdgeManager::FindCollisionDistance(TEdgeManager* this, struct ray_type* a2, struct TBall* a3, struct TEdgeSegment** a4);
TEdgeManager* __thiscall TEdgeManager::TEdgeManager(TEdgeManager* this, float a2, float a3, float a4, float a5);
void __thiscall TEdgeManager::add_edge_to_box(TEdgeManager* this, int, int, struct TEdgeSegment*); // idb
void __thiscall TEdgeManager::add_field_to_box(TEdgeManager* this, int, int, struct field_effect_type*); // idb
TEdgeBox* __thiscall TEdgeManager::~TEdgeManager(TEdgeManager* this);
TEdgeManager* __thiscall TEdgeManager::destroy(TEdgeManager* this, char a2);
#endif //PINBALL_TEDGEMANAGER_H
|
madebr/3d-pinball-space-cadet | Classes/TFlagSpinner/TFlagSpinner.h | //
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TFLAGSPINNER_H
#define PINBALL_TFLAGSPINNER_H
/* 105 */
struct TFlagSpinner;
void TFlagSpinner::SpinTimer(int, void*); // idb
void __thiscall TFlagSpinner::NextFrame(TFlagSpinner* this); // idb
int __thiscall TFlagSpinner::Message(TFlagSpinner* this, int, float); // idb
int __thiscall TFlagSpinner::get_scoring(TFlagSpinner* this, int); // idb
void __thiscall TFlagSpinner::put_scoring(TFlagSpinner* this, int, int); // idb
void __thiscall TFlagSpinner::Collision(TFlagSpinner* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
TFlagSpinner* __thiscall TFlagSpinner::TFlagSpinner(TFlagSpinner* this, struct TPinballTable* a2, int a3);
void* TFlagSpinner::vftable = &TFlagSpinner::Message; // weak
#endif //PINBALL_TFLAGSPINNER_H
|
madebr/3d-pinball-space-cadet | Classes/TKickout/TKickout.h | <reponame>madebr/3d-pinball-space-cadet<gh_stars>10-100
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TKICKOUT_H
#define PINBALL_TKICKOUT_H
/* 111 */
struct TKickout;
void __thiscall TKickout::Collision(TKickout* this, struct TBall*, struct vector_type*, struct vector_type*, float, struct TEdgeSegment*); // idb
void TKickout::ResetTimerExpired(int, void*); // idb
void TKickout::TimerExpired(int, void*); // idb
int __thiscall TKickout::FieldEffect(TKickout* this, struct TBall*, struct vector_type*); // idb
int __thiscall TKickout::Message(TKickout* this, int, float); // idb
int __thiscall TKickout::get_scoring(TKickout* this, int); // idb
void __thiscall TKickout::put_scoring(TKickout* this, int, int); // idb
TKickout* __thiscall TKickout::TKickout(TKickout* this, struct TPinballTable* a2, int a3, struct vector_type* a4);
void* TKickout::vftable = &TKickout::Message; // weak
#endif //PINBALL_TKICKOUT_H
|
madebr/3d-pinball-space-cadet | Classes/TLine/TLine.h | <reponame>madebr/3d-pinball-space-cadet
//
// Created by neo on 2019-08-15.
//
#include "../../pinball.h"
#ifndef PINBALL_TLINE_H
#define PINBALL_TLINE_H
/* 122 */
struct TLine;
TLine* __thiscall TLine::TLine(TLine* this, struct TCollisionComponent* a2, char* a3, unsigned int a4, float a5, float a6, float a7, float a8);
double __thiscall TLine::FindCollisionDistance(TLine* this, struct ray_type* a2);
TLine* __thiscall TLine::TLine(TLine* this, struct TCollisionComponent* a2, char* a3, unsigned int a4, struct vector_type* a5, struct vector_type* a6);
void __thiscall TLine::EdgeCollision(TLine* this, struct TBall*, float); // idb
void __thiscall TLine::Offset(TLine* this, float); // idb
void __thiscall TLine::place_in_grid(TLine* this); // idb
void* TLine::vftable = &TLine::EdgeCollision; // weak
#endif //PINBALL_TLINE_H
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/source/Plugins/Language/Swift/SwiftDictionary.h | //===-- SwiftDictionary.h ---------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_SwiftDictionary_h_
#define liblldb_SwiftDictionary_h_
#include "lldb/lldb-forward.h"
#include "SwiftHashedContainer.h"
#include "lldb/Core/ConstString.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
namespace lldb_private {
namespace formatters {
namespace swift {
bool Dictionary_SummaryProvider(ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &options);
SyntheticChildrenFrontEnd *
DictionarySyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP);
}
}
}
#endif // liblldb_SwiftDictionary_h_
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/clang/test/Sema/overloadable.c | <filename>SymbolExtractorAndRenamer/clang/test/Sema/overloadable.c
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wincompatible-pointer-types
int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}}
void params(void) __attribute__((overloadable(12))); // expected-error {{'overloadable' attribute takes no arguments}}
int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}}
float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}
int *f(int); // expected-error{{redeclaration of 'f' must have the 'overloadable' attribute}} \
// expected-note{{previous declaration is here}}
double *f(double) __attribute__((overloadable)); // okay, new
void test_f(int iv, float fv, double dv) {
int *ip = f(iv);
float *fp = f(fv);
double *dp = f(dv);
}
int *accept_funcptr(int (*)()) __attribute__((overloadable)); // \
// expected-note{{candidate function}}
float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable)); // \
// expected-note{{candidate function}}
void test_funcptr(int (*f1)(int, double),
int (*f2)(int, float)) {
float *fp = accept_funcptr(f1);
accept_funcptr(f2); // expected-error{{call to 'accept_funcptr' is ambiguous}}
}
struct X { int x; float y; };
struct Y { int x; float y; };
int* accept_struct(struct X x) __attribute__((__overloadable__));
float* accept_struct(struct Y y) __attribute__((overloadable));
void test_struct(struct X x, struct Y y) {
int *ip = accept_struct(x);
float *fp = accept_struct(y);
}
double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}}
double promote(float) __attribute__((__overloadable__)); // expected-note {{candidate}}
double promote(double) __attribute__((__overloadable__)); // expected-note {{candidate}}
long double promote(long double) __attribute__((__overloadable__)); // expected-note {{candidate}}
void promote(...) __attribute__((__overloadable__, __unavailable__)); // \
// expected-note{{candidate function}}
void test_promote(short* sp) {
promote(1.0);
promote(sp); // expected-error{{call to unavailable function 'promote'}}
}
// PR6600
typedef double Double;
typedef Double DoubleVec __attribute__((vector_size(16)));
typedef int Int;
typedef Int IntVec __attribute__((vector_size(16)));
double magnitude(DoubleVec) __attribute__((__overloadable__));
double magnitude(IntVec) __attribute__((__overloadable__));
double test_p6600(DoubleVec d) {
return magnitude(d) * magnitude(d);
}
// PR7738
extern int __attribute__((overloadable)) f0(); // expected-error{{'overloadable' function 'f0' must have a prototype}}
typedef int f1_type();
f1_type __attribute__((overloadable)) f1; // expected-error{{'overloadable' function 'f1' must have a prototype}}
void test() {
f0();
f1();
}
void before_local_1(int) __attribute__((overloadable)); // expected-note {{here}}
void before_local_2(int); // expected-note {{here}}
void before_local_3(int) __attribute__((overloadable));
void local() {
void before_local_1(char); // expected-error {{must have the 'overloadable' attribute}}
void before_local_2(char) __attribute__((overloadable)); // expected-error {{conflicting types}}
void before_local_3(char) __attribute__((overloadable));
void after_local_1(char); // expected-note {{here}}
void after_local_2(char) __attribute__((overloadable)); // expected-note {{here}}
void after_local_3(char) __attribute__((overloadable));
}
void after_local_1(int) __attribute__((overloadable)); // expected-error {{conflicting types}}
void after_local_2(int); // expected-error {{must have the 'overloadable' attribute}}
void after_local_3(int) __attribute__((overloadable));
// Make sure we allow C-specific conversions in C.
void conversions() {
void foo(char *c) __attribute__((overloadable));
void foo(char *c) __attribute__((overloadable, enable_if(c, "nope.jpg")));
void *ptr;
foo(ptr);
void multi_type(unsigned char *c) __attribute__((overloadable));
void multi_type(signed char *c) __attribute__((overloadable));
unsigned char *c;
multi_type(c);
}
// Ensure that we allow C-specific type conversions in C
void fn_type_conversions() {
void foo(void *c) __attribute__((overloadable));
void foo(char *c) __attribute__((overloadable));
void (*ptr1)(void *) = &foo;
void (*ptr2)(char *) = &foo;
void (*ambiguous)(int *) = &foo; // expected-error{{initializing 'void (*)(int *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
void *vp_ambiguous = &foo; // expected-error{{initializing 'void *' with an expression of incompatible type '<overloaded function type>'}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
void (*specific1)(int *) = (void (*)(void *))&foo; // expected-warning{{incompatible function pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}}
void *specific2 = (void (*)(void *))&foo;
void disabled(void *c) __attribute__((overloadable, enable_if(0, "")));
void disabled(int *c) __attribute__((overloadable, enable_if(c, "")));
void disabled(char *c) __attribute__((overloadable, enable_if(1, "The function name lies.")));
// To be clear, these should all point to the last overload of 'disabled'
void (*dptr1)(char *c) = &disabled;
void (*dptr2)(void *c) = &disabled; // expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type '<overloaded function type>'}} expected-note@115{{candidate function made ineligible by enable_if}} expected-note@116{{candidate function made ineligible by enable_if}} expected-note@117{{candidate function has type mismatch at 1st parameter (expected 'void *' but has 'char *')}}
void (*dptr3)(int *c) = &disabled; // expected-warning{{incompatible pointer types initializing 'void (*)(int *)' with an expression of type '<overloaded function type>'}} expected-note@115{{candidate function made ineligible by enable_if}} expected-note@116{{candidate function made ineligible by enable_if}} expected-note@117{{candidate function has type mismatch at 1st parameter (expected 'int *' but has 'char *')}}
void *specific_disabled = &disabled;
}
void incompatible_pointer_type_conversions() {
char charbuf[1];
unsigned char ucharbuf[1];
int intbuf[1];
void foo(char *c) __attribute__((overloadable));
void foo(short *c) __attribute__((overloadable));
foo(charbuf);
foo(ucharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@131{{candidate function}} expected-note@132{{candidate function}}
foo(intbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@131{{candidate function}} expected-note@132{{candidate function}}
void bar(unsigned char *c) __attribute__((overloadable));
void bar(signed char *c) __attribute__((overloadable));
bar(charbuf); // expected-error{{call to 'bar' is ambiguous}} expected-note@137{{candidate function}} expected-note@138{{candidate function}}
bar(ucharbuf);
bar(intbuf); // expected-error{{call to 'bar' is ambiguous}} expected-note@137{{candidate function}} expected-note@138{{candidate function}}
}
void dropping_qualifiers_is_incompatible() {
const char ccharbuf[1];
volatile char vcharbuf[1];
void foo(char *c) __attribute__((overloadable));
void foo(const volatile unsigned char *c) __attribute__((overloadable));
foo(ccharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@148{{candidate function}} expected-note@149{{candidate function}}
foo(vcharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@148{{candidate function}} expected-note@149{{candidate function}}
}
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/include/lldb/Core/Logging.h | //===-- Logging.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Core_Logging_h_
#define liblldb_Core_Logging_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
//----------------------------------------------------------------------
// Log Bits specific to logging in lldb
//----------------------------------------------------------------------
#define LIBLLDB_LOG_VERBOSE (1u << 0)
#define LIBLLDB_LOG_PROCESS (1u << 1)
#define LIBLLDB_LOG_THREAD (1u << 2)
#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3)
#define LIBLLDB_LOG_EVENTS (1u << 4)
#define LIBLLDB_LOG_BREAKPOINTS (1u << 5)
#define LIBLLDB_LOG_WATCHPOINTS (1u << 6)
#define LIBLLDB_LOG_STEP (1u << 7)
#define LIBLLDB_LOG_EXPRESSIONS (1u << 8)
#define LIBLLDB_LOG_TEMPORARY (1u << 9)
#define LIBLLDB_LOG_STATE (1u << 10)
#define LIBLLDB_LOG_OBJECT (1u << 11)
#define LIBLLDB_LOG_COMMUNICATION (1u << 12)
#define LIBLLDB_LOG_CONNECTION (1u << 13)
#define LIBLLDB_LOG_HOST (1u << 14)
#define LIBLLDB_LOG_UNWIND (1u << 15)
#define LIBLLDB_LOG_API (1u << 16)
#define LIBLLDB_LOG_SCRIPT (1u << 17)
#define LIBLLDB_LOG_COMMANDS (1U << 18)
#define LIBLLDB_LOG_TYPES (1u << 19)
#define LIBLLDB_LOG_SYMBOLS (1u << 20)
#define LIBLLDB_LOG_MODULES (1u << 21)
#define LIBLLDB_LOG_TARGET (1u << 22)
#define LIBLLDB_LOG_MMAP (1u << 23)
#define LIBLLDB_LOG_OS (1u << 24)
#define LIBLLDB_LOG_PLATFORM (1u << 25)
#define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26)
#define LIBLLDB_LOG_JIT_LOADER (1u << 27)
#define LIBLLDB_LOG_LANGUAGE (1u << 28)
#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29)
#define LIBLLDB_LOG_DEMANGLE (1u << 30)
#define LIBLLDB_LOG_ALL (UINT32_MAX)
#define LIBLLDB_LOG_DEFAULT \
(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD | LIBLLDB_LOG_DYNAMIC_LOADER | \
LIBLLDB_LOG_BREAKPOINTS | LIBLLDB_LOG_WATCHPOINTS | LIBLLDB_LOG_STEP | \
LIBLLDB_LOG_STATE | LIBLLDB_LOG_SYMBOLS | LIBLLDB_LOG_TARGET | \
LIBLLDB_LOG_COMMANDS)
namespace lldb_private {
void LogIfAllCategoriesSet(uint32_t mask, const char *format, ...);
void LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...);
Log *GetLogIfAllCategoriesSet(uint32_t mask);
Log *GetLogIfAnyCategoriesSet(uint32_t mask);
uint32_t GetLogMask();
bool IsLogVerbose();
void DisableLog(const char **categories, Stream *feedback_strm);
Log *EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options,
const char **categories, Stream *feedback_strm);
void ListLogCategories(Stream *strm);
} // namespace lldb_private
#endif // liblldb_Core_Logging_h_
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h | <gh_stars>100-1000
//===-- RegisterContextLinux_mips64.h ---------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#if defined(__mips__)
#ifndef liblldb_RegisterContextLinux_mips64_H_
#define liblldb_RegisterContextLinux_mips64_H_
#include "RegisterInfoInterface.h"
#include "lldb/lldb-private.h"
class RegisterContextLinux_mips64 : public lldb_private::RegisterInfoInterface {
public:
RegisterContextLinux_mips64(const lldb_private::ArchSpec &target_arch,
bool msa_present = true);
size_t GetGPRSize() const override;
const lldb_private::RegisterInfo *GetRegisterInfo() const override;
uint32_t GetRegisterCount() const override;
uint32_t GetUserRegisterCount() const override;
private:
const lldb_private::RegisterInfo *m_register_info_p;
uint32_t m_register_info_count;
uint32_t m_user_register_count;
};
#endif
#endif
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h | template<typename T>
class GenericContainer {
private:
T storage;
public:
GenericContainer(T value) {
storage = value;
};
};
typedef GenericContainer<int> IntContainer;
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h | <gh_stars>100-1000
//===-- WindowsMiniDump.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_WindowsMiniDump_h_
#define liblldb_WindowsMiniDump_h_
#include "lldb/Target/Process.h"
namespace lldb_private {
bool SaveMiniDump(const lldb::ProcessSP &process_sp,
const lldb_private::FileSpec &outfile,
lldb_private::Error &error);
} // namespace lldb_private
#endif
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/include/lldb/Interpreter/OptionValueSInt64.h | //===-- OptionValueSInt64.h --------------------------------------*- C++
//-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_OptionValueSInt64_h_
#define liblldb_OptionValueSInt64_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/OptionValue.h"
namespace lldb_private {
class OptionValueSInt64 : public OptionValue {
public:
OptionValueSInt64()
: OptionValue(), m_current_value(0), m_default_value(0),
m_min_value(INT64_MIN), m_max_value(INT64_MAX) {}
OptionValueSInt64(int64_t value)
: OptionValue(), m_current_value(value), m_default_value(value),
m_min_value(INT64_MIN), m_max_value(INT64_MAX) {}
OptionValueSInt64(int64_t current_value, int64_t default_value)
: OptionValue(), m_current_value(current_value),
m_default_value(default_value), m_min_value(INT64_MIN),
m_max_value(INT64_MAX) {}
OptionValueSInt64(const OptionValueSInt64 &rhs)
: OptionValue(rhs), m_current_value(rhs.m_current_value),
m_default_value(rhs.m_default_value), m_min_value(rhs.m_min_value),
m_max_value(rhs.m_max_value) {}
~OptionValueSInt64() override {}
//---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeSInt64; }
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
uint32_t dump_mask) override;
Error
SetValueFromString(llvm::StringRef value,
VarSetOperationType op = eVarSetOperationAssign) override;
Error
SetValueFromString(const char *,
VarSetOperationType = eVarSetOperationAssign) = delete;
bool Clear() override {
m_current_value = m_default_value;
m_value_was_set = false;
return true;
}
lldb::OptionValueSP DeepCopy() const override;
//---------------------------------------------------------------------
// Subclass specific functions
//---------------------------------------------------------------------
const int64_t &operator=(int64_t value) {
m_current_value = value;
return m_current_value;
}
int64_t GetCurrentValue() const { return m_current_value; }
int64_t GetDefaultValue() const { return m_default_value; }
bool SetCurrentValue(int64_t value) {
if (value >= m_min_value && value <= m_max_value) {
m_current_value = value;
return true;
}
return false;
}
bool SetDefaultValue(int64_t value) {
if (value >= m_min_value && value <= m_max_value) {
m_default_value = value;
return true;
}
return false;
}
void SetMinimumValue(int64_t v) { m_min_value = v; }
int64_t GetMinimumValue() const { return m_min_value; }
void SetMaximumValue(int64_t v) { m_max_value = v; }
int64_t GetMaximumValue() const { return m_max_value; }
protected:
int64_t m_current_value;
int64_t m_default_value;
int64_t m_min_value;
int64_t m_max_value;
};
} // namespace lldb_private
#endif // liblldb_OptionValueSInt64_h_
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/include/lldb/Target/Platform.h | <gh_stars>100-1000
//===-- Platform.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Platform_h_
#define liblldb_Platform_h_
// C Includes
// C++ Includes
#include <functional>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-public.h"
// TODO pull NativeDelegate class out of NativeProcessProtocol so we
// can just forward ref the NativeDelegate rather than include it here.
#include "lldb/Host/common/NativeProcessProtocol.h"
namespace lldb_private {
class ModuleCache;
enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 };
class PlatformProperties : public Properties {
public:
PlatformProperties();
static ConstString GetSettingName();
bool GetUseModuleCache() const;
bool SetUseModuleCache(bool use_module_cache);
FileSpec GetModuleCacheDirectory() const;
bool SetModuleCacheDirectory(const FileSpec &dir_spec);
};
typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP;
//----------------------------------------------------------------------
/// @class Platform Platform.h "lldb/Target/Platform.h"
/// @brief A plug-in interface definition class for debug platform that
/// includes many platform abilities such as:
/// @li getting platform information such as supported architectures,
/// supported binary file formats and more
/// @li launching new processes
/// @li attaching to existing processes
/// @li download/upload files
/// @li execute shell commands
/// @li listing and getting info for existing processes
/// @li attaching and possibly debugging the platform's kernel
//----------------------------------------------------------------------
class Platform : public PluginInterface {
public:
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
Platform(bool is_host_platform);
//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
//------------------------------------------------------------------
~Platform() override;
static void Initialize();
static void Terminate();
static const PlatformPropertiesSP &GetGlobalPlatformProperties();
//------------------------------------------------------------------
/// Get the native host platform plug-in.
///
/// There should only be one of these for each host that LLDB runs
/// upon that should be statically compiled in and registered using
/// preprocessor macros or other similar build mechanisms in a
/// PlatformSubclass::Initialize() function.
///
/// This platform will be used as the default platform when launching
/// or attaching to processes unless another platform is specified.
//------------------------------------------------------------------
static lldb::PlatformSP GetHostPlatform();
static lldb::PlatformSP
GetPlatformForArchitecture(const ArchSpec &arch, ArchSpec *platform_arch_ptr);
static const char *GetHostPlatformName();
static void SetHostPlatform(const lldb::PlatformSP &platform_sp);
// Find an existing platform plug-in by name
static lldb::PlatformSP Find(const ConstString &name);
static lldb::PlatformSP Create(const ConstString &name, Error &error);
static lldb::PlatformSP Create(const ArchSpec &arch,
ArchSpec *platform_arch_ptr, Error &error);
static uint32_t GetNumConnectedRemotePlatforms();
static lldb::PlatformSP GetConnectedRemotePlatformAtIndex(uint32_t idx);
//------------------------------------------------------------------
/// Find a platform plugin for a given process.
///
/// Scans the installed Platform plug-ins and tries to find
/// an instance that can be used for \a process
///
/// @param[in] process
/// The process for which to try and locate a platform
/// plug-in instance.
///
/// @param[in] plugin_name
/// An optional name of a specific platform plug-in that
/// should be used. If nullptr, pick the best plug-in.
//------------------------------------------------------------------
// static lldb::PlatformSP
// FindPlugin (Process *process, const ConstString &plugin_name);
//------------------------------------------------------------------
/// Set the target's executable based off of the existing
/// architecture information in \a target given a path to an
/// executable \a exe_file.
///
/// Each platform knows the architectures that it supports and can
/// select the correct architecture slice within \a exe_file by
/// inspecting the architecture in \a target. If the target had an
/// architecture specified, then in can try and obey that request
/// and optionally fail if the architecture doesn't match up.
/// If no architecture is specified, the platform should select the
/// default architecture from \a exe_file. Any application bundles
/// or executable wrappers can also be inspected for the actual
/// application binary within the bundle that should be used.
///
/// @return
/// Returns \b true if this Platform plug-in was able to find
/// a suitable executable, \b false otherwise.
//------------------------------------------------------------------
virtual Error ResolveExecutable(const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr);
//------------------------------------------------------------------
/// Find a symbol file given a symbol file module specification.
///
/// Each platform might have tricks to find symbol files for an
/// executable given information in a symbol file ModuleSpec. Some
/// platforms might also support symbol files that are bundles and
/// know how to extract the right symbol file given a bundle.
///
/// @param[in] target
/// The target in which we are trying to resolve the symbol file.
/// The target has a list of modules that we might be able to
/// use in order to help find the right symbol file. If the
/// "m_file" or "m_platform_file" entries in the \a sym_spec
/// are filled in, then we might be able to locate a module in
/// the target, extract its UUID and locate a symbol file.
/// If just the "m_uuid" is specified, then we might be able
/// to find the module in the target that matches that UUID
/// and pair the symbol file along with it. If just "m_symbol_file"
/// is specified, we can use a variety of tricks to locate the
/// symbols in an SDK, PDK, or other development kit location.
///
/// @param[in] sym_spec
/// A module spec that describes some information about the
/// symbol file we are trying to resolve. The ModuleSpec might
/// contain the following:
/// m_file - A full or partial path to an executable from the
/// target (might be empty).
/// m_platform_file - Another executable hint that contains
/// the path to the file as known on the
/// local/remote platform.
/// m_symbol_file - A full or partial path to a symbol file
/// or symbol bundle that should be used when
/// trying to resolve the symbol file.
/// m_arch - The architecture we are looking for when resolving
/// the symbol file.
/// m_uuid - The UUID of the executable and symbol file. This
/// can often be used to match up an executable with
/// a symbol file, or resolve an symbol file in a
/// symbol file bundle.
///
/// @param[out] sym_file
/// The resolved symbol file spec if the returned error
/// indicates success.
///
/// @return
/// Returns an error that describes success or failure.
//------------------------------------------------------------------
virtual Error ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
FileSpec &sym_file);
//------------------------------------------------------------------
/// Resolves the FileSpec to a (possibly) remote path. Remote
/// platforms must override this to resolve to a path on the remote
/// side.
//------------------------------------------------------------------
virtual bool ResolveRemotePath(const FileSpec &platform_path,
FileSpec &resolved_platform_path);
//------------------------------------------------------------------
/// Get the OS version from a connected platform.
///
/// Some platforms might not be connected to a remote platform, but
/// can figure out the OS version for a process. This is common for
/// simulator platforms that will run native programs on the current
/// host, but the simulator might be simulating a different OS. The
/// \a process parameter might be specified to help to determine
/// the OS version.
//------------------------------------------------------------------
virtual bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update,
Process *process = nullptr);
bool SetOSVersion(uint32_t major, uint32_t minor, uint32_t update);
bool GetOSBuildString(std::string &s);
bool GetOSKernelDescription(std::string &s);
// Returns the name of the platform
ConstString GetName();
virtual const char *GetHostname();
virtual ConstString GetFullNameForDylib(ConstString basename);
virtual const char *GetDescription() = 0;
//------------------------------------------------------------------
/// Report the current status for this platform.
///
/// The returned string usually involves returning the OS version
/// (if available), and any SDK directory that might be being used
/// for local file caching, and if connected a quick blurb about
/// what this platform is connected to.
//------------------------------------------------------------------
virtual void GetStatus(Stream &strm);
//------------------------------------------------------------------
// Subclasses must be able to fetch the current OS version
//
// Remote classes must be connected for this to succeed. Local
// subclasses don't need to override this function as it will just
// call the HostInfo::GetOSVersion().
//------------------------------------------------------------------
virtual bool GetRemoteOSVersion() { return false; }
virtual bool GetRemoteOSBuildString(std::string &s) {
s.clear();
return false;
}
virtual bool GetRemoteOSKernelDescription(std::string &s) {
s.clear();
return false;
}
// Remote Platform subclasses need to override this function
virtual ArchSpec GetRemoteSystemArchitecture() {
return ArchSpec(); // Return an invalid architecture
}
virtual FileSpec GetRemoteWorkingDirectory() { return m_working_dir; }
virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir);
virtual const char *GetUserName(uint32_t uid);
virtual const char *GetGroupName(uint32_t gid);
//------------------------------------------------------------------
/// Locate a file for a platform.
///
/// The default implementation of this function will return the same
/// file patch in \a local_file as was in \a platform_file.
///
/// @param[in] platform_file
/// The platform file path to locate and cache locally.
///
/// @param[in] uuid_ptr
/// If we know the exact UUID of the file we are looking for, it
/// can be specified. If it is not specified, we might now know
/// the exact file. The UUID is usually some sort of MD5 checksum
/// for the file and is sometimes known by dynamic linkers/loaders.
/// If the UUID is known, it is best to supply it to platform
/// file queries to ensure we are finding the correct file, not
/// just a file at the correct path.
///
/// @param[out] local_file
/// A locally cached version of the platform file. For platforms
/// that describe the current host computer, this will just be
/// the same file. For remote platforms, this file might come from
/// and SDK directory, or might need to be sync'ed over to the
/// current machine for efficient debugging access.
///
/// @return
/// An error object.
//------------------------------------------------------------------
virtual Error GetFileWithUUID(const FileSpec &platform_file,
const UUID *uuid_ptr, FileSpec &local_file);
//----------------------------------------------------------------------
// Locate the scripting resource given a module specification.
//
// Locating the file should happen only on the local computer or using
// the current computers global settings.
//----------------------------------------------------------------------
virtual FileSpecList
LocateExecutableScriptingResources(Target *target, Module &module,
Stream *feedback_stream);
virtual Error GetSharedModule(const ModuleSpec &module_spec, Process *process,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
lldb::ModuleSP *old_module_sp_ptr,
bool *did_create_ptr);
virtual bool GetModuleSpec(const FileSpec &module_file_spec,
const ArchSpec &arch, ModuleSpec &module_spec);
virtual Error ConnectRemote(Args &args);
virtual Error DisconnectRemote();
//------------------------------------------------------------------
/// Get the platform's supported architectures in the order in which
/// they should be searched.
///
/// @param[in] idx
/// A zero based architecture index
///
/// @param[out] arch
/// A copy of the architecture at index if the return value is
/// \b true.
///
/// @return
/// \b true if \a arch was filled in and is valid, \b false
/// otherwise.
//------------------------------------------------------------------
virtual bool GetSupportedArchitectureAtIndex(uint32_t idx,
ArchSpec &arch) = 0;
virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target,
BreakpointSite *bp_site);
//------------------------------------------------------------------
/// Launch a new process on a platform, not necessarily for
/// debugging, it could be just for running the process.
//------------------------------------------------------------------
virtual Error LaunchProcess(ProcessLaunchInfo &launch_info);
//------------------------------------------------------------------
/// Perform expansion of the command-line for this launch info
/// This can potentially involve wildcard expansion
// environment variable replacement, and whatever other
// argument magic the platform defines as part of its typical
// user experience
//------------------------------------------------------------------
virtual Error ShellExpandArguments(ProcessLaunchInfo &launch_info);
//------------------------------------------------------------------
/// Kill process on a platform.
//------------------------------------------------------------------
virtual Error KillProcess(const lldb::pid_t pid);
//------------------------------------------------------------------
/// Lets a platform answer if it is compatible with a given
/// architecture and the target triple contained within.
//------------------------------------------------------------------
virtual bool IsCompatibleArchitecture(const ArchSpec &arch,
bool exact_arch_match,
ArchSpec *compatible_arch_ptr);
//------------------------------------------------------------------
/// Not all platforms will support debugging a process by spawning
/// somehow halted for a debugger (specified using the
/// "eLaunchFlagDebug" launch flag) and then attaching. If your
/// platform doesn't support this, override this function and return
/// false.
//------------------------------------------------------------------
virtual bool CanDebugProcess() { return true; }
//------------------------------------------------------------------
/// Subclasses do not need to implement this function as it uses
/// the Platform::LaunchProcess() followed by Platform::Attach ().
/// Remote platforms will want to subclass this function in order
/// to be able to intercept STDIO and possibly launch a separate
/// process that will debug the debuggee.
//------------------------------------------------------------------
virtual lldb::ProcessSP
DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
Target *target, // Can be nullptr, if nullptr create a new
// target, else use existing one
Error &error);
virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
llvm::StringRef plugin_name,
lldb_private::Debugger &debugger,
lldb_private::Target *target,
lldb_private::Error &error);
//------------------------------------------------------------------
/// Attach to an existing process using a process ID.
///
/// Each platform subclass needs to implement this function and
/// attempt to attach to the process with the process ID of \a pid.
/// The platform subclass should return an appropriate ProcessSP
/// subclass that is attached to the process, or an empty shared
/// pointer with an appropriate error.
///
/// @param[in] pid
/// The process ID that we should attempt to attach to.
///
/// @return
/// An appropriate ProcessSP containing a valid shared pointer
/// to the default Process subclass for the platform that is
/// attached to the process, or an empty shared pointer with an
/// appropriate error fill into the \a error object.
//------------------------------------------------------------------
virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info,
Debugger &debugger,
Target *target, // Can be nullptr, if nullptr
// create a new target, else
// use existing one
Error &error) = 0;
//------------------------------------------------------------------
/// Attach to an existing process by process name.
///
/// This function is not meant to be overridden by Process
/// subclasses. It will first call
/// Process::WillAttach (const char *) and if that returns \b
/// true, Process::DoAttach (const char *) will be called to
/// actually do the attach. If DoAttach returns \b true, then
/// Process::DidAttach() will be called.
///
/// @param[in] process_name
/// A process name to match against the current process list.
///
/// @return
/// Returns \a pid if attaching was successful, or
/// LLDB_INVALID_PROCESS_ID if attaching fails.
//------------------------------------------------------------------
// virtual lldb::ProcessSP
// Attach (const char *process_name,
// bool wait_for_launch,
// Error &error) = 0;
//------------------------------------------------------------------
// The base class Platform will take care of the host platform.
// Subclasses will need to fill in the remote case.
//------------------------------------------------------------------
virtual uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
ProcessInstanceInfoList &proc_infos);
virtual bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info);
//------------------------------------------------------------------
// Set a breakpoint on all functions that can end up creating a thread
// for this platform. This is needed when running expressions and
// also for process control.
//------------------------------------------------------------------
virtual lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target);
//------------------------------------------------------------------
// Given a target, find the local SDK directory if one exists on the
// current host.
//------------------------------------------------------------------
virtual lldb_private::ConstString
GetSDKDirectory(lldb_private::Target &target) {
return lldb_private::ConstString();
}
const std::string &GetRemoteURL() const { return m_remote_url; }
bool IsHost() const {
return m_is_host; // Is this the default host platform?
}
bool IsRemote() const { return !m_is_host; }
virtual bool IsConnected() const {
// Remote subclasses should override this function
return IsHost();
}
const ArchSpec &GetSystemArchitecture();
void SetSystemArchitecture(const ArchSpec &arch) {
m_system_arch = arch;
if (IsHost())
m_os_version_set_while_connected = m_system_arch.IsValid();
}
// Used for column widths
size_t GetMaxUserIDNameLength() const { return m_max_uid_name_len; }
// Used for column widths
size_t GetMaxGroupIDNameLength() const { return m_max_gid_name_len; }
const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; }
void SetSDKRootDirectory(const ConstString &dir) { m_sdk_sysroot = dir; }
const ConstString &GetSDKBuild() const { return m_sdk_build; }
void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; }
// Override this to return true if your platform supports Clang modules.
// You may also need to override AddClangModuleCompilationOptions to pass the
// right Clang flags for your platform.
virtual bool SupportsModules() { return false; }
// Appends the platform-specific options required to find the modules for the
// current platform.
virtual void
AddClangModuleCompilationOptions(Target *target,
std::vector<std::string> &options);
FileSpec GetWorkingDirectory();
bool SetWorkingDirectory(const FileSpec &working_dir);
// There may be modules that we don't want to find by default for operations
// like "setting breakpoint by name".
// The platform will return "true" from this call if the passed in module
// happens to be one of these.
virtual bool
ModuleIsExcludedForUnconstrainedSearches(Target &target,
const lldb::ModuleSP &module_sp) {
return false;
}
virtual Error MakeDirectory(const FileSpec &file_spec, uint32_t permissions);
virtual Error GetFilePermissions(const FileSpec &file_spec,
uint32_t &file_permissions);
virtual Error SetFilePermissions(const FileSpec &file_spec,
uint32_t file_permissions);
virtual lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
uint32_t mode, Error &error) {
return UINT64_MAX;
}
virtual bool CloseFile(lldb::user_id_t fd, Error &error) { return false; }
virtual lldb::user_id_t GetFileSize(const FileSpec &file_spec) {
return UINT64_MAX;
}
virtual uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
uint64_t dst_len, Error &error) {
error.SetErrorStringWithFormat(
"Platform::ReadFile() is not supported in the %s platform",
GetName().GetCString());
return -1;
}
virtual uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset,
const void *src, uint64_t src_len, Error &error) {
error.SetErrorStringWithFormat(
"Platform::ReadFile() is not supported in the %s platform",
GetName().GetCString());
return -1;
}
virtual Error GetFile(const FileSpec &source, const FileSpec &destination);
virtual Error PutFile(const FileSpec &source, const FileSpec &destination,
uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX);
virtual Error
CreateSymlink(const FileSpec &src, // The name of the link is in src
const FileSpec &dst); // The symlink points to dst
//----------------------------------------------------------------------
/// Install a file or directory to the remote system.
///
/// Install is similar to Platform::PutFile(), but it differs in that if
/// an application/framework/shared library is installed on a remote
/// platform and the remote platform requires something to be done to
/// register the application/framework/shared library, then this extra
/// registration can be done.
///
/// @param[in] src
/// The source file/directory to install on the remote system.
///
/// @param[in] dst
/// The destination file/directory where \a src will be installed.
/// If \a dst has no filename specified, then its filename will
/// be set from \a src. It \a dst has no directory specified, it
/// will use the platform working directory. If \a dst has a
/// directory specified, but the directory path is relative, the
/// platform working directory will be prepended to the relative
/// directory.
///
/// @return
/// An error object that describes anything that went wrong.
//----------------------------------------------------------------------
virtual Error Install(const FileSpec &src, const FileSpec &dst);
virtual size_t GetEnvironment(StringList &environment);
virtual bool GetFileExists(const lldb_private::FileSpec &file_spec);
virtual Error Unlink(const FileSpec &file_spec);
virtual uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
unsigned flags);
virtual bool GetSupportsRSync() { return m_supports_rsync; }
virtual void SetSupportsRSync(bool flag) { m_supports_rsync = flag; }
virtual const char *GetRSyncOpts() { return m_rsync_opts.c_str(); }
virtual void SetRSyncOpts(const char *opts) { m_rsync_opts.assign(opts); }
virtual const char *GetRSyncPrefix() { return m_rsync_prefix.c_str(); }
virtual void SetRSyncPrefix(const char *prefix) {
m_rsync_prefix.assign(prefix);
}
virtual bool GetSupportsSSH() { return m_supports_ssh; }
virtual void SetSupportsSSH(bool flag) { m_supports_ssh = flag; }
virtual const char *GetSSHOpts() { return m_ssh_opts.c_str(); }
virtual void SetSSHOpts(const char *opts) { m_ssh_opts.assign(opts); }
virtual bool GetIgnoresRemoteHostname() { return m_ignores_remote_hostname; }
virtual void SetIgnoresRemoteHostname(bool flag) {
m_ignores_remote_hostname = flag;
}
virtual lldb_private::OptionGroupOptions *
GetConnectionOptions(CommandInterpreter &interpreter) {
return nullptr;
}
virtual lldb_private::Error RunShellCommand(
const char *command, // Shouldn't be nullptr
const FileSpec &working_dir, // Pass empty FileSpec to use the current
// working directory
int *status_ptr, // Pass nullptr if you don't want the process exit status
int *signo_ptr, // Pass nullptr if you don't want the signal that caused
// the process to exit
std::string
*command_output, // Pass nullptr if you don't want the command output
uint32_t timeout_sec); // Timeout in seconds to wait for shell program to
// finish
virtual void SetLocalCacheDirectory(const char *local);
virtual const char *GetLocalCacheDirectory();
virtual std::string GetPlatformSpecificConnectionInformation() { return ""; }
virtual bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
uint64_t &high);
virtual int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
return 1;
}
virtual const lldb::UnixSignalsSP &GetRemoteUnixSignals();
const lldb::UnixSignalsSP &GetUnixSignals();
//------------------------------------------------------------------
/// Locate a queue name given a thread's qaddr
///
/// On a system using libdispatch ("Grand Central Dispatch") style
/// queues, a thread may be associated with a GCD queue or not,
/// and a queue may be associated with multiple threads.
/// The process/thread must provide a way to find the "dispatch_qaddr"
/// for each thread, and from that dispatch_qaddr this Platform method
/// will locate the queue name and provide that.
///
/// @param[in] process
/// A process is required for reading memory.
///
/// @param[in] dispatch_qaddr
/// The dispatch_qaddr for this thread.
///
/// @return
/// The name of the queue, if there is one. An empty string
/// means that this thread is not associated with a dispatch
/// queue.
//------------------------------------------------------------------
virtual std::string
GetQueueNameForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) {
return "";
}
//------------------------------------------------------------------
/// Locate a queue ID given a thread's qaddr
///
/// On a system using libdispatch ("Grand Central Dispatch") style
/// queues, a thread may be associated with a GCD queue or not,
/// and a queue may be associated with multiple threads.
/// The process/thread must provide a way to find the "dispatch_qaddr"
/// for each thread, and from that dispatch_qaddr this Platform method
/// will locate the queue ID and provide that.
///
/// @param[in] process
/// A process is required for reading memory.
///
/// @param[in] dispatch_qaddr
/// The dispatch_qaddr for this thread.
///
/// @return
/// The queue_id for this thread, if this thread is associated
/// with a dispatch queue. Else LLDB_INVALID_QUEUE_ID is returned.
//------------------------------------------------------------------
virtual lldb::queue_id_t
GetQueueIDForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) {
return LLDB_INVALID_QUEUE_ID;
}
//------------------------------------------------------------------
/// Provide a list of trap handler function names for this platform
///
/// The unwinder needs to treat trap handlers specially -- the stack
/// frame may not be aligned correctly for a trap handler (the kernel
/// often won't perturb the stack pointer, or won't re-align it properly,
/// in the process of calling the handler) and the frame above the handler
/// needs to be treated by the unwinder's "frame 0" rules instead of its
/// "middle of the stack frame" rules.
///
/// In a user process debugging scenario, the list of trap handlers is
/// typically just "_sigtramp".
///
/// The Platform base class provides the m_trap_handlers ivar but it does
/// not populate it. Subclasses should add the names of the asynchronous
/// signal handler routines as needed. For most Unix platforms, add
/// _sigtramp.
///
/// @return
/// A list of symbol names. The list may be empty.
//------------------------------------------------------------------
virtual const std::vector<ConstString> &GetTrapHandlerSymbolNames();
//------------------------------------------------------------------
/// Find a support executable that may not live within in the
/// standard locations related to LLDB.
///
/// Executable might exist within the Platform SDK directories, or
/// in standard tool directories within the current IDE that is
/// running LLDB.
///
/// @param[in] basename
/// The basename of the executable to locate in the current
/// platform.
///
/// @return
/// A FileSpec pointing to the executable on disk, or an invalid
/// FileSpec if the executable cannot be found.
//------------------------------------------------------------------
virtual FileSpec LocateExecutable(const char *basename) { return FileSpec(); }
//------------------------------------------------------------------
/// Allow the platform to set preferred memory cache line size. If non-zero
/// (and the user
/// has not set cache line size explicitly), this value will be used as the
/// cache line
/// size for memory reads.
//------------------------------------------------------------------
virtual uint32_t GetDefaultMemoryCacheLineSize() { return 0; }
//------------------------------------------------------------------
/// Load a shared library into this process.
///
/// Try and load a shared library into the current process. This
/// call might fail in the dynamic loader plug-in says it isn't safe
/// to try and load shared libraries at the moment.
///
/// @param[in] process
/// The process to load the image.
///
/// @param[in] local_file
/// The file spec that points to the shared library that you want
/// to load if the library is located on the host. The library will
/// be copied over to the location specified by remote_file or into
/// the current working directory with the same filename if the
/// remote_file isn't specified.
///
/// @param[in] remote_file
/// If local_file is specified then the location where the library
/// should be copied over from the host. If local_file isn't
/// specified, then the path for the shared library on the target
/// what you want to load.
///
/// @param[out] error
/// An error object that gets filled in with any errors that
/// might occur when trying to load the shared library.
///
/// @return
/// A token that represents the shared library that can be
/// later used to unload the shared library. A value of
/// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
/// library can't be opened.
//------------------------------------------------------------------
uint32_t LoadImage(lldb_private::Process *process,
const lldb_private::FileSpec &local_file,
const lldb_private::FileSpec &remote_file,
lldb_private::Error &error);
virtual uint32_t DoLoadImage(lldb_private::Process *process,
const lldb_private::FileSpec &remote_file,
lldb_private::Error &error);
virtual Error UnloadImage(lldb_private::Process *process,
uint32_t image_token);
//------------------------------------------------------------------
/// Connect to all processes waiting for a debugger to attach
///
/// If the platform have a list of processes waiting for a debugger
/// to connect to them then connect to all of these pending processes.
///
/// @param[in] debugger
/// The debugger used for the connect.
///
/// @param[out] error
/// If an error occurred during the connect then this object will
/// contain the error message.
///
/// @return
/// The number of processes we are successfully connected to.
//------------------------------------------------------------------
virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
lldb_private::Error &error);
protected:
bool m_is_host;
// Set to true when we are able to actually set the OS version while
// being connected. For remote platforms, we might set the version ahead
// of time before we actually connect and this version might change when
// we actually connect to a remote platform. For the host platform this
// will be set to the once we call HostInfo::GetOSVersion().
bool m_os_version_set_while_connected;
bool m_system_arch_set_while_connected;
ConstString
m_sdk_sysroot; // the root location of where the SDK files are all located
ConstString m_sdk_build;
FileSpec m_working_dir; // The working directory which is used when installing
// modules that have no install path set
std::string m_remote_url;
std::string m_name;
uint32_t m_major_os_version;
uint32_t m_minor_os_version;
uint32_t m_update_os_version;
ArchSpec
m_system_arch; // The architecture of the kernel or the remote platform
typedef std::map<uint32_t, ConstString> IDToNameMap;
// Mutex for modifying Platform data structures that should only be used for
// non-reentrant code
std::mutex m_mutex;
IDToNameMap m_uid_map;
IDToNameMap m_gid_map;
size_t m_max_uid_name_len;
size_t m_max_gid_name_len;
bool m_supports_rsync;
std::string m_rsync_opts;
std::string m_rsync_prefix;
bool m_supports_ssh;
std::string m_ssh_opts;
bool m_ignores_remote_hostname;
std::string m_local_cache_directory;
std::vector<ConstString> m_trap_handlers;
bool m_calculated_trap_handlers;
const std::unique_ptr<ModuleCache> m_module_cache;
//------------------------------------------------------------------
/// Ask the Platform subclass to fill in the list of trap handler names
///
/// For most Unix user process environments, this will be a single
/// function name, _sigtramp. More specialized environments may have
/// additional handler names. The unwinder code needs to know when a
/// trap handler is on the stack because the unwind rules for the frame
/// that caused the trap are different.
///
/// The base class Platform ivar m_trap_handlers should be updated by
/// the Platform subclass when this method is called. If there are no
/// predefined trap handlers, this method may be a no-op.
//------------------------------------------------------------------
virtual void CalculateTrapHandlerSymbolNames() = 0;
const char *GetCachedUserName(uint32_t uid) {
std::lock_guard<std::mutex> guard(m_mutex);
// return the empty string if our string is NULL
// so we can tell when things were in the negative
// cached (didn't find a valid user name, don't keep
// trying)
const auto pos = m_uid_map.find(uid);
return ((pos != m_uid_map.end()) ? pos->second.AsCString("") : nullptr);
}
const char *SetCachedUserName(uint32_t uid, const char *name,
size_t name_len) {
std::lock_guard<std::mutex> guard(m_mutex);
ConstString const_name(name);
m_uid_map[uid] = const_name;
if (m_max_uid_name_len < name_len)
m_max_uid_name_len = name_len;
// Const strings lives forever in our const string pool, so we can return
// the const char *
return const_name.GetCString();
}
void SetUserNameNotFound(uint32_t uid) {
std::lock_guard<std::mutex> guard(m_mutex);
m_uid_map[uid] = ConstString();
}
void ClearCachedUserNames() {
std::lock_guard<std::mutex> guard(m_mutex);
m_uid_map.clear();
}
const char *GetCachedGroupName(uint32_t gid) {
std::lock_guard<std::mutex> guard(m_mutex);
// return the empty string if our string is NULL
// so we can tell when things were in the negative
// cached (didn't find a valid group name, don't keep
// trying)
const auto pos = m_gid_map.find(gid);
return ((pos != m_gid_map.end()) ? pos->second.AsCString("") : nullptr);
}
const char *SetCachedGroupName(uint32_t gid, const char *name,
size_t name_len) {
std::lock_guard<std::mutex> guard(m_mutex);
ConstString const_name(name);
m_gid_map[gid] = const_name;
if (m_max_gid_name_len < name_len)
m_max_gid_name_len = name_len;
// Const strings lives forever in our const string pool, so we can return
// the const char *
return const_name.GetCString();
}
void SetGroupNameNotFound(uint32_t gid) {
std::lock_guard<std::mutex> guard(m_mutex);
m_gid_map[gid] = ConstString();
}
void ClearCachedGroupNames() {
std::lock_guard<std::mutex> guard(m_mutex);
m_gid_map.clear();
}
Error GetCachedExecutable(ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
Platform &remote_platform);
virtual Error DownloadModuleSlice(const FileSpec &src_file_spec,
const uint64_t src_offset,
const uint64_t src_size,
const FileSpec &dst_file_spec);
virtual Error DownloadSymbolFile(const lldb::ModuleSP &module_sp,
const FileSpec &dst_file_spec);
virtual const char *GetCacheHostname();
private:
typedef std::function<Error(const ModuleSpec &)> ModuleResolver;
Error GetRemoteSharedModule(const ModuleSpec &module_spec, Process *process,
lldb::ModuleSP &module_sp,
const ModuleResolver &module_resolver,
bool *did_create_ptr);
bool GetCachedSharedModule(const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp, bool *did_create_ptr);
Error LoadCachedExecutable(const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
Platform &remote_platform);
FileSpec GetModuleCacheRoot();
DISALLOW_COPY_AND_ASSIGN(Platform);
};
class PlatformList {
public:
PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {}
~PlatformList() = default;
void Append(const lldb::PlatformSP &platform_sp, bool set_selected) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_platforms.push_back(platform_sp);
if (set_selected)
m_selected_platform_sp = m_platforms.back();
}
size_t GetSize() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_platforms.size();
}
lldb::PlatformSP GetAtIndex(uint32_t idx) {
lldb::PlatformSP platform_sp;
{
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (idx < m_platforms.size())
platform_sp = m_platforms[idx];
}
return platform_sp;
}
//------------------------------------------------------------------
/// Select the active platform.
///
/// In order to debug remotely, other platform's can be remotely
/// connected to and set as the selected platform for any subsequent
/// debugging. This allows connection to remote targets and allows
/// the ability to discover process info, launch and attach to remote
/// processes.
//------------------------------------------------------------------
lldb::PlatformSP GetSelectedPlatform() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_selected_platform_sp && !m_platforms.empty())
m_selected_platform_sp = m_platforms.front();
return m_selected_platform_sp;
}
void SetSelectedPlatform(const lldb::PlatformSP &platform_sp) {
if (platform_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
const size_t num_platforms = m_platforms.size();
for (size_t idx = 0; idx < num_platforms; ++idx) {
if (m_platforms[idx].get() == platform_sp.get()) {
m_selected_platform_sp = m_platforms[idx];
return;
}
}
m_platforms.push_back(platform_sp);
m_selected_platform_sp = m_platforms.back();
}
}
protected:
typedef std::vector<lldb::PlatformSP> collection;
mutable std::recursive_mutex m_mutex;
collection m_platforms;
lldb::PlatformSP m_selected_platform_sp;
private:
DISALLOW_COPY_AND_ASSIGN(PlatformList);
};
class OptionGroupPlatformRSync : public lldb_private::OptionGroup {
public:
OptionGroupPlatformRSync() = default;
~OptionGroupPlatformRSync() override = default;
lldb_private::Error
SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
ExecutionContext *execution_context) override;
void OptionParsingStarting(ExecutionContext *execution_context) override;
llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
// Options table: Required for subclasses of Options.
static lldb_private::OptionDefinition g_option_table[];
// Instance variables to hold the values for command options.
bool m_rsync;
std::string m_rsync_opts;
std::string m_rsync_prefix;
bool m_ignores_remote_hostname;
private:
DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync);
};
class OptionGroupPlatformSSH : public lldb_private::OptionGroup {
public:
OptionGroupPlatformSSH() = default;
~OptionGroupPlatformSSH() override = default;
lldb_private::Error
SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
ExecutionContext *execution_context) override;
void OptionParsingStarting(ExecutionContext *execution_context) override;
llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
// Options table: Required for subclasses of Options.
static lldb_private::OptionDefinition g_option_table[];
// Instance variables to hold the values for command options.
bool m_ssh;
std::string m_ssh_opts;
private:
DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH);
};
class OptionGroupPlatformCaching : public lldb_private::OptionGroup {
public:
OptionGroupPlatformCaching() = default;
~OptionGroupPlatformCaching() override = default;
lldb_private::Error
SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
ExecutionContext *execution_context) override;
void OptionParsingStarting(ExecutionContext *execution_context) override;
llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
// Options table: Required for subclasses of Options.
static lldb_private::OptionDefinition g_option_table[];
// Instance variables to hold the values for command options.
std::string m_cache_dir;
private:
DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching);
};
} // namespace lldb_private
#endif // liblldb_Platform_h_
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/tools/darwin-threads/examine-threads.c | #include <ctype.h>
#include <dispatch/dispatch.h>
#include <errno.h>
#include <libproc.h>
#include <mach/mach.h>
#include <mach/task_info.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/sysctl.h>
#include <time.h>
// from System.framework/Versions/B/PrivateHeaders/sys/codesign.h
#define CS_OPS_STATUS 0 /* return status */
#define CS_RESTRICT 0x0000800 /* tell dyld to treat restricted */
int csops(pid_t pid, unsigned int ops, void *useraddr, size_t usersize);
/* Step through the process table, find a matching process name, return
the pid of that matched process.
If there are multiple processes with that name, issue a warning on stdout
and return the highest numbered process.
The proc_pidpath() call is used which gets the full process name including
directories to the executable and the full (longer than 16 character)
executable name. */
pid_t get_pid_for_process_name(const char *procname) {
int process_count = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0) / sizeof(pid_t);
if (process_count < 1) {
printf("Only found %d processes running!\n", process_count);
exit(1);
}
// Allocate a few extra slots in case new processes are spawned
int all_pids_size = sizeof(pid_t) * (process_count + 3);
pid_t *all_pids = (pid_t *)malloc(all_pids_size);
// re-set process_count in case the number of processes changed (got smaller;
// we won't do bigger)
process_count =
proc_listpids(PROC_ALL_PIDS, 0, all_pids, all_pids_size) / sizeof(pid_t);
int i;
pid_t highest_pid = 0;
int match_count = 0;
for (i = 1; i < process_count; i++) {
char pidpath[PATH_MAX];
int pidpath_len = proc_pidpath(all_pids[i], pidpath, sizeof(pidpath));
if (pidpath_len == 0)
continue;
char *j = strrchr(pidpath, '/');
if ((j == NULL && strcmp(procname, pidpath) == 0) ||
(j != NULL && strcmp(j + 1, procname) == 0)) {
match_count++;
if (all_pids[i] > highest_pid)
highest_pid = all_pids[i];
}
}
free(all_pids);
if (match_count == 0) {
printf("Did not find process '%s'.\n", procname);
exit(1);
}
if (match_count > 1) {
printf("Warning: More than one process '%s'!\n", procname);
printf(" defaulting to the highest-pid one, %d\n", highest_pid);
}
return highest_pid;
}
/* Given a pid, get the full executable name (including directory
paths and the longer-than-16-chars executable name) and return
the basename of that (i.e. do not include the directory components).
This function mallocs the memory for the string it returns;
the caller must free this memory. */
const char *get_process_name_for_pid(pid_t pid) {
char tmp_name[PATH_MAX];
if (proc_pidpath(pid, tmp_name, sizeof(tmp_name)) == 0) {
printf("Could not find process with pid of %d\n", (int)pid);
exit(1);
}
if (strrchr(tmp_name, '/'))
return strdup(strrchr(tmp_name, '/') + 1);
else
return strdup(tmp_name);
}
/* Get a struct kinfo_proc structure for a given pid.
Process name is required for error printing.
Gives you the current state of the process and whether it is being debugged
by anyone.
memory is malloc()'ed for the returned struct kinfo_proc
and must be freed by the caller. */
struct kinfo_proc *get_kinfo_proc_for_pid(pid_t pid, const char *process_name) {
struct kinfo_proc *kinfo =
(struct kinfo_proc *)malloc(sizeof(struct kinfo_proc));
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
size_t len = sizeof(struct kinfo_proc);
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), kinfo, &len, NULL, 0) != 0) {
free((void *)kinfo);
printf("Could not get kinfo_proc for pid %d\n", (int)pid);
exit(1);
}
return kinfo;
}
/* Get the basic information (thread_basic_info_t) about a given
thread.
Gives you the suspend count; thread state; user time; system time; sleep
time; etc.
The return value is a pointer to malloc'ed memory - it is the caller's
responsibility to free it. */
thread_basic_info_t get_thread_basic_info(thread_t thread) {
kern_return_t kr;
integer_t *thinfo = (integer_t *)malloc(sizeof(integer_t) * THREAD_INFO_MAX);
mach_msg_type_number_t thread_info_count = THREAD_INFO_MAX;
kr = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t)thinfo,
&thread_info_count);
if (kr != KERN_SUCCESS) {
printf("Error - unable to get basic thread info for a thread\n");
exit(1);
}
return (thread_basic_info_t)thinfo;
}
/* Get the thread identifier info (thread_identifier_info_data_t)
about a given thread.
Gives you the system-wide unique thread number; the pthread identifier number
*/
thread_identifier_info_data_t get_thread_identifier_info(thread_t thread) {
kern_return_t kr;
thread_identifier_info_data_t tident;
mach_msg_type_number_t tident_count = THREAD_IDENTIFIER_INFO_COUNT;
kr = thread_info(thread, THREAD_IDENTIFIER_INFO, (thread_info_t)&tident,
&tident_count);
if (kr != KERN_SUCCESS) {
printf("Error - unable to get thread ident for a thread\n");
exit(1);
}
return tident;
}
/* Given a mach port # (in the examine-threads mach port namespace) for a
thread,
find the mach port # in the inferior program's port namespace.
Sets inferior_port if successful.
Returns true if successful, false if unable to find the port number. */
bool inferior_namespace_mach_port_num(task_t task,
thread_t examine_threads_port,
thread_t *inferior_port) {
kern_return_t retval;
mach_port_name_array_t names;
mach_msg_type_number_t nameslen;
mach_port_type_array_t types;
mach_msg_type_number_t typeslen;
if (inferior_port == NULL)
return false;
retval = mach_port_names(task, &names, &nameslen, &types, &typeslen);
if (retval != KERN_SUCCESS) {
printf("Error - unable to get mach port names for inferior.\n");
return false;
}
int i = 0;
for (i = 0; i < nameslen; i++) {
mach_port_t local_name;
mach_msg_type_name_t local_type;
retval = mach_port_extract_right(task, names[i], MACH_MSG_TYPE_COPY_SEND,
&local_name, &local_type);
if (retval == KERN_SUCCESS) {
mach_port_deallocate(mach_task_self(), local_name);
if (local_name == examine_threads_port) {
*inferior_port = names[i];
vm_deallocate(mach_task_self(), (vm_address_t)names,
nameslen * sizeof(mach_port_t));
vm_deallocate(mach_task_self(), (vm_address_t)types,
typeslen * sizeof(mach_port_t));
return true;
}
}
}
vm_deallocate(mach_task_self(), (vm_address_t)names,
nameslen * sizeof(mach_port_t));
vm_deallocate(mach_task_self(), (vm_address_t)types,
typeslen * sizeof(mach_port_t));
return false;
}
/* Get the current pc value for a given thread. */
uint64_t get_current_pc(thread_t thread, int *wordsize) {
kern_return_t kr;
#if defined(__x86_64__) || defined(__i386__)
x86_thread_state_t gp_regs;
mach_msg_type_number_t gp_count = x86_THREAD_STATE_COUNT;
kr = thread_get_state(thread, x86_THREAD_STATE, (thread_state_t)&gp_regs,
&gp_count);
if (kr != KERN_SUCCESS) {
printf("Error - unable to get registers for a thread\n");
exit(1);
}
if (gp_regs.tsh.flavor == x86_THREAD_STATE64) {
*wordsize = 8;
return gp_regs.uts.ts64.__rip;
} else {
*wordsize = 4;
return gp_regs.uts.ts32.__eip;
}
#endif
#if defined(__arm__)
arm_thread_state_t gp_regs;
mach_msg_type_number_t gp_count = ARM_THREAD_STATE_COUNT;
kr = thread_get_state(thread, ARM_THREAD_STATE, (thread_state_t)&gp_regs,
&gp_count);
if (kr != KERN_SUCCESS) {
printf("Error - unable to get registers for a thread\n");
exit(1);
}
*wordsize = 4;
return gp_regs.__pc;
#endif
#if defined(__arm64__)
arm_thread_state64_t gp_regs;
mach_msg_type_number_t gp_count = ARM_THREAD_STATE64_COUNT;
kr = thread_get_state(thread, ARM_THREAD_STATE64, (thread_state_t)&gp_regs,
&gp_count);
if (kr != KERN_SUCCESS) {
printf("Error - unable to get registers for a thread\n");
exit(1);
}
*wordsize = 8;
return gp_regs.__pc;
#endif
}
/* Get the proc_threadinfo for a given thread.
Gives you the thread name, if set; current and max priorities.
Returns 1 if successful
Returns 0 if proc_pidinfo() failed
*/
int get_proc_threadinfo(pid_t pid, uint64_t thread_handle,
struct proc_threadinfo *pth) {
pth->pth_name[0] = '\0';
int ret = proc_pidinfo(pid, PROC_PIDTHREADINFO, thread_handle, pth,
sizeof(struct proc_threadinfo));
if (ret != 0)
return 1;
else
return 0;
}
int main(int argc, char **argv) {
kern_return_t kr;
task_t task;
pid_t pid = 0;
char *procname = NULL;
int arg_is_procname = 0;
int do_loop = 0;
int verbose = 0;
int resume_when_done = 0;
mach_port_t mytask = mach_task_self();
if (argc != 2 && argc != 3 && argc != 4 && argc != 5) {
printf("Usage: tdump [-l] [-v] [-r] pid/procname\n");
exit(1);
}
if (argc == 3 || argc == 4) {
int i = 1;
while (i < argc - 1) {
if (strcmp(argv[i], "-l") == 0)
do_loop = 1;
if (strcmp(argv[i], "-v") == 0)
verbose = 1;
if (strcmp(argv[i], "-r") == 0)
resume_when_done++;
i++;
}
}
char *c = argv[argc - 1];
if (*c == '\0') {
printf("Usage: tdump [-l] [-v] pid/procname\n");
exit(1);
}
while (*c != '\0') {
if (!isdigit(*c)) {
arg_is_procname = 1;
procname = argv[argc - 1];
break;
}
c++;
}
if (arg_is_procname && procname) {
pid = get_pid_for_process_name(procname);
} else {
errno = 0;
pid = (pid_t)strtol(argv[argc - 1], NULL, 10);
if (pid == 0 && errno == EINVAL) {
printf("Usage: tdump [-l] [-v] pid/procname\n");
exit(1);
}
}
const char *process_name = get_process_name_for_pid(pid);
// At this point "pid" is the process id and "process_name" is the process
// name
// Now we have to get the process list from the kernel (which only has the
// truncated
// 16 char names)
struct kinfo_proc *kinfo = get_kinfo_proc_for_pid(pid, process_name);
printf("pid %d (%s) is currently ", pid, process_name);
switch (kinfo->kp_proc.p_stat) {
case SIDL:
printf("being created by fork");
break;
case SRUN:
printf("runnable");
break;
case SSLEEP:
printf("sleeping on an address");
break;
case SSTOP:
printf("suspended");
break;
case SZOMB:
printf("zombie state - awaiting collection by parent");
break;
default:
printf("unknown");
}
if (kinfo->kp_proc.p_flag & P_TRACED)
printf(" and is being debugged.");
free((void *)kinfo);
printf("\n");
int csops_flags = 0;
if (csops(pid, CS_OPS_STATUS, &csops_flags, sizeof(csops_flags)) != -1 &&
(csops_flags & CS_RESTRICT)) {
printf("pid %d (%s) is restricted so nothing can attach to it.\n", pid,
process_name);
}
kr = task_for_pid(mach_task_self(), pid, &task);
if (kr != KERN_SUCCESS) {
printf("Error - unable to task_for_pid()\n");
exit(1);
}
struct task_basic_info info;
unsigned int info_count = TASK_BASIC_INFO_COUNT;
kr = task_info(task, TASK_BASIC_INFO, (task_info_t)&info, &info_count);
if (kr != KERN_SUCCESS) {
printf("Error - unable to call task_info.\n");
exit(1);
}
printf("Task suspend count: %d.\n", info.suspend_count);
struct timespec *rqtp = (struct timespec *)malloc(sizeof(struct timespec));
rqtp->tv_sec = 0;
rqtp->tv_nsec = 150000000;
int loop_cnt = 1;
do {
int i;
if (do_loop)
printf("Iteration %d:\n", loop_cnt++);
thread_array_t thread_list;
mach_msg_type_number_t thread_count;
kr = task_threads(task, &thread_list, &thread_count);
if (kr != KERN_SUCCESS) {
printf("Error - unable to get thread list\n");
exit(1);
}
printf("pid %d has %d threads\n", pid, thread_count);
if (verbose)
printf("\n");
for (i = 0; i < thread_count; i++) {
thread_basic_info_t basic_info = get_thread_basic_info(thread_list[i]);
thread_identifier_info_data_t identifier_info =
get_thread_identifier_info(thread_list[i]);
int wordsize;
uint64_t pc = get_current_pc(thread_list[i], &wordsize);
printf("thread #%d, system-wide-unique-tid %lld, suspend count is %d, ",
i, identifier_info.thread_id, basic_info->suspend_count);
if (wordsize == 8)
printf("pc 0x%016llx, ", pc);
else
printf("pc 0x%08llx, ", pc);
printf("run state is ");
switch (basic_info->run_state) {
case TH_STATE_RUNNING:
puts("running");
break;
case TH_STATE_STOPPED:
puts("stopped");
break;
case TH_STATE_WAITING:
puts("waiting");
break;
case TH_STATE_UNINTERRUPTIBLE:
puts("uninterruptible");
break;
case TH_STATE_HALTED:
puts("halted");
break;
default:
puts("");
}
printf(" pthread handle id 0x%llx (not the same value as "
"pthread_self() returns)\n",
(uint64_t)identifier_info.thread_handle);
struct proc_threadinfo pth;
int proc_threadinfo_succeeded =
get_proc_threadinfo(pid, identifier_info.thread_handle, &pth);
if (proc_threadinfo_succeeded && pth.pth_name[0] != '\0')
printf(" thread name '%s'\n", pth.pth_name);
printf(" libdispatch qaddr 0x%llx (not the same as the "
"dispatch_queue_t token)\n",
(uint64_t)identifier_info.dispatch_qaddr);
if (verbose) {
printf(
" (examine-threads port namespace) mach port # 0x%4.4x\n",
(int)thread_list[i]);
thread_t mach_port_inferior_namespace;
if (inferior_namespace_mach_port_num(task, thread_list[i],
&mach_port_inferior_namespace))
printf(" (inferior port namepsace) mach port # 0x%4.4x\n",
(int)mach_port_inferior_namespace);
printf(" user %d.%06ds, system %d.%06ds",
basic_info->user_time.seconds,
basic_info->user_time.microseconds,
basic_info->system_time.seconds,
basic_info->system_time.microseconds);
if (basic_info->cpu_usage > 0) {
float cpu_percentage = basic_info->cpu_usage / 10.0;
printf(", using %.1f%% cpu currently", cpu_percentage);
}
if (basic_info->sleep_time > 0)
printf(", this thread has slept for %d seconds",
basic_info->sleep_time);
printf("\n ");
printf("scheduling policy %d", basic_info->policy);
if (basic_info->flags != 0) {
printf(", flags %d", basic_info->flags);
if ((basic_info->flags | TH_FLAGS_SWAPPED) == TH_FLAGS_SWAPPED)
printf(" (thread is swapped out)");
if ((basic_info->flags | TH_FLAGS_IDLE) == TH_FLAGS_IDLE)
printf(" (thread is idle)");
}
if (proc_threadinfo_succeeded)
printf(", current pri %d, max pri %d", pth.pth_curpri,
pth.pth_maxpriority);
printf("\n\n");
}
free((void *)basic_info);
}
if (do_loop)
printf("\n");
vm_deallocate(mytask, (vm_address_t)thread_list,
thread_count * sizeof(thread_act_t));
nanosleep(rqtp, NULL);
} while (do_loop);
while (resume_when_done > 0) {
kern_return_t err = task_resume(task);
if (err != KERN_SUCCESS)
printf("Error resuming task: %d.", err);
resume_when_done--;
}
vm_deallocate(mytask, (vm_address_t)task, sizeof(task_t));
free((void *)process_name);
return 0;
}
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h | //===-- RegisterContextPOSIX.h --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_RegisterContextPOSIX_H_
#define liblldb_RegisterContextPOSIX_H_
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "RegisterInfoInterface.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Target/RegisterContext.h"
//------------------------------------------------------------------------------
/// @class POSIXBreakpointProtocol
///
/// @brief Extends RegisterClass with a few virtual operations useful on POSIX.
class POSIXBreakpointProtocol {
public:
POSIXBreakpointProtocol() { m_watchpoints_initialized = false; }
virtual ~POSIXBreakpointProtocol() {}
/// Updates the register state of the associated thread after hitting a
/// breakpoint (if that make sense for the architecture). Default
/// implementation simply returns true for architectures which do not
/// require any update.
///
/// @return
/// True if the operation succeeded and false otherwise.
virtual bool UpdateAfterBreakpoint() = 0;
/// Determines the index in lldb's register file given a kernel byte offset.
virtual unsigned GetRegisterIndexFromOffset(unsigned offset) = 0;
// Checks to see if a watchpoint specified by hw_index caused the inferior
// to stop.
virtual bool IsWatchpointHit(uint32_t hw_index) = 0;
// Resets any watchpoints that have been hit.
virtual bool ClearWatchpointHits() = 0;
// Returns the watchpoint address associated with a watchpoint hardware
// index.
virtual lldb::addr_t GetWatchpointAddress(uint32_t hw_index) = 0;
virtual bool IsWatchpointVacant(uint32_t hw_index) = 0;
virtual bool SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
bool read, bool write,
uint32_t hw_index) = 0;
// From lldb_private::RegisterContext
virtual uint32_t NumSupportedHardwareWatchpoints() = 0;
// Force m_watchpoints_initialized to TRUE
void ForceWatchpointsInitialized() { m_watchpoints_initialized = true; }
protected:
bool m_watchpoints_initialized;
};
#endif // #ifndef liblldb_RegisterContextPOSIX_H_
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/tools/lldb-mi/MIUtilSingletonHelper.h | <gh_stars>100-1000
//===-- MIUtilSingletonHelper.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#pragma once
namespace MI {
// In house headers:
#include "MICmnResources.h"
#include "MIUtilString.h"
//++
//============================================================================
// Details: Short cut helper function to simplify repeated initialisation of
// MI components (singletons) required by a client module.
// Type: Template method.
// Args: vErrorResrcId - (R) The string resource ID error message
// identifier to place in errMsg.
// vwrbOk - (RW) On input True = Try to initialize MI driver
// module.
// On output True = MI driver module initialise
// successfully.
// vwrErrMsg - (W) MI driver module initialise error description
// on failure.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
//--
template <typename T>
bool ModuleInit(const MIint vErrorResrcId, bool &vwrbOk,
CMIUtilString &vwrErrMsg) {
if (vwrbOk && !T::Instance().Initialize()) {
vwrbOk = MIstatus::failure;
vwrErrMsg = CMIUtilString::Format(
MIRSRC(vErrorResrcId), T::Instance().GetErrorDescription().c_str());
}
return vwrbOk;
}
//++
//============================================================================
// Details: Short cut helper function to simplify repeated shutdown of
// MI components (singletons) required by a client module.
// Type: Template method.
// Args: vErrorResrcId - (R) The string resource ID error message
// identifier
// to place in errMsg.
// vwrbOk - (W) If not already false make false on module
// shutdown failure.
// vwrErrMsg - (RW) Append to existing error description string
// MI
// driver module initialise error description on
// failure.
// Return: True - Module shutdown succeeded.
// False - Module shutdown failed.
//--
template <typename T>
bool ModuleShutdown(const MIint vErrorResrcId, bool &vwrbOk,
CMIUtilString &vwrErrMsg) {
bool bOk = MIstatus::success;
if (!T::Instance().Shutdown()) {
const bool bMoreThanOneError(!vwrErrMsg.empty());
bOk = MIstatus::failure;
if (bMoreThanOneError)
vwrErrMsg += ", ";
vwrErrMsg += CMIUtilString::Format(
MIRSRC(vErrorResrcId), T::Instance().GetErrorDescription().c_str());
}
vwrbOk = bOk ? vwrbOk : MIstatus::failure;
return bOk;
}
} // namespace MI
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Headers/SimpleKit.h | struct RenamedAgainInAPINotesA {
int field;
} __attribute__((swift_name("bad")));
struct __attribute__((swift_name("bad"))) RenamedAgainInAPINotesB {
int field;
};
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/clang/test/Headers/stdatomic.c | // RUN: %clang_cc1 -std=c11 -E %s | FileCheck %s
#include <stdatomic.h>
int bool_lock_free = ATOMIC_BOOL_LOCK_FREE;
// CHECK: bool_lock_free = {{ *[012] *;}}
int char_lock_free = ATOMIC_CHAR_LOCK_FREE;
// CHECK: char_lock_free = {{ *[012] *;}}
int char16_t_lock_free = ATOMIC_CHAR16_T_LOCK_FREE;
// CHECK: char16_t_lock_free = {{ *[012] *;}}
int char32_t_lock_free = ATOMIC_CHAR32_T_LOCK_FREE;
// CHECK: char32_t_lock_free = {{ *[012] *;}}
int wchar_t_lock_free = ATOMIC_WCHAR_T_LOCK_FREE;
// CHECK: wchar_t_lock_free = {{ *[012] *;}}
int short_lock_free = ATOMIC_SHORT_LOCK_FREE;
// CHECK: short_lock_free = {{ *[012] *;}}
int int_lock_free = ATOMIC_INT_LOCK_FREE;
// CHECK: int_lock_free = {{ *[012] *;}}
int long_lock_free = ATOMIC_LONG_LOCK_FREE;
// CHECK: long_lock_free = {{ *[012] *;}}
int llong_lock_free = ATOMIC_LLONG_LOCK_FREE;
// CHECK: llong_lock_free = {{ *[012] *;}}
int pointer_lock_free = ATOMIC_POINTER_LOCK_FREE;
// CHECK: pointer_lock_free = {{ *[012] *;}}
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/compiler-rt/test/profile/Linux/prctl.c | // RUN: %clang_pgogen -O2 -o %t %s
// RUN: rm -rf default_*.profraw
// RUN: %run %t && sleep 1
// RUN: llvm-profdata show default_*.profraw 2>&1 | FileCheck %s
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include <unistd.h>
#define FAKE_COUNT_SZ 2000000
/* fake counts to increse the profile size. */
unsigned long long __attribute__((section("__llvm_prf_cnts")))
counts[FAKE_COUNT_SZ];
int main(int argc, char **argv) {
pid_t pid = fork();
if (pid == 0) {
int i;
int sum = 0;
/* child process: sleep 500us and get to runtime before the
* main process exits. */
prctl(PR_SET_PDEATHSIG, SIGKILL);
usleep(500);
for (i = 0; i < 5000; ++i)
sum += i * i * i;
printf("child process (%d): sum=%d\n", getpid(), sum);
} else if (pid > 0) {
/* parent process: sleep 100us to get into profile runtime first. */
usleep(100);
}
return 0;
}
// CHECK-NOT: Empty raw profile file
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/clang/include/clang/DirectoryWatcher/DirectoryWatcher.h | <filename>SymbolExtractorAndRenamer/clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
//===- DirectoryWatcher.h - Listens for directory file changes --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/// \file
/// \brief Utility class for listening for file system changes in a directory.
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
#define LLVM_CLANG_DIRECTORYWATCHER_DIRECTORYWATCHER_H
#include "clang/Basic/LLVM.h"
#include "clang/Index/IndexDataStore.h"
#include <functional>
#include <memory>
#include <string>
namespace clang {
/// Provides notifications for file system changes in a directory.
///
/// Guarantees that the first time the directory is processed, the receiver will
/// be invoked even if the directory is empty.
class DirectoryWatcher : public index::AbstractDirectoryWatcher {
struct Implementation;
Implementation &Impl;
DirectoryWatcher();
DirectoryWatcher(const DirectoryWatcher&) = delete;
DirectoryWatcher &operator =(const DirectoryWatcher&) = delete;
public:
~DirectoryWatcher();
static std::unique_ptr<DirectoryWatcher>
create(StringRef Path, EventReceiver Receiver, bool waitInitialSync,
std::string &Error);
};
} // namespace clang
#endif
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/clang/test/Analysis/gmalloc.c | // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s
#include "Inputs/system-header-simulator.h"
typedef void* gpointer;
typedef const void* gconstpointer;
typedef unsigned long gsize;
typedef unsigned int guint;
gpointer g_malloc(gsize n_bytes);
gpointer g_malloc0(gsize n_bytes);
gpointer g_realloc(gpointer mem, gsize n_bytes);
gpointer g_try_malloc(gsize n_bytes);
gpointer g_try_malloc0(gsize n_bytes);
gpointer g_try_realloc(gpointer mem, gsize n_bytes);
void g_free(gpointer mem);
gpointer g_memdup(gconstpointer mem, guint byte_size);
static const gsize n_bytes = 1024;
void f1() {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
gpointer g3 = g_try_malloc(n_bytes);
gpointer g4 = g_try_malloc0(n_bytes);
g3 = g_try_realloc(g3, n_bytes * 2);
g_free(g1);
g_free(g2);
g_free(g2); // expected-warning{{Attempt to free released memory}}
}
void f2() {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
gpointer g3 = g_try_malloc(n_bytes);
gpointer g4 = g_try_malloc0(n_bytes);
g3 = g_try_realloc(g3, n_bytes * 2);
g_free(g1);
g_free(g2);
g_free(g3);
g3 = g_memdup(g3, n_bytes); // expected-warning{{Use of memory after it is freed}}
}
void f3() {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
gpointer g3 = g_try_malloc(n_bytes);
gpointer g4 = g_try_malloc0(n_bytes);
g3 = g_try_realloc(g3, n_bytes * 2); // expected-warning{{Potential leak of memory pointed to by 'g4'}}
g_free(g1);
g_free(g2);
g_free(g3);
}
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/swift/include/swift/Obfuscation/NameMapping.h | #ifndef NameMapping_h
#define NameMapping_h
#include "swift/Obfuscation/DataStructures.h"
#include "llvm/Support/Error.h"
#include "swift/Obfuscation/Random.h"
#include "swift/Obfuscation/Utils.h"
#include <string>
#include <vector>
#include <set>
namespace swift {
namespace obfuscation {
/// Name mapping strategies:
/// - Random generates unique random identifiers
/// - Deterministic generates predictible identifiers, we use it in tests
/// - Minifying generates shortes possible names
enum NameMappingStrategy {
Random, Deterministic, Minifying
};
/// Base class for names generators.
class BaseIdentifierGenerator {
protected:
static const std::vector<std::string> UniquelyTailSymbols;
static const std::vector<std::string> HeadSymbols;
static const std::vector<std::string> HeadOperatorSymbols;
static const std::vector<std::string> UniquelyTailOperatorSymbols;
std::map<SymbolType, std::string> SymbolShortNameMap = {
{ SymbolType::Type, "T" },
{ SymbolType::NamedFunction, "NF" },
{ SymbolType::SingleParameter, "SP" },
{ SymbolType::ExternalParameter, "EP" },
{ SymbolType::InternalParameter, "IP" },
{ SymbolType::Variable, "V" },
{ SymbolType::Operator, "O" }
};
std::map<SymbolType, std::map<std::string, int>> SymbolTypeMap = {
{ SymbolType::Type, {} },
{ SymbolType::NamedFunction, {} },
{ SymbolType::SingleParameter, {} },
{ SymbolType::ExternalParameter, {} },
{ SymbolType::InternalParameter, {} },
{ SymbolType::Variable, {} },
{ SymbolType::Operator, {} }
};
// taken from https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html
std::set<std::string> SwiftKeywords = {
"associatedtype", "class", "deinit", "enum", "extension", "fileprivate",
"func", "import", "init", "inout", "internal", "let", "open", "operator",
"private", "protocol", "public", "static", "struct", "subscript",
"typealias", "var", "break", "case", "continue", "default", "defer", "do",
"else", "fallthrough", "for", "guard", "if", "in", "repeat", "return",
"switch", "where", "while", "as", "Any", "catch", "false", "is", "nil",
"rethrows", "super", "self", "Self", "throw", "throws", "true", "try",
"associativity", "convenience", "dynamic", "didSet", "final", "get", "infix",
"indirect", "lazy", "left", "mutating", "none", "nonmutating", "optional",
"override", "postfix", "precedence", "prefix", "Protocol", "required",
"right", "set", "Type", "unowned", "weak", "willSet"
};
static std::vector<std::string>
concatenateSymbols(const std::vector<std::string> &Head,
const std::vector<std::string> &Tail);
public:
virtual llvm::Expected<std::string> generateName(const Symbol &Symbol) = 0;
virtual ~BaseIdentifierGenerator() = default;
};
class NameMapping {
private:
NameMappingStrategy NameMappingStrategy;
std::unique_ptr<BaseIdentifierGenerator> IdentifierGenerator;
std::unique_ptr<BaseIdentifierGenerator> OperatorGenerator;
llvm::Expected<std::string> generateNameForSymbol(const Symbol &Symbol);
public:
NameMapping(enum NameMappingStrategy NameMappingStrategy);
/// Creates renamings for symbols found in SymbolsJson object.
///
/// Rename generation depends on the type of the symbol found in SymbolsJson.
/// Proposed new name for specific type must conform to [Swift Grammar]
/// (https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AboutTheLanguageReference.html).
/// Generated names are unique to ensure that no symbol name collisions will
/// occur after renaming.
///
/// Typical usage:
/// \code
/// // NameMappingStrategy is passed as an option when running the mapper
/// // currently it can be "deterministic" or "random" (empty defaults to "random").
/// NameMapping NameMapping(NameMappingStrategy);
/// auto RenamingsOrError = NameMapping.proposeRenamings(SymbolsJson);
/// if (auto Error = RenamingsOrError.takeError()) {
/// ExitOnError(std::move(Error));
/// }
/// auto Renamings = RenamingsOrError.get();
/// \endcode
///
/// \param SymbolsJson Symbols before renaming
///
/// \returns Symbols with proposed renamings or error.
/// Each SymbolRenaming object contains data of the symbol before renaming
/// and proposed new name.
llvm::Expected<RenamesJson> proposeRenamings(const SymbolsJson &SymbolsJson);
};
} //namespace obfuscation
} //namespace swift
#endif /* NameMapping_h */
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/clang/test/CodeGen/attributes.c | <filename>SymbolExtractorAndRenamer/clang/test/CodeGen/attributes.c
// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
// RUN: FileCheck --input-file=%t %s
// CHECK: @t5 = weak global i32 2
int t5 __attribute__((weak)) = 2;
// CHECK: @t13 = global %struct.s0 zeroinitializer, section "SECT"
struct s0 { int x; };
struct s0 t13 __attribute__((section("SECT"))) = { 0 };
// CHECK: @t14.x = internal global i32 0, section "SECT"
void t14(void) {
static int x __attribute__((section("SECT"))) = 0;
}
// CHECK: @t18 = global i32 1, align 4
extern int t18 __attribute__((weak_import));
int t18 = 1;
// CHECK: @t16 = extern_weak global i32
extern int t16 __attribute__((weak_import));
// CHECK: @t6 = common protected global i32 0
int t6 __attribute__((visibility("protected")));
// CHECK: @t12 = global i32 0, section "SECT"
int t12 __attribute__((section("SECT")));
// CHECK: @t9 = weak alias void (...), bitcast (void ()* @__t8 to void (...)*)
void __t8() {}
void t9() __attribute__((weak, alias("__t8")));
// CHECK: declare extern_weak i32 @t15()
int __attribute__((weak_import)) t15(void);
int t17() {
return t15() + t16;
}
// CHECK: define void @t1() [[NR:#[0-9]+]] {
void t1() __attribute__((noreturn));
void t1() { while (1) {} }
// CHECK: define void @t2() [[NUW:#[0-9]+]] {
void t2() __attribute__((nothrow));
void t2() {}
// CHECK: define weak void @t3() [[NUW]] {
void t3() __attribute__((weak));
void t3() {}
// CHECK: define hidden void @t4() [[NUW]] {
void t4() __attribute__((visibility("hidden")));
void t4() {}
// CHECK: define void @t7() [[NR]] {
void t7() __attribute__((noreturn, nothrow));
void t7() { while (1) {} }
// CHECK: define void @t10() [[NUW]] section "SECT" {
void t10(void) __attribute__((section("SECT")));
void t10(void) {}
// CHECK: define void @t11() [[NUW]] section "SECT" {
void __attribute__((section("SECT"))) t11(void) {}
// CHECK: define i32 @t19() [[NUW]] {
extern int t19(void) __attribute__((weak_import));
int t19(void) {
return 10;
}
// CHECK:define void @t20() [[NUW]] {
// CHECK: call void @abort()
// CHECK-NEXT: unreachable
void t20(void) {
__builtin_abort();
}
void (__attribute__((fastcall)) *fptr)(int);
void t21(void) {
fptr(10);
}
// CHECK: [[FPTRVAR:%[a-z0-9]+]] = load void (i32)*, void (i32)** @fptr
// CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 inreg 10)
// PR9356: We might want to err on this, but for now at least make sure we
// use the section in the definition.
void __attribute__((section(".foo"))) t22(void);
void __attribute__((section(".bar"))) t22(void) {}
// CHECK: define void @t22() [[NUW]] section ".bar"
// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
// CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.h | <reponame>Polidea/SiriusObfuscator
//===-- NativeProcessDarwin.h --------------------------------- -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef NativeProcessDarwin_h
#define NativeProcessDarwin_h
// NOTE: this code should only be compiled on Apple Darwin systems. It is
// not cross-platform code and is not intended to build on any other platform.
// Therefore, platform-specific headers and code are okay here.
// C includes
#include <mach/mach_types.h>
// C++ includes
#include <mutex>
#include <unordered_set>
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/Debug.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/lldb-types.h"
#include "LaunchFlavor.h"
#include "MachException.h"
#include "NativeThreadDarwin.h"
#include "NativeThreadListDarwin.h"
namespace lldb_private {
class Error;
class Scalar;
namespace process_darwin {
/// @class NativeProcessDarwin
/// @brief Manages communication with the inferior (debugee) process.
///
/// Upon construction, this class prepares and launches an inferior
/// process for debugging.
///
/// Changes in the inferior process state are broadcasted.
class NativeProcessDarwin : public NativeProcessProtocol {
friend Error NativeProcessProtocol::Launch(
ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
friend Error NativeProcessProtocol::Attach(
lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
public:
~NativeProcessDarwin() override;
// -----------------------------------------------------------------
// NativeProcessProtocol Interface
// -----------------------------------------------------------------
Error Resume(const ResumeActionList &resume_actions) override;
Error Halt() override;
Error Detach() override;
Error Signal(int signo) override;
Error Interrupt() override;
Error Kill() override;
Error GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) override;
Error ReadMemory(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read) override;
Error ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read) override;
Error WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
size_t &bytes_written) override;
Error AllocateMemory(size_t size, uint32_t permissions,
lldb::addr_t &addr) override;
Error DeallocateMemory(lldb::addr_t addr) override;
lldb::addr_t GetSharedLibraryInfoAddress() override;
size_t UpdateThreads() override;
bool GetArchitecture(ArchSpec &arch) const override;
Error SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override;
void DoStopIDBumped(uint32_t newBumpId) override;
Error GetLoadedModuleFileSpec(const char *module_path,
FileSpec &file_spec) override;
Error GetFileLoadAddress(const llvm::StringRef &file_name,
lldb::addr_t &load_addr) override;
NativeThreadDarwinSP GetThreadByID(lldb::tid_t id);
task_t GetTask() const { return m_task; }
// -----------------------------------------------------------------
// Interface used by NativeRegisterContext-derived classes.
// -----------------------------------------------------------------
static Error PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
void *data = nullptr, size_t data_size = 0,
long *result = nullptr);
bool SupportHardwareSingleStepping() const;
protected:
// -----------------------------------------------------------------
// NativeProcessProtocol protected interface
// -----------------------------------------------------------------
Error
GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint,
size_t &actual_opcode_size,
const uint8_t *&trap_opcode_bytes) override;
private:
// -----------------------------------------------------------------
/// Mach task-related Member Variables
// -----------------------------------------------------------------
// The task port for the inferior process.
mutable task_t m_task;
// True if the inferior process did an exec since we started
// monitoring it.
bool m_did_exec;
// The CPU type of this process.
mutable cpu_type_t m_cpu_type;
// -----------------------------------------------------------------
/// Exception/Signal Handling Member Variables
// -----------------------------------------------------------------
// Exception port on which we will receive child exceptions
mach_port_t m_exception_port;
// Saved state of the child exception port prior to us installing
// our own intercepting port.
MachException::PortInfo m_exc_port_info;
// The thread that runs the Mach exception read and reply handler.
pthread_t m_exception_thread;
// TODO see if we can remove this if we get the exception collection
// and distribution to happen in a single-threaded fashion.
std::recursive_mutex m_exception_messages_mutex;
// A collection of exception messages caught when listening to the
// exception port.
MachException::Message::collection m_exception_messages;
// When we call MachProcess::Interrupt(), we want to send this
// signal (if non-zero).
int m_sent_interrupt_signo;
// If we resume the process and still haven't received our
// interrupt signal (if this is non-zero).
int m_auto_resume_signo;
// -----------------------------------------------------------------
/// Thread-related Member Variables
// -----------------------------------------------------------------
NativeThreadListDarwin m_thread_list;
ResumeActionList m_thread_actions;
// -----------------------------------------------------------------
/// Process Lifetime Member Variable
// -----------------------------------------------------------------
// The pipe over which the waitpid thread and the main loop will
// communicate.
Pipe m_waitpid_pipe;
// The thread that runs the waitpid handler.
pthread_t m_waitpid_thread;
// waitpid reader callback handle.
MainLoop::ReadHandleUP m_waitpid_reader_handle;
#if 0
ArchSpec m_arch;
LazyBool m_supports_mem_region;
std::vector<MemoryRegionInfo> m_mem_region_cache;
lldb::tid_t m_pending_notification_tid;
// List of thread ids stepping with a breakpoint with the address of
// the relevan breakpoint
std::map<lldb::tid_t, lldb::addr_t>
m_threads_stepping_with_breakpoint;
#endif
// -----------------------------------------------------------------
// Private Instance Methods
// -----------------------------------------------------------------
NativeProcessDarwin(lldb::pid_t pid, int pty_master_fd);
// -----------------------------------------------------------------
/// Finalize the launch.
///
/// This method associates the NativeProcessDarwin instance with
/// the host process that was just launched. It peforms actions
/// like attaching a listener to the inferior exception port,
/// ptracing the process, and the like.
///
/// @param[in] launch_flavor
/// The launch flavor that was used to launch the process.
///
/// @param[in] main_loop
/// The main loop that will run the process monitor. Work
/// that needs to be done (e.g. reading files) gets registered
/// here along with callbacks to process the work.
///
/// @return
/// Any error that occurred during the aforementioned
/// operations. Failure here will force termination of the
/// launched process and debugging session.
// -----------------------------------------------------------------
Error FinalizeLaunch(LaunchFlavor launch_flavor, MainLoop &main_loop);
Error SaveExceptionPortInfo();
void ExceptionMessageReceived(const MachException::Message &message);
void MaybeRaiseThreadPriority();
Error StartExceptionThread();
Error SendInferiorExitStatusToMainLoop(::pid_t pid, int status);
Error HandleWaitpidResult();
bool ProcessUsingSpringBoard() const;
bool ProcessUsingBackBoard() const;
static void *ExceptionThread(void *arg);
void *DoExceptionThread();
lldb::addr_t GetDYLDAllImageInfosAddress(Error &error) const;
static uint32_t GetCPUTypeForLocalProcess(::pid_t pid);
uint32_t GetCPUType() const;
task_t ExceptionMessageBundleComplete();
void StartSTDIOThread();
Error StartWaitpidThread(MainLoop &main_loop);
static void *WaitpidThread(void *arg);
void *DoWaitpidThread();
task_t TaskPortForProcessID(Error &error, bool force = false) const;
/// Attaches to an existing process. Forms the
/// implementation of Process::DoAttach.
void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Error &error);
::pid_t Attach(lldb::pid_t pid, Error &error);
Error PrivateResume();
Error ReplyToAllExceptions();
Error ResumeTask();
bool IsTaskValid() const;
bool IsTaskValid(task_t task) const;
mach_port_t GetExceptionPort() const;
bool IsExceptionPortValid() const;
Error GetTaskBasicInfo(task_t task, struct task_basic_info *info) const;
Error SuspendTask();
static Error SetDefaultPtraceOpts(const lldb::pid_t);
static void *MonitorThread(void *baton);
void MonitorCallback(lldb::pid_t pid, bool exited, int signal, int status);
void WaitForNewThread(::pid_t tid);
void MonitorSIGTRAP(const siginfo_t &info, NativeThreadDarwin &thread);
void MonitorTrace(NativeThreadDarwin &thread);
void MonitorBreakpoint(NativeThreadDarwin &thread);
void MonitorWatchpoint(NativeThreadDarwin &thread, uint32_t wp_index);
void MonitorSignal(const siginfo_t &info, NativeThreadDarwin &thread,
bool exited);
Error SetupSoftwareSingleStepping(NativeThreadDarwin &thread);
#if 0
static ::ProcessMessage::CrashReason
GetCrashReasonForSIGSEGV(const siginfo_t *info);
static ::ProcessMessage::CrashReason
GetCrashReasonForSIGILL(const siginfo_t *info);
static ::ProcessMessage::CrashReason
GetCrashReasonForSIGFPE(const siginfo_t *info);
static ::ProcessMessage::CrashReason
GetCrashReasonForSIGBUS(const siginfo_t *info);
#endif
bool HasThreadNoLock(lldb::tid_t thread_id);
bool StopTrackingThread(lldb::tid_t thread_id);
NativeThreadDarwinSP AddThread(lldb::tid_t thread_id);
Error GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size);
Error FixupBreakpointPCAsNeeded(NativeThreadDarwin &thread);
/// Writes a siginfo_t structure corresponding to the given thread
/// ID to the memory region pointed to by @p siginfo.
Error GetSignalInfo(lldb::tid_t tid, void *siginfo);
/// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG)
/// corresponding to the given thread ID to the memory pointed to
/// by @p message.
Error GetEventMessage(lldb::tid_t tid, unsigned long *message);
void NotifyThreadDeath(lldb::tid_t tid);
Error Detach(lldb::tid_t tid);
// This method is requests a stop on all threads which are still
// running. It sets up a deferred delegate notification, which will
// fire once threads report as stopped. The triggerring_tid will be
// set as the current thread (main stop reason).
void StopRunningThreads(lldb::tid_t triggering_tid);
// Notify the delegate if all threads have stopped.
void SignalIfAllThreadsStopped();
// Resume the given thread, optionally passing it the given signal.
// The type of resume operation (continue, single-step) depends on
// the state parameter.
Error ResumeThread(NativeThreadDarwin &thread, lldb::StateType state,
int signo);
void ThreadWasCreated(NativeThreadDarwin &thread);
void SigchldHandler();
};
} // namespace process_darwin
} // namespace lldb_private
#endif /* NativeProcessDarwin_h */
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/include/lldb/Interpreter/OptionGroupUUID.h | <gh_stars>100-1000
//===-- OptionGroupUUID.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_OptionGroupUUID_h_
#define liblldb_OptionGroupUUID_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/OptionValueUUID.h"
#include "lldb/Interpreter/Options.h"
namespace lldb_private {
//-------------------------------------------------------------------------
// OptionGroupUUID
//-------------------------------------------------------------------------
class OptionGroupUUID : public OptionGroup {
public:
OptionGroupUUID();
~OptionGroupUUID() override;
llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
ExecutionContext *execution_context) override;
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override;
const OptionValueUUID &GetOptionValue() const { return m_uuid; }
protected:
OptionValueUUID m_uuid;
};
} // namespace lldb_private
#endif // liblldb_OptionGroupUUID_h_
|
Polidea/SiriusObfuscator | SymbolExtractorAndRenamer/lldb/include/lldb/Interpreter/Args.h | //===-- Args.h --------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Command_h_
#define liblldb_Command_h_
// C Includes
// C++ Includes
#include <list>
#include <string>
#include <utility>
#include <vector>
// Other libraries and framework includes
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
// Project includes
#include "lldb/Core/Error.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/lldb-private-types.h"
#include "lldb/lldb-types.h"
namespace lldb_private {
typedef std::vector<std::tuple<std::string, int, std::string>> OptionArgVector;
typedef std::shared_ptr<OptionArgVector> OptionArgVectorSP;
struct OptionArgElement {
enum { eUnrecognizedArg = -1, eBareDash = -2, eBareDoubleDash = -3 };
OptionArgElement(int defs_index, int pos, int arg_pos)
: opt_defs_index(defs_index), opt_pos(pos), opt_arg_pos(arg_pos) {}
int opt_defs_index;
int opt_pos;
int opt_arg_pos;
};
typedef std::vector<OptionArgElement> OptionElementVector;
//----------------------------------------------------------------------
/// @class Args Args.h "lldb/Interpreter/Args.h"
/// @brief A command line argument class.
///
/// The Args class is designed to be fed a command line. The
/// command line is copied into an internal buffer and then split up
/// into arguments. Arguments are space delimited if there are no quotes
/// (single, double, or backtick quotes) surrounding the argument. Spaces
/// can be escaped using a \ character to avoid having to surround an
/// argument that contains a space with quotes.
//----------------------------------------------------------------------
class Args {
public:
struct ArgEntry {
private:
friend class Args;
std::unique_ptr<char[]> ptr;
char *data() { return ptr.get(); }
public:
ArgEntry() = default;
ArgEntry(llvm::StringRef str, char quote);
llvm::StringRef ref;
char quote;
const char *c_str() const { return ptr.get(); }
};
//------------------------------------------------------------------
/// Construct with an option command string.
///
/// @param[in] command
/// A NULL terminated command that will be copied and split up
/// into arguments.
///
/// @see Args::SetCommandString(llvm::StringRef)
//------------------------------------------------------------------
Args(llvm::StringRef command = llvm::StringRef());
Args(const Args &rhs);
Args &operator=(const Args &rhs);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~Args();
//------------------------------------------------------------------
/// Dump all entries to the stream \a s using label \a label_name.
///
/// If label_name is nullptr, the dump operation is skipped.
///
/// @param[in] s
/// The stream to which to dump all arguments in the argument
/// vector.
/// @param[in] label_name
/// The label_name to use as the label printed for each
/// entry of the args like so:
/// {label_name}[{index}]={value}
//------------------------------------------------------------------
void Dump(Stream &s, const char *label_name = "argv") const;
//------------------------------------------------------------------
/// Sets the command string contained by this object.
///
/// The command string will be copied and split up into arguments
/// that can be accessed via the accessor functions.
///
/// @param[in] command
/// A command StringRef that will be copied and split up
/// into arguments.
///
/// @see Args::GetArgumentCount() const
/// @see Args::GetArgumentAtIndex (size_t) const
/// @see Args::GetArgumentVector ()
/// @see Args::Shift ()
/// @see Args::Unshift (const char *)
//------------------------------------------------------------------
void SetCommandString(llvm::StringRef command);
bool GetCommandString(std::string &command) const;
bool GetQuotedCommandString(std::string &command) const;
//------------------------------------------------------------------
/// Gets the number of arguments left in this command object.
///
/// @return
/// The number or arguments in this object.
//------------------------------------------------------------------
size_t GetArgumentCount() const;
bool empty() const { return GetArgumentCount() == 0; }
//------------------------------------------------------------------
/// Gets the NULL terminated C string argument pointer for the
/// argument at index \a idx.
///
/// @return
/// The NULL terminated C string argument pointer if \a idx is a
/// valid argument index, NULL otherwise.
//------------------------------------------------------------------
const char *GetArgumentAtIndex(size_t idx) const;
llvm::ArrayRef<ArgEntry> entries() const { return m_entries; }
char GetArgumentQuoteCharAtIndex(size_t idx) const;
std::vector<ArgEntry>::const_iterator begin() const {
return m_entries.begin();
}
std::vector<ArgEntry>::const_iterator end() const { return m_entries.end(); }
size_t size() const { return GetArgumentCount(); }
const ArgEntry &operator[](size_t n) const { return m_entries[n]; }
//------------------------------------------------------------------
/// Gets the argument vector.
///
/// The value returned by this function can be used by any function
/// that takes and vector. The return value is just like \a argv
/// in the standard C entry point function:
/// \code
/// int main (int argc, const char **argv);
/// \endcode
///
/// @return
/// An array of NULL terminated C string argument pointers that
/// also has a terminating NULL C string pointer
//------------------------------------------------------------------
char **GetArgumentVector();
//------------------------------------------------------------------
/// Gets the argument vector.
///
/// The value returned by this function can be used by any function
/// that takes and vector. The return value is just like \a argv
/// in the standard C entry point function:
/// \code
/// int main (int argc, const char **argv);
/// \endcode
///
/// @return
/// An array of NULL terminate C string argument pointers that
/// also has a terminating NULL C string pointer
//------------------------------------------------------------------
const char **GetConstArgumentVector() const;
//------------------------------------------------------------------
/// Appends a new argument to the end of the list argument list.
///
/// @param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
//------------------------------------------------------------------
void AppendArgument(llvm::StringRef arg_str, char quote_char = '\0');
void AppendArguments(const Args &rhs);
void AppendArguments(const char **argv);
//------------------------------------------------------------------
/// Insert the argument value at index \a idx to \a arg_cstr.
///
/// @param[in] idx
/// The index of where to insert the argument.
///
/// @param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
///
/// @return
/// The NULL terminated C string of the copy of \a arg_cstr.
//------------------------------------------------------------------
void InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
char quote_char = '\0');
//------------------------------------------------------------------
/// Replaces the argument value at index \a idx to \a arg_cstr
/// if \a idx is a valid argument index.
///
/// @param[in] idx
/// The index of the argument that will have its value replaced.
///
/// @param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
//------------------------------------------------------------------
void ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
char quote_char = '\0');
//------------------------------------------------------------------
/// Deletes the argument value at index
/// if \a idx is a valid argument index.
///
/// @param[in] idx
/// The index of the argument that will have its value replaced.
///
//------------------------------------------------------------------
void DeleteArgumentAtIndex(size_t idx);
//------------------------------------------------------------------
/// Sets the argument vector value, optionally copying all
/// arguments into an internal buffer.
///
/// Sets the arguments to match those found in \a argv. All argument
/// strings will be copied into an internal buffers.
//
// FIXME: Handle the quote character somehow.
//------------------------------------------------------------------
void SetArguments(size_t argc, const char **argv);
void SetArguments(const char **argv);
//------------------------------------------------------------------
/// Shifts the first argument C string value of the array off the
/// argument array.
///
/// The string value will be freed, so a copy of the string should
/// be made by calling Args::GetArgumentAtIndex (size_t) const
/// first and copying the returned value before calling
/// Args::Shift().
///
/// @see Args::GetArgumentAtIndex (size_t) const
//------------------------------------------------------------------
void Shift();
//------------------------------------------------------------------
/// Inserts a class owned copy of \a arg_cstr at the beginning of
/// the argument vector.
///
/// A copy \a arg_cstr will be made.
///
/// @param[in] arg_cstr
/// The argument to push on the front of the argument stack.
///
/// @param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
//------------------------------------------------------------------
void Unshift(llvm::StringRef arg_str, char quote_char = '\0');
//------------------------------------------------------------------
/// Parse the arguments in the contained arguments.
///
/// The arguments that are consumed by the argument parsing process
/// will be removed from the argument vector. The arguments that
/// get processed start at the second argument. The first argument
/// is assumed to be the command and will not be touched.
///
/// param[in] platform_sp
/// The platform used for option validation. This is necessary
/// because an empty execution_context is not enough to get us
/// to a reasonable platform. If the platform isn't given,
/// we'll try to get it from the execution context. If we can't
/// get it from the execution context, we'll skip validation.
///
/// param[in] require_validation
/// When true, it will fail option parsing if validation could
/// not occur due to not having a platform.
///
/// @see class Options
//------------------------------------------------------------------
Error ParseOptions(Options &options, ExecutionContext *execution_context,
lldb::PlatformSP platform_sp, bool require_validation);
bool IsPositionalArgument(const char *arg);
// The following works almost identically to ParseOptions, except that no
// option is required to have arguments, and it builds up the
// option_arg_vector as it parses the options.
std::string ParseAliasOptions(Options &options, CommandReturnObject &result,
OptionArgVector *option_arg_vector,
llvm::StringRef raw_input_line);
void ParseArgsForCompletion(Options &options,
OptionElementVector &option_element_vector,
uint32_t cursor_index);
bool GetOptionValueAsString(const char *option, std::string &value);
int GetOptionValuesAsStrings(const char *option,
std::vector<std::string> &values);
//------------------------------------------------------------------
// Clear the arguments.
//
// For re-setting or blanking out the list of arguments.
//------------------------------------------------------------------
void Clear();
static const char *StripSpaces(std::string &s, bool leading = true,
bool trailing = true,
bool return_null_if_empty = true);
static bool UInt64ValueIsValidForByteSize(uint64_t uval64,
size_t total_byte_size) {
if (total_byte_size > 8)
return false;
if (total_byte_size == 8)
return true;
const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
return uval64 <= max;
}
static bool SInt64ValueIsValidForByteSize(int64_t sval64,
size_t total_byte_size) {
if (total_byte_size > 8)
return false;
if (total_byte_size == 8)
return true;
const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
const int64_t min = ~(max);
return min <= sval64 && sval64 <= max;
}
static lldb::addr_t StringToAddress(const ExecutionContext *exe_ctx,
llvm::StringRef s,
lldb::addr_t fail_value, Error *error);
static bool StringToBoolean(llvm::StringRef s, bool fail_value,
bool *success_ptr);
static char StringToChar(llvm::StringRef s, char fail_value,
bool *success_ptr);
static int64_t StringToOptionEnum(llvm::StringRef s,
OptionEnumValueElement *enum_values,
int32_t fail_value, Error &error);
static lldb::ScriptLanguage
StringToScriptLanguage(llvm::StringRef s, lldb::ScriptLanguage fail_value,
bool *success_ptr);
// TODO: Use StringRef
static Error StringToFormat(const char *s, lldb::Format &format,
size_t *byte_size_ptr); // If non-NULL, then a
// byte size can precede
// the format character
static lldb::Encoding
StringToEncoding(llvm::StringRef s,
lldb::Encoding fail_value = lldb::eEncodingInvalid);
static uint32_t StringToGenericRegister(llvm::StringRef s);
static bool StringToVersion(llvm::StringRef string, uint32_t &major,
uint32_t &minor, uint32_t &update);
static const char *GetShellSafeArgument(const FileSpec &shell,
const char *unsafe_arg,
std::string &safe_arg);
// EncodeEscapeSequences will change the textual representation of common
// escape sequences like "\n" (two characters) into a single '\n'. It does
// this for all of the supported escaped sequences and for the \0ooo (octal)
// and \xXX (hex). The resulting "dst" string will contain the character
// versions of all supported escape sequences. The common supported escape
// sequences are: "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\'", "\"", "\\".
static void EncodeEscapeSequences(const char *src, std::string &dst);
// ExpandEscapeSequences will change a string of possibly non-printable
// characters and expand them into text. So '\n' will turn into two characters
// like "\n" which is suitable for human reading. When a character is not
// printable and isn't one of the common in escape sequences listed in the
// help for EncodeEscapeSequences, then it will be encoded as octal. Printable
// characters are left alone.
static void ExpandEscapedCharacters(const char *src, std::string &dst);
static std::string EscapeLLDBCommandArgument(const std::string &arg,
char quote_char);
//------------------------------------------------------------------
/// Add or replace an environment variable with the given value.
///
/// This command adds the environment variable if it is not already
/// present using the given value. If the environment variable is
/// already in the list, it replaces the first such occurrence
/// with the new value.
//------------------------------------------------------------------
void AddOrReplaceEnvironmentVariable(llvm::StringRef env_var_name,
llvm::StringRef new_value);
/// Return whether a given environment variable exists.
///
/// This command treats Args like a list of environment variables,
/// as used in ProcessLaunchInfo. It treats each argument as
/// an {env_var_name}={value} or an {env_var_name} entry.
///
/// @param[in] env_var_name
/// Specifies the name of the environment variable to check.
///
/// @param[out] argument_index
/// If non-null, then when the environment variable is found,
/// the index of the argument position will be returned in
/// the size_t pointed to by this argument.
///
/// @return
/// true if the specified env var name exists in the list in
/// either of the above-mentioned formats; otherwise, false.
//------------------------------------------------------------------
bool ContainsEnvironmentVariable(llvm::StringRef env_var_name,
size_t *argument_index = nullptr) const;
private:
size_t FindArgumentIndexForOption(Option *long_options,
int long_options_index) const;
std::vector<ArgEntry> m_entries;
std::vector<char *> m_argv;
void UpdateArgsAfterOptionParsing();
};
} // namespace lldb_private
#endif // liblldb_Command_h_
|
Subsets and Splits