Skip to content

Commit

Permalink
LOTS of mostly minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Harmon committed Nov 4, 2013
1 parent 4919e84 commit bcd97ff
Show file tree
Hide file tree
Showing 29 changed files with 689 additions and 107 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ PYDIR := $(TOPDIR)/python
SLICE2PY_LOCKFILE := $(TOPDIR)/.slice2py-lock

FLAGS_ALL := $(FLAGS_ALL) -ferror-limit=3
FLAGS_PREPROC_AND_COMPILER := $(FLAGS_PREPROC_AND_COMPILER) -Wall -Wextra -Wnonnull
FLAGS_PREPROC_AND_COMPILER := $(FLAGS_PREPROC_AND_COMPILER) -Wall -Wextra -Wnonnull -Werror -pedantic
FLAGS_PREPROC_AND_COMPILER_CXX := $(FLAGS_PREPROC_AND_COMPILER_CXX) -std=c++98
FLAGS_PREPROC_AND_COMPILER_C := $(FLAGS_PREPROC_AND_COMPILER_C) -std=c99
FLAGS_PREPROC_AND_COMPILER_C := $(FLAGS_PREPROC_AND_COMPILER_C) -std=c11
FLAGS_COMPILER := $(FLAGS_COMPILER) -g -fno-omit-frame-pointer -O0 -fno-optimize-sibling-calls -fPIC -fvisibility=hidden -pipe

FLAGS_PREPROC_AND_COMPILER := $(FLAGS_PREPROC_AND_COMPILER) $(shell $(PKG_CONFIG) --cflags 'glib-2.0 >= 2.38')
Expand Down Expand Up @@ -99,6 +99,10 @@ COMPILE_FLAGS_PREFIX :=

include $(TOPDIR)/mk/compile_flags.mk

define subst_vars
$(SED) -e "s,@prefix@,$(PREFIX:,=\,),g" $< > $@ || $(RM) $@
endef

# This defines the following for every dir in SUBDIRS:
# Sets CURDIR to the $(TOPDIR)/$(dir)
# Includes a makefile in $(CURDIR)/Makefile
Expand Down Expand Up @@ -153,4 +157,4 @@ COMPILE_FLAGS_PREFIX :=
$(CXX) $(SO_LINK_FLAGS) -o $@ $(SO_OBJECTS) $(FLAGS_LINKER)

%: %.in
$(SED) -e "s,@prefix@,$(PREFIX:,=\,),g" $< > $@ || $(RM) $@
$(subst_vars)
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
C++ variable initialization may throw
Introspection of opaque types don't error
2 changes: 1 addition & 1 deletion doc/html
Submodule html updated 50 files
+1 −1 aggregate__member_8h.html
+1 −1 aggregate__type_8h.html
+1 −1 annotated.html
+1 −1 builtin__type_8h.html
+1 −1 classes.html
+1 −1 dir_1229bae49d98528e082d5169ebe9d673.html
+1 −1 errors_8h.html
+1 −1 files.html
+1 −1 functions.html
+1 −1 functions_func.html
+1 −1 globals.html
+1 −1 globals_defs.html
+1 −1 globals_enum.html
+1 −1 globals_eval.html
+1 −1 globals_func.html
+1 −1 hierarchy.html
+1 −1 index.html
+1 −1 inherits.html
+1 −1 pages.html
+1 −1 ruminate_2ruminate_8h.html
+1 −1 ruminate_8h.html
+1 −1 struct_r_aggregate_member-members.html
+1 −2 struct_r_aggregate_member.html
+1 −1 struct_r_aggregate_type-members.html
+1 −1 struct_r_aggregate_type.html
+1 −1 struct_r_array_type-members.html
+1 −1 struct_r_array_type.html
+1 −1 struct_r_builtin_type-members.html
+1 −1 struct_r_builtin_type.html
+1 −1 struct_r_enum_member-members.html
+1 −1 struct_r_enum_member.html
+1 −1 struct_r_frame-members.html
+1 −1 struct_r_frame.html
+1 −1 struct_r_frame_list-members.html
+1 −1 struct_r_frame_list.html
+1 −1 struct_r_function_type-members.html
+1 −1 struct_r_function_type.html
+1 −1 struct_r_pointer_type-members.html
+1 −1 struct_r_pointer_type.html
+1 −1 struct_r_string-members.html
+1 −1 struct_r_string.html
+1 −1 struct_r_type-members.html
+1 −1 struct_r_type.html
+1 −1 struct_r_type_member-members.html
+1 −1 struct_r_type_member.html
+1 −1 struct_r_typedef_type-members.html
+2 −2 struct_r_typedef_type.html
+2 −4 todo.html
+1 −1 type_8h.html
+1 −1 type__member_8h.html
76 changes: 40 additions & 36 deletions include/private/common.h
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
#define gxx_call(body, error) ({ \
bool ret = true; \
try { \
body; \
} catch( Ice::Exception &ex ) { \
/* If we throw here, meh. */ \
std::ostringstream ss; \
ss << ex; \
g_set_error( \
error, \
RUMINATE_ERROR, \
RUMINATE_ERROR_ICE, \
"%s", \
ss.str().c_str() \
); \
ret = false; \
} catch( std::exception &ex ) { \
g_set_error( \
error, \
RUMINATE_ERROR, \
RUMINATE_ERROR_STDLIB, \
"%s", \
ex.what() \
); \
ret = false; \
} catch(...) { \
g_set_error_literal( \
error, \
RUMINATE_ERROR, \
RUMINATE_ERROR_UNSPEC, \
"Unspecified error" \
); \
ret = false; \
} \
ret; \
})
#define gxx_call(body, error) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wgnu-statement-expression\"") \
({ \
bool ret = true; \
try { \
body; \
} catch( Ice::Exception &ex ) { \
/* If we throw here, meh. */ \
std::ostringstream ss; \
ss << ex; \
g_set_error( \
error, \
RUMINATE_ERROR, \
RUMINATE_ERROR_ICE, \
"%s", \
ss.str().c_str() \
); \
ret = false; \
} catch( std::exception &ex ) { \
g_set_error( \
error, \
RUMINATE_ERROR, \
RUMINATE_ERROR_STDLIB, \
"%s", \
ex.what() \
); \
ret = false; \
} catch(...) { \
g_set_error_literal( \
error, \
RUMINATE_ERROR, \
RUMINATE_ERROR_UNSPEC, \
"Unspecified error" \
); \
ret = false; \
} \
ret; \
}) \
_Pragma("clang diagnostic pop")
7 changes: 7 additions & 0 deletions include/private/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@
#include <glib.h>

#pragma clang diagnostic pop

#define R_STATIC_ASSERT(cond) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wvla-extension\"") \
_Pragma("clang diagnostic ignored \"-Wpedantic\"") \
G_STATIC_ASSERT(cond) \
_Pragma("clang diagnostic pop")
28 changes: 16 additions & 12 deletions include/ruminate/ruminate.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ G_END_DECLS
* @return A pointer to an RType or `NULL` if an error occurred. This RType
* must be freed using r_type_unref().
*/
#define ruminate_get_type(expr, error) ({ \
__typeof__(expr) *_expr = g_malloc(sizeof(__typeof__(expr))); \
*_expr = (expr); \
RType *ret; \
if( !ruminate_begin_get_type_by_variable_name("_expr", error) ) { \
ret = NULL; \
} else { \
ruminate_hit_breakpoint(); \
ret = ruminate_end_get_type_by_variable_name(_expr, error); \
} \
ret; \
})
#define ruminate_get_type(expr, error) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wgnu-statement-expression\"") \
({ \
__typeof__(expr) *_expr = g_malloc(sizeof(__typeof__(expr))); \
*_expr = (expr); \
RType *ret; \
if( !ruminate_begin_get_type_by_variable_name("_expr", error) ) { \
ret = NULL; \
} else { \
ruminate_hit_breakpoint(); \
ret = ruminate_end_get_type_by_variable_name(_expr, error); \
} \
ret; \
}) \
_Pragma("clang diagnostic pop")
2 changes: 1 addition & 1 deletion include/ruminate/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ size_t RUMINATE_EXPORT r_string_length(
) RUMINATE_NOEXCEPT;

/// @todo document
GQuark r_string_quark( RString * );
GQuark RUMINATE_EXPORT r_string_quark( RString * ) RUMINATE_NOEXCEPT;

G_END_DECLS
5 changes: 4 additions & 1 deletion python/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.PHONY: python/clean python/all python/install

python/all: $(ICE_IN_PYDIR_PY_SOURCES) $(ICE_IN_PYDIR_PY_MODDIR) $(PYTHON_DBGSVR)
$(CHMOD) +x $(PYTHON_DBGSVR)

$(PYTHON_DBGSVR): $(PYTHON_DBGSVR_INPUT)
$(subst_vars)
$(CHMOD) +x $(PYTHON_DBGSVR) || $(RM) $(PYTHON_DBGSVR)

python/clean:
$(RM) $(PYTHON_OBJECTS) $(ICE_IN_PYDIR_PY_OBJECTS) $(ICE_IN_PYDIR_PY_SOURCES) $(PYTHON_DBGSVR)
Expand Down
3 changes: 2 additions & 1 deletion python/debugger_factory_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def shutdown(self, current = None):
self.adapter.getCommunicator().shutdown()

def create(self, options, cbid, current):
debugee = DebugeePrx.uncheckedCast(current.con.createProxy(cbid))
#debugee = DebugeePrx.uncheckedCast(current.con.createProxy(cbid))
debugee = None
debugger = DebuggerImpl(options, self.shutdown, debugee)
proxy = DebuggerPrx.uncheckedCast(
current.adapter.addWithUUID(
Expand Down
20 changes: 10 additions & 10 deletions python/debugger_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ def onStopped(event):

process = SBProcess.GetProcessFromEvent(event)

#unix_signals = validate(process.GetUnixSignals())
## This may not need to be here, we might be able to put it
## outside the onStopped func
#for sig in unix_signals.signals:
# unix_signals.SetShouldSuppress(sig, False)
# unix_signals.SetShouldStop(sig, False)
# unix_signals.SetShouldNotify(sig, False)

# A temporary hack since the above is racy.
unix_signals = validate(process.GetUnixSignals())
# This may not need to be here, we might be able to put it
# outside the onStopped func
for sig in unix_signals.signals:
self.debugger.HandleCommand("process handle -n false -p true -s false " + unix_signals.GetSignalAsCString(sig))
unix_signals.SetShouldSuppress(sig, False)
unix_signals.SetShouldStop(sig, False)
unix_signals.SetShouldNotify(sig, False)

## A temporary hack since the above is racy.
#unix_signals = validate(process.GetUnixSignals())
#for sig in unix_signals.signals:
# self.debugger.HandleCommand("process handle -n false -p true -s false " + unix_signals.GetSignalAsCString(sig))

process.Continue()
self.em.addCallback(lldb.eStateStopped, onStopped)
Expand Down
2 changes: 2 additions & 0 deletions python/lldb_em.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def run(self):
event = lldb.SBEvent()
#validate(self.listener.WaitForEvent(2**32-1, event))
if not self.listener.WaitForEvent(1, event):
if self.shutdownRequested:
break
continue
validate(event)
#print("Got event " + getDescription(event))
Expand Down
2 changes: 1 addition & 1 deletion python/type_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def getMembers(self, tid, current = None):
ret = []
array = self.debugger.createSBValueFor(self.sbtype, self.address)
for index in range(0, array.num_children):
child = array.GetChildAtIndex(index, lldb.eDynamicDontRunTarget, False)
child = array.GetChildAtIndex(index, lldb.eDynamicCanRunTarget, False)
ret.append(
type_member_impl.SBTypeAdapter.proxyFor(
sbtype = child.type,
Expand Down
1 change: 1 addition & 0 deletions python/variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ PYTHON_SOURCES := $(PYTHON_SOURCES:%=$(CURDIR)/%)
PYTHON_OBJECTS := $(PYTHON_SOURCES:.py=.pyc)

PYTHON_DBGSVR := $(CURDIR)/ruminate-dbgsvr
PYTHON_DBGSVR_INPUT := $(PYTHON_DBGSVR).in
2 changes: 1 addition & 1 deletion src/array_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static bool init_members( RArrayType *rat, GError **error ) RUMINATE_NOEXCEPT {

G_BEGIN_DECLS

G_STATIC_ASSERT(sizeof(size_t) >= sizeof(uint64_t));
R_STATIC_ASSERT(sizeof(size_t) >= sizeof(uint64_t));

size_t r_array_type_size( RArrayType *rat, GError **error ) RUMINATE_NOEXCEPT {
if( !init_members(rat, error) ) return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/pointer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RType *r_pointer_type_pointee( RPointerType *rpt, GError **error ) RUMINATE_NOEX
RType *rt = (RType *) rpt;
void *ptr = *((void **) rt->cur);
RuminateBackend::TypePrx t;
G_STATIC_ASSERT(sizeof(ptr) <= sizeof(::Ice::Long));
R_STATIC_ASSERT(sizeof(ptr) <= sizeof(::Ice::Long));
if( !gxx_call(t = ((RType *) rpt)->type->getPointeeType((::Ice::Long) ptr), error) )
return NULL;

Expand Down
40 changes: 33 additions & 7 deletions src/ruminate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

static Ruminate *ruminate;

#if 0
static Ice::Identity init_callbacks( Ice::CommunicatorPtr &, RuminateBackend::DebuggerFactoryPrx & );
#endif

G_BEGIN_DECLS

Expand All @@ -51,7 +53,10 @@ void ruminate_hit_breakpoint() RUMINATE_NOEXCEPT {

static gint fork_child( GError **err ) RUMINATE_NOEXCEPT {
size_t len = strlen(RUMINATE_DEBUGGER_CONTROLLER_PATH) + 1;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wvla-extension"
char controller_path[len];
#pragma clang diagnostic pop
memcpy(controller_path, RUMINATE_DEBUGGER_CONTROLLER_PATH, len);
char *argv[] = {
controller_path,
Expand Down Expand Up @@ -111,8 +116,8 @@ static int read_child_port( gint child_stdout, GError **error ) RUMINATE_NOEXCEP
return port;
}

G_STATIC_ASSERT(sizeof(::Ice::Long) >= sizeof(pid_t) && "A pid cannot fit in a long!");
G_STATIC_ASSERT(sizeof(::Ice::Long) >= sizeof(size_t) && "A pointer cannot fit in a long!");
R_STATIC_ASSERT(sizeof(::Ice::Long) >= sizeof(pid_t) && "A pid cannot fit in a long!");
R_STATIC_ASSERT(sizeof(::Ice::Long) >= sizeof(size_t) && "A pointer cannot fit in a long!");

bool ruminate_init( int *argc, char *argv[], GError **error ) RUMINATE_NOEXCEPT {
GError *err = NULL;
Expand All @@ -121,7 +126,9 @@ bool ruminate_init( int *argc, char *argv[], GError **error ) RUMINATE_NOEXCEPT
Ice::ObjectPrx factory_proxy;
gint child_stdout;
int port;
#if 0
Ice::Identity cbid;
#endif
Ice::PropertiesPtr props;
Ice::InitializationData id;

Expand All @@ -141,11 +148,14 @@ bool ruminate_init( int *argc, char *argv[], GError **error ) RUMINATE_NOEXCEPT
goto error_read_child_port;
}

// TODO: Handle exceptions
// TODO: Move all this checked C++ code into it's own method which can throw
// TODO: Remove ice arguments from argc.
props = Ice::createProperties(*argc, argv);
props->setProperty("Ice.ACM.Client", "0");
id.properties = props;
if( !gxx_call(props = Ice::createProperties(*argc, argv), error) )
goto error_ice_create_properties;
if( !gxx_call(props->setProperty("Ice.ACM.Client", "0"), error) )
goto error_ice_set_property;
if( !gxx_call(id.properties = props, error) )
goto error_ice_assign_properties;

if( !gxx_call(ruminate->communicator = Ice::initialize(id), error) )
goto error_ice_initialize;
Expand All @@ -158,15 +168,23 @@ bool ruminate_init( int *argc, char *argv[], GError **error ) RUMINATE_NOEXCEPT
if( !gxx_call(ruminate->factory = RuminateBackend::DebuggerFactoryPrx::checkedCast(factory_proxy), error) )
goto error_checkedCast;

#if 0
// TODO: Handle exceptions
cbid = init_callbacks(ruminate->communicator, ruminate->factory);
if( !gxx_call(cbid = init_callbacks(ruminate->communicator, ruminate->factory), error) )
goto error_init_callbacks;
#endif

opts.exename = argv[0];
opts.pid = getpid();
opts.breakpointAddress = (::Ice::Long) &ruminate_hit_breakpoint;

#if 0
if( !gxx_call(ruminate->debugger = ruminate->factory->create(opts, cbid), error) )
goto error_factory_create;
#else
if( !gxx_call(ruminate->debugger = ruminate->factory->create(opts, Ice::Identity()), error) )
goto error_factory_create;
#endif

atexit(ruminate_destroy_atexit);

Expand All @@ -175,10 +193,16 @@ bool ruminate_init( int *argc, char *argv[], GError **error ) RUMINATE_NOEXCEPT
return true;

error_factory_create:
#if 0
error_init_callbacks:
#endif
error_checkedCast:
error_communicator_stringToProxy:
g_free(proxy_str);
error_ice_initialize:
error_ice_assign_properties:
error_ice_set_property:
error_ice_create_properties:
error_read_child_port:
error_fork_child:
// TODO: Resource cleanup
Expand Down Expand Up @@ -237,6 +261,7 @@ RFrameList *ruminate_backtrace( GError **error ) RUMINATE_NOEXCEPT {

G_END_DECLS

#if 0
class DebugeeImpl : public RuminateBackend::Debugee {
public:
void stop( const Ice::Current & = Ice::Current() ) {
Expand All @@ -256,3 +281,4 @@ static Ice::Identity init_callbacks( Ice::CommunicatorPtr &communicator, Ruminat
proxy->ice_getConnection()->setAdapter(adapter);
return ident;
}
#endif
2 changes: 1 addition & 1 deletion src/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ size_t r_string_length( RString *rs ) RUMINATE_NOEXCEPT {
return rs->gstr->len;
}

GQuark r_string_quark( RString *rs ) {
GQuark r_string_quark( RString *rs ) RUMINATE_NOEXCEPT {
if( rs->quark.initialized ) return rs->quark.value;

rs->quark.value = g_quark_from_string(rs->gstr->str);
Expand Down
2 changes: 1 addition & 1 deletion src/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ RType *r_type_pointer( RType *rt, GError **error ) RUMINATE_NOEXCEPT {
rm = r_memory_new(ptrptr, rt->ptr, error);
if( rm == NULL ) goto err_r_memory_new;

G_STATIC_ASSERT(sizeof(void **) <= sizeof(::Ice::Long));
R_STATIC_ASSERT(sizeof(void **) <= sizeof(::Ice::Long));
if( !gxx_call(t = rt->type->getPointerType((::Ice::Long) ptrptr), error) )
goto err_getPointerType;
return r_type_new(t, rm, ptrptr, error);
Expand Down
2 changes: 1 addition & 1 deletion src/type_member.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void r_type_member_delete( RTypeMember *tm ) RUMINATE_NOEXCEPT {
}

bool _r_type_member_offset( RuminateBackend::TypeMemberPrx &tmp, ptrdiff_t *out, GError **error ) RUMINATE_NOEXCEPT {
G_STATIC_ASSERT(sizeof(ptrdiff_t) >= sizeof(__typeof__(tmp->getOffsetInBytes())));
R_STATIC_ASSERT(sizeof(ptrdiff_t) >= sizeof(__typeof__(tmp->getOffsetInBytes())));
g_assert(out != NULL);

// TODO: Error here if this type member has no offset (function arguments)
Expand Down
Loading

0 comments on commit bcd97ff

Please sign in to comment.