hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Haohui Mai (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-7010) boot up libhdfs3 project
Date Mon, 06 Oct 2014 20:29:35 GMT

    [ https://issues.apache.org/jira/browse/HDFS-7010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14160885#comment-14160885
] 

Haohui Mai commented on HDFS-7010:
----------------------------------

I wonder, why the code needs to unwind the stack?

{code}
+static const std::string SymbolizeAndDemangle(void * pc) {
+    std::vector<char> buffer(1024);
+    std::ostringstream ss;
+    uint64_t pc0 = reinterpret_cast<uintptr_t>(pc);
+    uint64_t start_address = 0;
+    int object_fd = OpenObjectFileContainingPcAndGetStartAddress(pc0,
+                    start_address);
+
+    if (object_fd == -1) {
+        return DEFAULT_STACK_PREFIX"Unknown";
+    }
+
+    FileDescriptor wrapped_object_fd(object_fd);
+    int elf_type = FileGetElfType(wrapped_object_fd.get());
+
+    if (elf_type == -1) {
+        return DEFAULT_STACK_PREFIX"Unknown";
+    }
+
+    if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0,
+                                 &buffer[0], buffer.size(), start_address)) {
+        return DEFAULT_STACK_PREFIX"Unknown";
+    }
+
+    ss << DEFAULT_STACK_PREFIX << DemangleSymbol(&buffer[0]);
+    return ss.str();
+}
+
+#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
+
+static const std::string SymbolizeAndDemangle(void * pc) {
+    Dl_info info;
+    std::ostringstream ss;
+
+    if (dladdr(pc, &info) && info.dli_sname) {
+        ss << DEFAULT_STACK_PREFIX << DemangleSymbol(info.dli_sname);
+    } else {
+        ss << DEFAULT_STACK_PREFIX << "Unknown";
+    }
+
+    return ss.str();
+}
+
+#endif
+
+const std::string PrintStack(int skip, int maxDepth) {
+    std::ostringstream ss;
+    std::vector<void *> stack;
+    GetStack(skip + 1, maxDepth, stack);
+
+    for (size_t i = 0; i < stack.size(); ++i) {
+        ss << SymbolizeAndDemangle(stack[i]) << std::endl;
+    }
+
+    return ss.str();
+}
{code}

> boot up libhdfs3 project
> ------------------------
>
>                 Key: HDFS-7010
>                 URL: https://issues.apache.org/jira/browse/HDFS-7010
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: hdfs-client
>            Reporter: Zhanwei Wang
>            Assignee: Colin Patrick McCabe
>         Attachments: HDFS-7010-pnative.003.patch, HDFS-7010-pnative.004.patch, HDFS-7010-pnative.004.patch,
HDFS-7010.patch
>
>
> boot up libhdfs3 project with CMake, Readme and license file.
> Integrate google mock and google test



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message