PengZheng commented on code in PR #473: URL: https://github.com/apache/celix/pull/473#discussion_r1071862064
########## misc/error_injector/error_injector.h: ########## @@ -0,0 +1,86 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. + */ + +#ifndef CELIX_ERROR_INJECTOR_H +#define CELIX_ERROR_INJECTOR_H +#ifdef __cplusplus +extern "C" { +#endif + +#include <assert.h> +#include <dlfcn.h> +#include <stddef.h> + +#define CELIX_EI_GET_CALLER(addr, level) \ +do { \ + Dl_info dlinfo; \ + void *dlret; \ + dlret = __builtin_return_address((level)); \ + assert(dladdr(dlret, &dlinfo)); \ Review Comment: `-rdynamic` is used to make `dladdr` work. This tech works for release and debug build. However, there is a limitation, if the caller is a static function (not visible outside the current translation unit), it will not work, in which case I will specify `CELIX_EI_UNKNOWN_CALLER` and rely solely on `ordinal`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org