Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lldb/test/Shell/Expr/Inputs/name-conflict-test/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "service.h"
#include <cassert>
#include <dlfcn.h>

#ifndef PLUGIN_PATH
#error "Expected PLUGIN_PATH to be defined"
#endif // !PLUGIN_PATH

int main() {
void *handle = dlopen(PLUGIN_PATH, RTLD_NOW);
assert(handle != nullptr);
void (*plugin_init)(void) = (void (*)(void))dlsym(handle, "plugin_init");
assert(plugin_init != nullptr);
void (*plugin_entry)(void) = (void (*)(void))dlsym(handle, "plugin_entry");
assert(plugin_entry != nullptr);

exported();
plugin_init();
plugin_entry();
return 0;
}
14 changes: 14 additions & 0 deletions lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "plugin.h"
#include "service.h"

struct Proxy : public Service {
State *proxyState;
};

Proxy *gProxyThis = 0;

extern "C" {
void plugin_init() { gProxyThis = new Proxy; }

void plugin_entry() {}
}
9 changes: 9 additions & 0 deletions lldb/test/Shell/Expr/Inputs/name-conflict-test/plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef PLUGIN_H_IN
#define PLUGIN_H_IN

extern "C" {
void plugin_entry(void);
void plugin_init(void);
}

#endif // _H_IN
14 changes: 14 additions & 0 deletions lldb/test/Shell/Expr/Inputs/name-conflict-test/service.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "service.h"

struct ServiceAux {
Service *Owner;
};

struct Service::State {};

void exported() {
// Make sure debug-info for definition of Service is
// emitted in this CU.
Service service;
service.start(0);
}
20 changes: 20 additions & 0 deletions lldb/test/Shell/Expr/Inputs/name-conflict-test/service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef SERVICE_H_IN
#define SERVICE_H_IN

struct ServiceAux;

struct Service {
struct State;
bool start(State *) { return true; }

#if HIDE_FROM_PLUGIN
int __resv1;
#endif // !HIDE_FROM_PLUGIN

Service *__owner;
ServiceAux *aux;
};

void exported();

#endif
17 changes: 17 additions & 0 deletions lldb/test/Shell/Expr/TestODRHandlingWithDylib.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# REQUIRES: system-darwin

# RUN: %clangxx_host %p/Inputs/name-conflict-test/plugin.cpp -shared -gdwarf -O0 -o %t.plugin.dylib
#
# RUN: %clangxx_host %p/Inputs/name-conflict-test/main.cpp \
# RUN: %p/Inputs/name-conflict-test/service.cpp \
# RUN: -DPLUGIN_PATH=\"%t.plugin.dylib\" \
# RUN: -DHIDE_FROM_PLUGIN \
# RUN: -gdwarf -O0 -o %t.a.out
#
# RUN: %lldb %t.a.out \
# RUN: -o "b plugin_entry" \
# RUN: -o run \
# RUN: -o "expr *gProxyThis" \
# RUN: -o exit | FileCheck %s

# CHECK: (lldb) expr *gProxyThis
Loading